Mod/Part/Gui/ViewProvider.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef PARTGUI_VIEWPROVIDERPART_H
00025 #define PARTGUI_VIEWPROVIDERPART_H
00026 
00027 #include <Standard_math.hxx>
00028 #include <Standard_Boolean.hxx>
00029 #include <TopoDS_Shape.hxx>
00030 #include <Gui/ViewProviderGeometryObject.h>
00031 #include <Gui/ViewProviderBuilder.h>
00032 #include <Mod/Part/Gui/ViewProviderExt.h>
00033 #include <map>
00034 
00035 class TopoDS_Shape;
00036 class TopoDS_Edge;
00037 class TopoDS_Wire;
00038 class TopoDS_Face;
00039 class SoSeparator;
00040 class SoGroup;
00041 class SoSwitch;
00042 class SoVertexShape;
00043 class SoPickedPoint;
00044 class SoShapeHints;
00045 class SoEventCallback;
00046 class SbVec3f;
00047 class SoSphere;
00048 class SoScale;
00049 
00050 // Set this to use the fast rendering of shapes
00051 #define FC_USE_FAST_SHAPE_RENDERING
00052 
00053 namespace PartGui {
00054 
00055 class ViewProviderShapeBuilder : public Gui::ViewProviderBuilder
00056 {
00057 public:
00058     ViewProviderShapeBuilder(){}
00059     ~ViewProviderShapeBuilder(){}
00060     virtual void buildNodes(const App::Property*, std::vector<SoNode*>&) const;
00061     void createShape(const App::Property*, SoSeparator*) const;
00062 };
00063 
00064 class PartGuiExport ViewProviderPartBase : public Gui::ViewProviderGeometryObject
00065 {
00066     PROPERTY_HEADER(PartGui::ViewProviderPartBase);
00067 
00068 public:
00070     ViewProviderPartBase();
00072     virtual ~ViewProviderPartBase();
00073 
00074     // Display properties
00075     App::PropertyFloatConstraint LineWidth;
00076     App::PropertyFloatConstraint PointSize;
00077     App::PropertyColor LineColor;
00078     App::PropertyColor PointColor;
00079     App::PropertyMaterial LineMaterial;
00080     App::PropertyMaterial PointMaterial;
00081     App::PropertyBool ControlPoints;
00082     App::PropertyEnumeration Lighting;
00083 
00084 
00085     virtual void attach(App::DocumentObject *);
00086     virtual void setDisplayMode(const char* ModeName);
00088     virtual std::vector<std::string> getDisplayModes(void) const;
00090     void reload();
00091 
00092     virtual void updateData(const App::Property*);
00093     TopoDS_Shape getShape(const SoPickedPoint*) const;
00094     static void shapeInfoCallback(void * ud, SoEventCallback * n);
00095 
00096 protected:
00098     virtual void onChanged(const App::Property* prop);
00099     bool loadParameter();
00100     Standard_Boolean computeFaces   (SoGroup* root, const TopoDS_Shape &myShape, double defl);
00101     Standard_Boolean computeEdges   (SoGroup* root, const TopoDS_Shape &myShape);
00102     Standard_Boolean computeVertices(SoGroup* root, const TopoDS_Shape &myShape);
00103 
00104     void transferToArray(const TopoDS_Face& aFace,SbVec3f** vertices,SbVec3f** vertexnormals,
00105          int32_t** cons,int &nbNodesInFace,int &nbTriInFace );
00106     void showControlPoints(bool, const App::Property* prop);
00107     void showControlPointsOfEdge(const TopoDS_Edge&);
00108     void showControlPointsOfWire(const TopoDS_Wire&);
00109     void showControlPointsOfFace(const TopoDS_Face&);
00110 
00111     // nodes for the data representation
00112     SoGroup  *EdgeRoot;
00113     SoGroup  *FaceRoot;
00114     SoGroup  *VertexRoot;
00115     SoMaterial   *pcLineMaterial;
00116     SoMaterial   *pcPointMaterial;
00117     SoDrawStyle  *pcLineStyle;
00118     SoDrawStyle  *pcPointStyle;
00119     SoSwitch     *pcControlPoints;
00120     SoShapeHints *pShapeHints;
00121 
00122 private:
00123     // settings stuff
00124     float meshDeviation;
00125     bool noPerVertexNormals;
00126     bool qualityNormals;
00127     static App::PropertyFloatConstraint::Constraints floatRange;
00128     static const char* LightingEnums[];
00129     std::map<SoVertexShape*, TopoDS_Shape> vertexShapeMap;
00130 };
00131 
00132 class PartGuiExport ViewProviderEllipsoid : public ViewProviderPartBase
00133 {
00134     PROPERTY_HEADER(PartGui::ViewProviderEllipsoid);
00135 
00136 public:
00138     ViewProviderEllipsoid();
00140     virtual ~ViewProviderEllipsoid();
00141 
00142     void updateData(const App::Property*);
00143 
00144 private:
00145     SoSphere* pSphere;
00146     SoScale * pScaling;
00147 };
00148 
00149 #if defined(FC_USE_FAST_SHAPE_RENDERING)
00150 class PartGuiExport ViewProviderPart : public ViewProviderPartExt
00151 {
00152     PROPERTY_HEADER(PartGui::ViewProviderPart);
00153 
00154 public:
00156     ViewProviderPart();
00158     virtual ~ViewProviderPart();
00159 };
00160 #else
00161 class PartGuiExport ViewProviderPart : public ViewProviderPartBase
00162 {
00163     PROPERTY_HEADER(PartGui::ViewProviderPart);
00164 
00165 public:
00167     ViewProviderPart();
00169     virtual ~ViewProviderPart();
00170 };
00171 #endif
00172 
00173 } // namespace PartGui
00174 
00175 
00176 #endif // PARTGUI_VIEWPROVIDERPART_H
00177 

Generated on Wed Nov 23 19:00:58 2011 for FreeCAD by  doxygen 1.6.1