|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef SCHEMATICNODE_H
|
|
Toshihiro Shimizu |
890ddd |
#define SCHEMATICNODE_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qgraphicsitem></qgraphicsitem>
|
|
Toshihiro Shimizu |
890ddd |
#include "schematicviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class SchematicPort;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// StageSchematicName.
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicName : public QGraphicsTextItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
double m_width;
|
|
Toshihiro Shimizu |
890ddd |
double m_height;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicName(QGraphicsItem *parent, double width, double height);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool eventFilter(QObject *object, QEvent *event);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setName(const QString &name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void focusInEvent(QFocusEvent *fe);
|
|
Toshihiro Shimizu |
890ddd |
void focusOutEvent(QFocusEvent *fe);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void keyPressEvent(QKeyEvent *ke);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void focusOut();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Toshihiro Shimizu |
890ddd |
void onContentsChanged();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//SchematicThumbnailToggle
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicThumbnailToggle : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
#ifndef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
Q_INTERFACES(QGraphicsItem)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_isDown;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicThumbnailToggle(SchematicNode *parent, bool isOpened);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicThumbnailToggle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRectF boundingRect() const;
|
|
Toshihiro Shimizu |
890ddd |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
void setIsDown(bool value);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void toggled(bool isOpened);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//SchematicToggle
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicToggle : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
#ifndef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
Q_INTERFACES(QGraphicsItem)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
QPixmap m_pixmap1, m_pixmap2;
|
|
Toshihiro Shimizu |
890ddd |
int m_state;
|
|
Toshihiro Shimizu |
890ddd |
int m_flags;
|
|
Toshihiro Shimizu |
890ddd |
int m_width, m_height;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
enum {
|
|
Toshihiro Shimizu |
890ddd |
eIsParentColumn = 0x01,
|
|
Toshihiro Shimizu |
890ddd |
eEnableNullState = 0x02
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicToggle(SchematicNode *parent, const QPixmap &pixmap, int flags, bool isLargeScaled = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! the schematic toggle can be a 3-state or a 2-state toggle!
|
|
Toshihiro Shimizu |
890ddd |
SchematicToggle(SchematicNode *parent, const QPixmap &pixmap1, const QPixmap &pixmap2, int flags, bool isLargeScaled = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~SchematicToggle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRectF boundingRect() const;
|
|
Toshihiro Shimizu |
890ddd |
//reimplemeted in SchematicToggle_SplineOptions
|
|
Toshihiro Shimizu |
890ddd |
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!this is used for a 2-state toggle;
|
|
Toshihiro Shimizu |
890ddd |
void setIsActive(bool value) { m_state = value ? 1 : 0; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!this is used for a 3-state toggle;
|
|
Toshihiro Shimizu |
890ddd |
void setState(int state) { m_state = state; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setSize(int width, int height)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_width = width;
|
|
Toshihiro Shimizu |
890ddd |
m_height = height;
|
|
Toshihiro Shimizu |
890ddd |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
//reimplemeted in SchematicToggle_SplineOptions
|
|
Toshihiro Shimizu |
890ddd |
virtual void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme);
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
//!this is triggered for a 2-state toggle;
|
|
Toshihiro Shimizu |
890ddd |
void toggled(bool isChecked);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!this is triggered for a 3-state toggle;
|
|
Toshihiro Shimizu |
890ddd |
void stateChanged(int state);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicToggle_SplineOptions : public SchematicToggle
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicToggle_SplineOptions(SchematicNode *parent,
|
|
Toshihiro Shimizu |
890ddd |
const QPixmap &pixmap,
|
|
Toshihiro Shimizu |
890ddd |
int flags)
|
|
Toshihiro Shimizu |
890ddd |
: SchematicToggle(parent, pixmap, flags) {}
|
|
Toshihiro Shimizu |
890ddd |
SchematicToggle_SplineOptions(SchematicNode *parent,
|
|
Toshihiro Shimizu |
890ddd |
const QPixmap &pixmap1,
|
|
Toshihiro Shimizu |
890ddd |
const QPixmap &pixmap2,
|
|
Toshihiro Shimizu |
890ddd |
int flags)
|
|
Toshihiro Shimizu |
890ddd |
: SchematicToggle(parent, pixmap1, pixmap2, flags) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//SchematicHandleSpinBox
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicHandleSpinBox : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
#ifndef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
Q_INTERFACES(QGraphicsItem)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
Qt::MouseButton m_buttonState;
|
|
Toshihiro Shimizu |
890ddd |
int m_delta;
|
|
Toshihiro Shimizu |
890ddd |
QPixmap m_pixmap;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicHandleSpinBox(QGraphicsItem *parent);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicHandleSpinBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRectF boundingRect() const;
|
|
Toshihiro Shimizu |
890ddd |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void modifyHandle(int);
|
|
Toshihiro Shimizu |
890ddd |
void changeStatus();
|
|
Toshihiro Shimizu |
890ddd |
void sceneChanged();
|
|
Toshihiro Shimizu |
890ddd |
void handleReleased();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mouseMoveEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void mouseReleaseEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//class SchematicLink
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief The class provides method to draw links between two SchematicPort
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
A link can has a cubic shape or a line shape and is drawing calling the updatePath() method. The class also provides
|
|
Toshihiro Shimizu |
890ddd |
methods to retrieve the start SchematicPort and the end SchematicPort of the link and a method to remove the
|
|
Toshihiro Shimizu |
890ddd |
link from these two SchematicPort.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\see SchematicPort, SchematicNode.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class SchematicLink : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *m_startPort, *m_endPort;
|
|
Toshihiro Shimizu |
890ddd |
QPainterPath m_path, m_hitPath;
|
|
Toshihiro Shimizu |
890ddd |
bool m_lineShaped;
|
|
Toshihiro Shimizu |
890ddd |
bool m_highlighted;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink(QGraphicsItem *parent, QGraphicsScene *scene);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicLink();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Reimplements the pure virtual QGraphicsItem::boundingRect() method.
|
|
Toshihiro Shimizu |
890ddd |
QRectF boundingRect() const;
|
|
Toshihiro Shimizu |
890ddd |
//!Reimplements the virtual QGraphicsItem::shape() method.
|
|
Toshihiro Shimizu |
890ddd |
QPainterPath shape() const;
|
|
Toshihiro Shimizu |
890ddd |
//!Reimplements the pure virtual QGraphicsItem::paint() method.
|
|
Toshihiro Shimizu |
890ddd |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Update the link path.\n
|
|
Toshihiro Shimizu |
890ddd |
The link is has a cubic shape starting from \b startPos and ending to \b endPos.
|
|
Toshihiro Shimizu |
890ddd |
If a link path already exists, the path is updating otherwise a path is created.*/
|
|
Toshihiro Shimizu |
890ddd |
void updatePath(const QPointF &startPos, const QPointF &endPos);
|
|
Toshihiro Shimizu |
890ddd |
//! Update the link path.\n
|
|
Toshihiro Shimizu |
890ddd |
//! Call the updatePath(const QPointF &startPos, const QPointF &endPos) method. The \b start pos and the \b endPos
|
|
Toshihiro Shimizu |
890ddd |
//! are taken from the the given \b startPort and \b endPort.
|
|
Toshihiro Shimizu |
890ddd |
void updatePath(SchematicPort *startPort, SchematicPort *endPort);
|
|
Toshihiro Shimizu |
890ddd |
void updatePath() { updatePath(m_startPort, m_endPort); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Sets the start SchematicPort of the link to \b startPort.
|
|
Toshihiro Shimizu |
890ddd |
void setStartPort(SchematicPort *startPort) { m_startPort = startPort; }
|
|
Toshihiro Shimizu |
890ddd |
//!Sets the start SchematicPort of the link to \b startPort.
|
|
Toshihiro Shimizu |
890ddd |
void setEndPort(SchematicPort *endPort) { m_endPort = endPort; }
|
|
Toshihiro Shimizu |
890ddd |
//!Returns the start SchematicPort of the link.
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *getStartPort() const { return m_startPort; }
|
|
Toshihiro Shimizu |
890ddd |
//!Returns the end SchematicPort of the link.
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *getEndPort() const { return m_endPort; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Returns the other SchematicPort linked to the specified \b port.\n
|
|
Toshihiro Shimizu |
890ddd |
Returns 0 if \b port isn't neither the start SchematicPort eihter the end SchematicPort of this link.*/
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *getOtherPort(const SchematicPort *port) const;
|
|
Toshihiro Shimizu |
890ddd |
/*! Returns the other SchematicNode linked to the specified \b node.\n
|
|
Toshihiro Shimizu |
890ddd |
Returns 0 if \b node isn't neither the parent node of the start SchematicPort
|
|
Toshihiro Shimizu |
890ddd |
eihter the parent node of the end SchematicPort of the link.*/
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *getOtherNode(const SchematicNode *node) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns true if the link is line shaped.
|
|
Toshihiro Shimizu |
890ddd |
bool isLineShaped() { return m_lineShaped; }
|
|
Toshihiro Shimizu |
890ddd |
void setLineShaped(bool value) { m_lineShaped = value; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isHighlighted() { return m_highlighted; }
|
|
Toshihiro Shimizu |
890ddd |
void setHighlighted(bool value) { m_highlighted = value; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void mouseReleaseEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//class SchematicPort
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief The class provides method to draw and andle a SchematicPort.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
A SchematicPort is a child af a SchematicNode and is used to link a parent node to other nodes. It can be an input port,
|
|
Toshihiro Shimizu |
890ddd |
or better , a port used to accept link coming from other node. A port that isn't an input port cannot accept
|
|
Toshihiro Shimizu |
890ddd |
links but can begin to draw links.\n
|
|
Toshihiro Shimizu |
890ddd |
A SchematicPort has got a hook thet is a position where links starts or ends.\n
|
|
Toshihiro Shimizu |
890ddd |
A SchematicPort can be linked to an arbitriary number of links.
|
|
Toshihiro Shimizu |
890ddd |
A SchematicPort handles a container of all links to retrieve all linked node; each link is indexed using a
|
|
Toshihiro Shimizu |
890ddd |
progressive number assigned when the link is inserted to the container.
|
|
Toshihiro Shimizu |
890ddd |
\see SchematicNode, SchematicLink.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class SchematicPort : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
#ifndef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
Q_INTERFACES(QGraphicsItem)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
Qt::MouseButton m_buttonState;
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *m_node;
|
|
Toshihiro Shimizu |
890ddd |
QPointF m_hook;
|
|
Toshihiro Shimizu |
890ddd |
bool m_highlighted;
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *m_ghostLink;
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *m_linkingTo;
|
|
Toshihiro Shimizu |
890ddd |
QList<schematiclink *=""> m_links;</schematiclink>
|
|
Toshihiro Shimizu |
890ddd |
int m_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort(QGraphicsItem *parent, SchematicNode *node, int type);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicPort();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *getNode() const { return m_node; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual QRectF boundingRect() const { return QRectF(0, 0, 1, 1); };
|
|
Toshihiro Shimizu |
890ddd |
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Add the \b link to the links container.
|
|
Toshihiro Shimizu |
890ddd |
void addLink(SchematicLink *link) { m_links.push_back(link); }
|
|
Toshihiro Shimizu |
890ddd |
//!Returns the number of the link contained in the links container or, it is the same, the number of nodes
|
|
Toshihiro Shimizu |
890ddd |
//!linked to this SchematicPort
|
|
Toshihiro Shimizu |
890ddd |
int getLinkCount() const { return m_links.size(); }
|
|
Toshihiro Shimizu |
890ddd |
//!Removes the link form the links container.\n
|
|
Toshihiro Shimizu |
890ddd |
//!It doesn't remove the link from the scene and it doesn't delete the link!
|
|
Toshihiro Shimizu |
890ddd |
void removeLink(SchematicLink *link);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Removes \b link from the scene and the m_links list; delete it .
|
|
Toshihiro Shimizu |
890ddd |
void eraseLink(SchematicLink *link);
|
|
Toshihiro Shimizu |
890ddd |
//! Removes all links from the scene and the m_links list; delete them .
|
|
Toshihiro Shimizu |
890ddd |
void eraseAllLinks();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Returns the link indexed with \b index.\n
|
|
Toshihiro Shimizu |
890ddd |
//!\note A link is indexed with a progressive number when is inserted in the container.
|
|
Toshihiro Shimizu |
890ddd |
SchematicLink *getLink(int index) const { return (index < m_links.size() && index >= 0) ? m_links[index] : 0; }
|
|
Toshihiro Shimizu |
890ddd |
//!Returns the node linked with the link \b index.
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode *getLinkedNode(int index) const { return m_links[index] ? m_links[index]->getOtherNode(m_node) : 0; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Make a link from this port to the given port.
|
|
Toshihiro Shimizu |
890ddd |
virtual SchematicLink *makeLink(SchematicPort *port);
|
|
Toshihiro Shimizu |
890ddd |
//! Check and make a connection between the data Objects.
|
|
Toshihiro Shimizu |
890ddd |
//! Returns true if it is possible to have a connection between the data Object represented by this SchematicPort
|
|
Toshihiro Shimizu |
890ddd |
//! and that represented by \b port. If check only is false no connections is created!
|
|
Toshihiro Shimizu |
890ddd |
//! \see TFxPort, TStageObject.
|
|
Toshihiro Shimizu |
890ddd |
virtual bool linkTo(SchematicPort *port, bool checkOnly = false) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// !Return the hook poeistion of the port.
|
|
Toshihiro Shimizu |
890ddd |
QPointF getHook() const { return m_hook; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns true if this SchematicPort is linked to \b port. Otherwise returns false.
|
|
Toshihiro Shimizu |
890ddd |
bool isLinkedTo(SchematicPort *port) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void highLight(bool value) { m_highlighted = value; }
|
|
Toshihiro Shimizu |
890ddd |
bool isHighlighted() const { return m_highlighted; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Updates all links of the ports.
|
|
Toshihiro Shimizu |
890ddd |
void updateLinksGeometry();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns the scene position of the link end
|
|
Toshihiro Shimizu |
890ddd |
QPointF getLinkEndPoint() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns the type of the port. \see eFxSchematicPortType, eStageSchematicPortType
|
|
Toshihiro Shimizu |
890ddd |
int getType() const { return m_type; }
|
|
Toshihiro Shimizu |
890ddd |
//! Set the type of the port.
|
|
Toshihiro Shimizu |
890ddd |
void setType(int type) { m_type = type; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mouseMoveEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
void mouseReleaseEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
virtual SchematicPort *searchPort(const QPointF &scenePos) = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual void hideSnappedLinks() = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual void showSnappedLinks() = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void isClicked();
|
|
Toshihiro Shimizu |
890ddd |
void isReleased(const QPointF &);
|
|
Toshihiro Shimizu |
890ddd |
void sceneChanged();
|
|
Toshihiro Shimizu |
890ddd |
void xsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//class SchematicNode
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SchematicNode : public QObject, public QGraphicsItem
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
#ifndef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
Q_INTERFACES(QGraphicsItem)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
SchematicScene *m_scene;
|
|
Toshihiro Shimizu |
890ddd |
qreal m_width, m_height;
|
|
Toshihiro Shimizu |
890ddd |
Qt::MouseButton m_buttonState;
|
|
Toshihiro Shimizu |
890ddd |
QMap<int, *="" schematicport=""> m_ports;</int,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
SchematicNode(SchematicScene *scene);
|
|
Toshihiro Shimizu |
890ddd |
~SchematicNode();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRectF boundingRect() const;
|
|
Toshihiro Shimizu |
890ddd |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *addPort(int portId, SchematicPort *port);
|
|
Toshihiro Shimizu |
890ddd |
void erasePort(int portId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SchematicPort *getPort(int portId) const;
|
|
Toshihiro Shimizu |
890ddd |
QList<schematicnode *=""> getLinkedNodes(int portId) const;</schematicnode>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void setSchematicNodePos(const QPointF &pos) const = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual void setPosition(const QPointF &newPos) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateLinksGeometry();
|
|
Toshihiro Shimizu |
890ddd |
virtual void onClicked(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
virtual void mousePressEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *me);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void sceneChanged();
|
|
Toshihiro Shimizu |
890ddd |
void xsheetChanged();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //SCHEMATICNODE_H
|