PARP Research Group University of Murcia, Spain


src/qvgui/qvdesigner/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 QVDesignerGUI;
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(QVDesignerGUI *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, bool sequential);
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         void includeItemType(QString itemType);
00058         void arrangeItems();
00059 
00060 public slots:
00061     void showProperties();
00062         void showProperties(Node *node);
00063         void showMessage(QString message);
00064 
00065 private slots:
00066     void del();
00067         void join();
00068     void bringToFront();
00069     void sendToBack();
00070     void updateActions();
00071         void insertItem(QString type);
00072         void run();
00073         void stop();
00074         bool saveAs();
00075 
00076 signals:
00078         void closed();
00079 
00080 private:
00081     typedef QPair<Node *, Node *> NodePair;
00082 
00083     QPoint startPos;
00084 
00085     void createMenus();
00086     void createToolBars();
00087     void setZValue(int z);
00088     void setupNode(Node *node);
00089     Node *selectedNode() const;
00090     Link *selectedLink() const;
00091     NodePair selectedNodePair() const;
00092     QList<QGraphicsItem *> selectedNodeGroup() const;
00093         QList<QGraphicsItem *> onlyParents(QList<QGraphicsItem *> items) const;
00094     bool saveFile(const QString &fileName);
00095         bool writeCppFile(const QString &fileName);
00096         int precursors(ItemNode *node);
00097 
00098     QMenu *fileMenu;
00099     QMenu *editMenu;
00100         QMenu *insertMenu;
00101     QToolBar *editToolBar;
00102     QAction *exitAction;
00103     QAction *addSLinkAction;
00104     QAction *addALinkAction;
00105     QAction *addQLinkAction;
00106         QActionGroup *linkGroup;
00107     QAction *joinAction;
00108     QAction *deleteAction;
00109     QAction *bringToFrontAction;
00110     QAction *sendToBackAction;
00111     QAction *propertiesAction;
00112         QAction *runAction;
00113         QAction *stopAction;
00114         QAction *saveAsAction;
00115 
00116         QStatusBar *statusbar;
00117 
00118     QGraphicsScene *scene;
00119     SlateView *view;
00120         QVDesignerGUI *designer;
00121 
00122     int minZ;
00123     int maxZ;
00124     int seqNumber;
00125 
00126         QMap<QString, ItemNode *> insertNodes;
00127         QMap<QString, QPointF> insertNodesPos;
00128         QMap<QString, Link *> insertLinks;
00129 };
00130 
00131 #endif
00132 #endif



QVision framework. PARP research group, copyright 2007, 2008.