![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef MOUSEEDGEBENDEDITION_H 00022 #define MOUSEEDGEBENDEDITION_H 00023 00024 #include <tulip/GlCircle.h> 00025 #include <tulip/GlTriangle.h> 00026 #include <tulip/GLInteractor.h> 00027 #include <tulip/GlScene.h> 00028 #include <tulip/GlLines.h> 00029 00030 namespace tlp { 00031 00032 class LayoutProperty; 00033 class BooleanProperty; 00034 class SizeProperty; 00035 class DoubleProperty; 00036 class CoordVectorProperty; 00037 class IntegerProperty; 00038 00039 class EdgeEntity : public GlSimpleEntity { 00040 00041 Coord start; 00042 Coord end; 00043 std::vector<Coord> bends; 00044 00045 public : 00046 00047 void setCoordinates(const Coord &startPos, const Coord &endPos,const std::vector<Coord> &bendsPos) { 00048 boundingBox = BoundingBox(); 00049 start=startPos; 00050 end=endPos; 00051 bends=bendsPos; 00052 boundingBox.expand(start); 00053 boundingBox.expand(end); 00054 00055 for(std::vector<Coord>::iterator it=bends.begin(); it!=bends.end(); ++it) { 00056 boundingBox.expand(*it); 00057 } 00058 } 00059 00060 void draw(float,Camera *) { 00061 GlLines::glDrawCurve(start,bends,end,10,0,Color(127,127,127,255),Color(127,127,127,255)); 00062 } 00063 00064 void getXML(std::string &) {} 00065 void setWithXML(const std::string &, unsigned int &) {} 00066 }; 00067 00068 /// This interactor allows to move/add/delete EdgeBends 00069 class TLP_QT_SCOPE MouseEdgeBendEditor:public GLInteractorComponent { 00070 00071 public: 00072 00073 MouseEdgeBendEditor(); 00074 ~MouseEdgeBendEditor(); 00075 bool compute(GlMainWidget *glMainWidget); 00076 bool draw(GlMainWidget *); 00077 void clear(); 00078 bool eventFilter(QObject *, QEvent *); 00079 00080 protected: 00081 enum EditOperation { NONE_OP=0, TRANSLATE_OP, NEW_OP, DELETE_OP}; 00082 00083 EditOperation operation()const { 00084 return _operation; 00085 } 00086 00087 tlp::edge getEdge()const { 00088 return mEdge; 00089 } 00090 00091 void stopEdition(); 00092 00093 private: 00094 00095 enum OperationTarget { COORD = 0, SIZE, COORD_AND_SIZE}; 00096 00097 Graph *_graph; 00098 GlMainWidget* glMainWidget; 00099 LayoutProperty *_layout; 00100 BooleanProperty *_selection; 00101 DoubleProperty *_rotation; 00102 SizeProperty *_sizes; 00103 IntegerProperty *_shape; 00104 CoordVectorProperty *_coordsVectorProperty; 00105 00106 void initProxies(GlMainWidget *glMainWidget); 00107 00108 00109 EditOperation _operation; 00110 OperationTarget mode; 00111 00112 Coord editPosition; 00113 00114 GlLayer *layer; 00115 std::vector<tlp::GlCircle> circles; 00116 EdgeEntity *edgeEntity; 00117 std::vector<Coord> coordinates; 00118 GlCircle basicCircle; 00119 GlTriangle targetTriangle; 00120 GlCircle sourceCircle; 00121 GlComposite *circleString; 00122 std::vector <SelectedEntity> select; 00123 bool edgeSelected; 00124 tlp::edge mEdge; 00125 node mNode; 00126 Coord start, end; 00127 std::string selectedEntity; 00128 bool mouseButtonPressOnEdge; 00129 bool belong(Coord, Coord, Coord, GlMainWidget*); 00130 bool haveSelection(GlMainWidget *); 00131 void computeSrcTgtEntities(GlMainWidget *); 00132 bool computeBendsCircles(GlMainWidget*); 00133 void mMouseTranslate(double, double, GlMainWidget*); 00134 void mMouseDelete(); 00135 void mMouseCreate(double, double, GlMainWidget*); 00136 }; 00137 00138 } 00139 00140 00141 #endif 00142 ///@endcond