examples/qvdesigner0.2/slate/slatewindow.h

00001 /*
00002  *      Copyright (C) 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef SLATEWINDOW_H
00022 #define SLATEWINDOW_H
00023 
00024 #include <QMainWindow>
00025 #include <QCloseEvent>
00026 #include <QPair>
00027 #include <QAction>
00028 
00029 
00030 class QGraphicsItem;
00031 class QGraphicsScene;
00032 class QGraphicsView;
00033 class Link;
00034 class Node;
00035 class ItemNode;
00036 class ItemProperties;
00037 class SlateView;
00038 class DesignerGUI;
00039 
00040 #ifndef DOXYGEN_IGNORE_THIS
00041 
00042 // usar QGraphicsItem::collidesWithItem() para meter automátcamente un item dentro de un grupo (debería estar en node)
00043 class SlateWindow : public QMainWindow
00044 {
00045     Q_OBJECT
00046 
00047 public:
00048     SlateWindow(DesignerGUI *desig, QWidget * parent = 0);
00049         bool createLink(Node *fromNode, int fromPoint, Node *toNode, int toPoint);
00050         void addLinkLine(QString fromNode, QString fromProp, QString toNode, QString toProp, bool sinc);
00051         void delLinkLine(QString fromNode, QString fromProp, QString toNode, QString toProp);
00052         void addItemNode(QString type, QString name, ItemProperties *item);
00053         void delItemNode(QString name);
00054         void addProperty(QString srcName, QString propName, int type, bool in, bool out);
00055         void delProperty(QString srcName, QString propName);
00056         void closeEvent(QCloseEvent *event);
00057 
00058 public slots:
00059     void showProperties();
00060         void showProperties(Node *node);
00061 
00062 private slots:
00063     void del();
00064         void join();
00065     void bringToFront();
00066     void sendToBack();
00067     void updateActions();
00068         void insertItem(QString type);
00069         void run();
00070         void stop();
00071 
00072 signals:
00074         void closed();
00075 
00076 private:
00077     typedef QPair<Node *, Node *> NodePair;
00078 
00079     QPoint startPos;
00080 
00081     void createMenus();
00082     void createToolBars();
00083     void setZValue(int z);
00084     void setupNode(Node *node);
00085     Node *selectedNode() const;
00086     Link *selectedLink() const;
00087     NodePair selectedNodePair() const;
00088     QList<QGraphicsItem *> selectedNodeGroup() const;
00089         QList<QGraphicsItem *> onlyParents(QList<QGraphicsItem *> items) const;
00090 
00091     QMenu *fileMenu;
00092     QMenu *editMenu;
00093         QMenu *insertMenu;
00094     QToolBar *editToolBar;
00095     QAction *exitAction;
00096     QAction *addSLinkAction;
00097     QAction *addALinkAction;
00098         QActionGroup *linkGroup;
00099     QAction *joinAction;
00100     QAction *deleteAction;
00101     QAction *bringToFrontAction;
00102     QAction *sendToBackAction;
00103     QAction *propertiesAction;
00104         QAction *runAction;
00105         QAction *stopAction;
00106 
00107     QGraphicsScene *scene;
00108     SlateView *view;
00109         DesignerGUI *designer;
00110 
00111     int minZ;
00112     int maxZ;
00113     int seqNumber;
00114 
00115         QMap<QString, ItemNode *> insertNodes;
00116         QMap<QString, QPointF> insertNodesPos;
00117         QMap<QString, Link *> insertLinks;
00118 };
00119 
00120 #endif
00121 #endif