Mod/Mesh/Gui/ViewProvider.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MESHGUI_VIEWPROVIDERMESH_H
00024 #define MESHGUI_VIEWPROVIDERMESH_H
00025
00026 #include <vector>
00027 #include <Inventor/fields/SoSFVec2f.h>
00028
00029 #include <Mod/Mesh/App/Core/Elements.h>
00030 #include <Gui/ViewProviderGeometryObject.h>
00031 #include <Gui/ViewProviderBuilder.h>
00032 #include <App/PropertyStandard.h>
00033
00034
00035 class SoSeparator;
00036 class SoEventCallback;
00037 class SbViewVolume;
00038 class SoBaseColor;
00039 class SoShape;
00040 class SoCoordinate3;
00041 class SoIndexedFaceSet;
00042 class SoShapeHints;
00043 class SoMaterialBinding;
00044 class SoCamera;
00045 class SoAction;
00046 class SbViewportRegion;
00047 class SbVec2f;
00048 class SbBox2s;
00049 class SbPlane;
00050
00051 namespace App {
00052 class Color;
00053 }
00054
00055 namespace Gui {
00056 class View3DInventorViewer;
00057 class SoFCSelection;
00058 }
00059
00060
00061 namespace MeshCore {
00062 class MeshKernel;
00063 }
00064
00065
00066 namespace MeshGui {
00067 class SoFCMeshObjectNode;
00068 class SoFCMeshObjectShape;
00069
00070 class MeshGuiExport ViewProviderMeshBuilder : public Gui::ViewProviderBuilder
00071 {
00072 public:
00073 ViewProviderMeshBuilder(){}
00074 ~ViewProviderMeshBuilder(){}
00075 virtual void buildNodes(const App::Property*, std::vector<SoNode*>&) const;
00076 void createMesh(const App::Property*, SoCoordinate3*, SoIndexedFaceSet*) const;
00077 };
00078
00083 class MeshGuiExport ViewProviderExport : public Gui::ViewProviderDocumentObject
00084 {
00085 PROPERTY_HEADER(MeshGui::ViewProviderExport);
00086
00087 public:
00088 ViewProviderExport();
00089 virtual ~ViewProviderExport();
00090
00091 virtual QIcon getIcon() const;
00092 SoSeparator* getRoot(void){return 0;}
00093 std::vector<std::string> getDisplayModes(void) const;
00094 const char* getDefaultDisplayMode() const;
00095 };
00096
00102 class MeshGuiExport ViewProviderMesh : public Gui::ViewProviderGeometryObject
00103 {
00104 PROPERTY_HEADER(MeshGui::ViewProviderMesh);
00105
00106 public:
00107 ViewProviderMesh();
00108 virtual ~ViewProviderMesh();
00109
00110
00111 App::PropertyPercent LineTransparency;
00112 App::PropertyFloatConstraint LineWidth;
00113 App::PropertyFloatConstraint PointSize;
00114 App::PropertyFloatConstraint CreaseAngle;
00115 App::PropertyBool OpenEdges;
00116 App::PropertyEnumeration Lighting;
00117 App::PropertyColor LineColor;
00118
00119 virtual void attach(App::DocumentObject *);
00120 virtual QIcon getIcon() const;
00122 virtual void setDisplayMode(const char* ModeName);
00124 virtual std::vector<std::string> getDisplayModes(void) const;
00125
00128 bool doubleClicked(void){ return false; }
00129 void selectComponent(unsigned long facet);
00130 void deselectComponent(unsigned long facet);
00131 void selectFacet(unsigned long facet);
00132 void deselectFacet(unsigned long facet);
00133 void setSelection(const std::vector<unsigned long>&);
00134 void addSelection(const std::vector<unsigned long>&);
00135 void removeSelection(const std::vector<unsigned long>&);
00136 void clearSelection();
00137 void deleteSelection();
00138 void getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
00139 Gui::View3DInventorViewer &Viewer, SbBool inner,
00140 std::vector<unsigned long>& indices) const;
00141 std::vector<unsigned long> getFacetsOfRegion(const SbViewportRegion&, const SbViewportRegion&, SoCamera*) const;
00142 std::vector<unsigned long> getVisibleFacetsAfterZoom(const SbBox2s&, const SbViewportRegion&, SoCamera*) const;
00143 std::vector<unsigned long> getVisibleFacets(const SbViewportRegion&, SoCamera*) const;
00145
00146 protected:
00148 bool setEdit(int ModNum);
00150 void unsetEdit(int ModNum);
00152 void onChanged(const App::Property* prop);
00153 virtual void showOpenEdges(bool);
00154 void setOpenEdgeColorFrom(const App::Color& col);
00155 virtual void cutMesh(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer, SbBool inner);
00156 virtual void splitMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner);
00157 virtual void segmentMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner);
00158 virtual void faceInfo(unsigned long facet);
00159 virtual void fillHole(unsigned long facet);
00160 virtual void selectArea(short, short, short, short, const SbViewportRegion&, SoCamera*);
00161 void highlightSelection();
00162 void unhighlightSelection();
00163
00164 virtual SoShape* getShapeNode() const;
00165 virtual SoNode* getCoordNode() const;
00166
00167 public:
00168 static void faceInfoCallback(void * ud, SoEventCallback * n);
00169 static void fillHoleCallback(void * ud, SoEventCallback * n);
00170 static void markPartCallback(void * ud, SoEventCallback * n);
00171 static void clipMeshCallback(void * ud, SoEventCallback * n);
00172 static void partMeshCallback(void * ud, SoEventCallback * n);
00173 static void segmMeshCallback(void * ud, SoEventCallback * n);
00174 static void selectGLCallback(void * ud, SoEventCallback * n);
00176 static bool createToolMesh(const std::vector<SbVec2f>& rclPoly, const SbViewVolume& vol,
00177 const Base::Vector3f& rcNormal, std::vector<MeshCore::MeshGeomFacet>&);
00178
00179 private:
00180 static void renderGLCallback(void * ud, SoAction * a);
00181 static void boxZoom(const SbBox2s& box, const SbViewportRegion & vp, SoCamera* cam);
00182 static void panCamera(SoCamera*, float, const SbPlane&, const SbVec2f&, const SbVec2f&);
00183
00184 protected:
00185 SoDrawStyle * pcLineStyle;
00186 SoDrawStyle * pcPointStyle;
00187 SoSeparator * pcOpenEdge;
00188 SoBaseColor * pOpenColor;
00189 SoMaterial * pLineColor;
00190 SoShapeHints * pShapeHints;
00191 SoMaterialBinding * pcMatBinding;
00192
00193 private:
00194 static App::PropertyFloatConstraint::Constraints floatRange;
00195 static App::PropertyFloatConstraint::Constraints angleRange;
00196 static App::PropertyIntegerConstraint::Constraints intPercent;
00197 static const char* LightingEnums[];
00198 };
00199
00205 class MeshGuiExport ViewProviderIndexedFaceSet : public ViewProviderMesh
00206 {
00207 PROPERTY_HEADER(MeshGui::ViewProviderIndexedFaceSet);
00208
00209 public:
00210 ViewProviderIndexedFaceSet();
00211 virtual ~ViewProviderIndexedFaceSet();
00212
00213 virtual void attach(App::DocumentObject *);
00215 virtual void updateData(const App::Property*);
00216
00217 protected:
00218 void showOpenEdges(bool);
00219 SoShape* getShapeNode() const;
00220 SoNode* getCoordNode() const;
00221
00222 private:
00223 SoCoordinate3 * pcMeshCoord;
00224 SoIndexedFaceSet * pcMeshFaces;
00225 };
00226
00232 class MeshGuiExport ViewProviderMeshObject : public ViewProviderMesh
00233 {
00234 PROPERTY_HEADER(MeshGui::ViewProviderMeshObject);
00235
00236 public:
00237 ViewProviderMeshObject();
00238 virtual ~ViewProviderMeshObject();
00239
00240 void attach(App::DocumentObject *pcFeat);
00241 virtual void updateData(const App::Property*);
00242
00243 protected:
00244 SoShape* getShapeNode() const;
00245 SoNode* getCoordNode() const;
00246 void showOpenEdges(bool);
00247
00248 private:
00249 SoFCMeshObjectNode * pcMeshNode;
00250 SoFCMeshObjectShape * pcMeshShape;
00251 };
00252
00253 }
00254
00255
00256 #endif // MESHGUI_VIEWPROVIDERMESH_H
00257