Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs and memory leaks #4

Open
wants to merge 1 commit into
base: modelview
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 34 additions & 47 deletions include/nodes/internal/Compiler.hpp
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
#pragma once

#if \
defined (__MINGW32__) || \
defined (__MINGW64__)
# define NODE_EDITOR_COMPILER "MinGW"
# define NODE_EDITOR_COMPILER_MINGW
#elif \
defined (__GNUC__)
# define NODE_EDITOR_COMPILER "GNU"
# define NODE_EDITOR_COMPILER_GNU
# define NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR __GNUC__
# define NODE_EDITOR_COMPILER_GNU_VERSION_MINOR __GNUC_MINOR__
# define NODE_EDITOR_COMPILER_GNU_VERSION_PATCH __GNUC_PATCHLEVEL__
#elif \
defined (__clang__)
# define NODE_EDITOR_COMPILER "Clang"
# define NODE_EDITOR_COMPILER_CLANG
#elif \
defined (_MSC_VER)
# define NODE_EDITOR_COMPILER "Microsoft Visual C++"
# define NODE_EDITOR_COMPILER_MICROSOFT
#elif \
defined (__BORLANDC__)
# define NODE_EDITOR_COMPILER "Borland C++ Builder"
# define NODE_EDITOR_COMPILER_BORLAND
#elif \
defined (__CODEGEARC__)
# define NODE_EDITOR_COMPILER "CodeGear C++ Builder"
# define NODE_EDITOR_COMPILER_CODEGEAR
#elif \
defined (__INTEL_COMPILER) || \
defined (__ICL)
# define NODE_EDITOR_COMPILER "Intel C++"
# define NODE_EDITOR_COMPILER_INTEL
#elif \
defined (__xlC__) || \
defined (__IBMCPP__)
# define NODE_EDITOR_COMPILER "IBM XL C++"
# define NODE_EDITOR_COMPILER_IBM
#elif \
defined (__HP_aCC)
# define NODE_EDITOR_COMPILER "HP aC++"
# define NODE_EDITOR_COMPILER_HP
#elif \
defined (__WATCOMC__)
# define NODE_EDITOR_COMPILER "Watcom C++"
# define NODE_EDITOR_COMPILER_WATCOM
#if defined(__MINGW32__) || defined(__MINGW64__)
#define NODE_EDITOR_COMPILER "MinGW"
#define NODE_EDITOR_COMPILER_MINGW
#elif defined(__GNUC__)
#define NODE_EDITOR_COMPILER "GNU"
#define NODE_EDITOR_COMPILER_GNU
#define NODE_EDITOR_COMPILER_GNU_VERSION_MAJOR __GNUC__
#define NODE_EDITOR_COMPILER_GNU_VERSION_MINOR __GNUC_MINOR__
#define NODE_EDITOR_COMPILER_GNU_VERSION_PATCH __GNUC_PATCHLEVEL__
#elif defined(__clang__)
#define NODE_EDITOR_COMPILER "Clang"
#define NODE_EDITOR_COMPILER_CLANG
#elif defined(_MSC_VER)
#define NODE_EDITOR_COMPILER "Microsoft Visual C++"
#define NODE_EDITOR_COMPILER_MICROSOFT
#elif defined(__BORLANDC__)
#define NODE_EDITOR_COMPILER "Borland C++ Builder"
#define NODE_EDITOR_COMPILER_BORLAND
#elif defined(__CODEGEARC__)
#define NODE_EDITOR_COMPILER "CodeGear C++ Builder"
#define NODE_EDITOR_COMPILER_CODEGEAR
#elif defined(__INTEL_COMPILER) || defined(__ICL)
#define NODE_EDITOR_COMPILER "Intel C++"
#define NODE_EDITOR_COMPILER_INTEL
#elif defined(__xlC__) || defined(__IBMCPP__)
#define NODE_EDITOR_COMPILER "IBM XL C++"
#define NODE_EDITOR_COMPILER_IBM
#elif defined(__HP_aCC)
#define NODE_EDITOR_COMPILER "HP aC++"
#define NODE_EDITOR_COMPILER_HP
#elif defined(__WATCOMC__)
#define NODE_EDITOR_COMPILER "Watcom C++"
#define NODE_EDITOR_COMPILER_WATCOM
#endif

#ifndef NODE_EDITOR_COMPILER
# error "Current compiler is not supported."
#error "Current compiler is not supported."
#endif
86 changes: 27 additions & 59 deletions include/nodes/internal/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
#include <QtCore/QUuid>
#include <QtCore/QVariant>

#include "PortType.hpp"
#include "NodeData.hpp"
#include "PortType.hpp"

#include "Serializable.hpp"
#include "ConnectionState.hpp"
#include "ConnectionGeometry.hpp"
#include "TypeConverter.hpp"
#include "QUuidStdHash.hpp"
#include "ConnectionID.hpp"
#include "ConnectionState.hpp"
#include "Export.hpp"
#include "QUuidStdHash.hpp"
#include "Serializable.hpp"
#include "TypeConverter.hpp"
#include "memory.hpp"
#include "ConnectionID.hpp"

class QPointF;

namespace QtNodes
{
namespace QtNodes {

class Node;
class NodeData;
Expand All @@ -28,94 +27,63 @@ class ConnectionGraphicsObject;
/// Connection is a representation in DataFlowScene of a connection
/// It is part of the model, and not the rendering system.
/// This class is not to be used if you're implementing FlowScene model yourself
class NODE_EDITOR_PUBLIC Connection
: public QObject
, public Serializable
{
class NODE_EDITOR_PUBLIC Connection : public QObject, public Serializable {

Q_OBJECT

public:
Connection(Node &nodeIn, PortIndex portIndexIn, Node &nodeOut,
PortIndex portIndexOut, TypeConverter converter = TypeConverter{});

Connection(Node& nodeIn,
PortIndex portIndexIn,
Node& nodeOut,
PortIndex portIndexOut,
TypeConverter converter =
TypeConverter{});

Connection(const Connection&) = delete;
Connection
operator=(const Connection&) = delete;
Connection(const Connection &) = delete;
Connection operator=(const Connection &) = delete;

~Connection();

public:

QJsonObject
save() const override;
QJsonObject save() const override;

public:
ConnectionID id() const;

ConnectionID
id() const;

Node*
getNode(PortType portType) const;
Node *getNode(PortType portType) const;

private:

Node*&
getNodePtrRef(PortType portType);
Node *&getNodePtrRef(PortType portType);

public:
PortIndex getPortIndex(PortType portType) const;

PortIndex
getPortIndex(PortType portType) const;
NodeDataType dataType(PortType portType) const;

NodeDataType
dataType(PortType portType) const;

void
setTypeConverter(TypeConverter converter);
void setTypeConverter(TypeConverter converter);

public: // data propagation
void propagateData(std::shared_ptr<NodeData> nodeData) const;

void
propagateData(std::shared_ptr<NodeData> nodeData) const;

void
propagateEmptyData() const;
void propagateEmptyData() const;

private:

QUuid _uid;

private:
void setNodeToPort(Node &node, PortType portType, PortIndex portIndex);

void
setNodeToPort(Node& node,
PortType portType,
PortIndex portIndex);

Node* _outNode = nullptr;
Node* _inNode = nullptr;
Node *_outNode = nullptr;
Node *_inNode = nullptr;

PortIndex _outPortIndex;
PortIndex _inPortIndex;

private:

ConnectionState _connectionState;
ConnectionGeometry _connectionGeometry;

std::unique_ptr<ConnectionGraphicsObject>_connectionGraphicsObject;
std::unique_ptr<ConnectionGraphicsObject> _connectionGraphicsObject;

TypeConverter _converter;

signals:

void
updated(Connection& conn) const;
void updated(Connection &conn) const;
};
}
} // namespace QtNodes
49 changes: 22 additions & 27 deletions include/nodes/internal/ConnectionGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,49 @@

#include <iostream>

namespace QtNodes
{
namespace QtNodes {

class ConnectionGraphicsObject;

class ConnectionGeometry
{
public:

ConnectionGeometry();
friend ConnectionGraphicsObject;

public:
/**\brief this class change bounding rect of obj, so, it have to call
* prepareGeometrychange for do this safely
*/
explicit ConnectionGeometry(ConnectionGraphicsObject& obj);

QPointF const&
getEndPoint(PortType portType) const;
public:
QPointF const& getEndPoint(PortType portType) const;

void
setEndPoint(PortType portType, QPointF const& point);
void setEndPoint(PortType portType, QPointF const& point);

void
moveEndPoint(PortType portType, QPointF const &offset);
void moveEndPoint(PortType portType, QPointF const& offset);

QRectF
boundingRect() const;
QRectF boundingRect() const;

std::pair<QPointF, QPointF>
pointsC1C2() const;
std::pair<QPointF, QPointF> pointsC1C2() const;

QPointF
source() const { return _out; }
QPointF
sink() const { return _in; }
QPointF source() const { return _out; }
QPointF sink() const { return _in; }

double
lineWidth() const { return _lineWidth; }
double lineWidth() const { return _lineWidth; }

bool
hovered() const { return _hovered; }
void
setHovered(bool hovered) { _hovered = hovered; }
bool hovered() const { return _hovered; }
void setHovered(bool hovered) { _hovered = hovered; }

private:
// local object coordinates
ConnectionGraphicsObject& _obj;
QPointF _in;
QPointF _out;

//int _animationPhase;
// int _animationPhase;

double _lineWidth;

bool _hovered;
};
}
} // namespace QtNodes
Loading