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