Debian Codegraph @

src/Gui/ViewProviderGeometryObject.h

raw
1 /***************************************************************************
2 * Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef GUI_VIEWPROVIDER_GEOMETRYOBJECT_H
25 #define GUI_VIEWPROVIDER_GEOMETRYOBJECT_H
26
27 #include "ViewProviderDragger.h"
28 #include <Inventor/lists/SoPickedPointList.h>
29
30 class SoPickedPointList;
31 class SoPickStyle;
32 class SoSwitch;
33 class SoSensor;
34 class SbVec2s;
35 class SoBaseColor;
36
37 namespace Gui
38 {
39
40 class SoFCSelection;
41 class SoFCBoundingBox;
42 class View3DInventorViewer;
43
44 /**
45 * The base class for all view providers that display geometric data, like mesh, point clouds and
46 * shapes.
47 * @author Werner Mayer
48 */
49 class GuiExport ViewProviderGeometryObject: public ViewProviderDragger
50 {
51 PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderGeometryObject);
52
53 public:
54 /// constructor.
55 ViewProviderGeometryObject();
56
57 /// destructor.
58 ~ViewProviderGeometryObject() override;
59
60 // Display properties
61 App::PropertyPercent Transparency;
62 App::PropertyMaterialList ShapeAppearance; // May be different from material
63 App::PropertyBool BoundingBox;
64 App::PropertyBool Selectable;
65
66 /**
67 * Attaches the document object to this view provider.
68 */
69 void attach(App::DocumentObject* pcObject) override;
70 void updateData(const App::Property*) override;
71
72 bool isSelectable() const override
73 {
74 return Selectable.getValue();
75 }
76
77 /**
78 * Returns a list of picked points from the geometry under \a getRoot().
79 * If \a pickAll is false (the default) only the intersection point closest to the camera will
80 * be picked, otherwise all intersection points will be picked.
81 */
82 SoPickedPointList getPickedPoints(
83 const SbVec2s& pos,
84 const View3DInventorViewer& viewer,
85 bool pickAll = false
86 ) const;
87 /**
88 * This method is provided for convenience and does basically the same as getPickedPoints()
89 * unless that only the closest point to the camera will be picked. \note It is in the response
90 * of the client programmer to delete the returned SoPickedPoint object.
91 */
92 SoPickedPoint* getPickedPoint(const SbVec2s& pos, const View3DInventorViewer& viewer) const;
93
94 /** @name Edit methods */
95 //@{
96 virtual void showBoundingBox(bool);
97 //@}
98
99 /// Get the python wrapper for that ViewProvider
100 PyObject* getPyObject() override;
101
102 protected:
103 /// get called by the container whenever a property has been changed
104 void onChanged(const App::Property* prop) override;
105 void setSelectable(bool Selectable = true);
106
107 virtual unsigned long getBoundColor() const;
108
109 void handleChangedPropertyName(
110 Base::XMLReader& reader,
111 const char* TypeName,
112 const char* PropName
113 ) override;
114 void setCoinAppearance(const App::Material& source);
115
116 private:
117 bool isSelectionEnabled() const;
118
119 protected:
120 SoMaterial* pcShapeMaterial {nullptr};
121 SoFCBoundingBox* pcBoundingBox {nullptr};
122 SoSwitch* pcBoundSwitch {nullptr};
123 SoBaseColor* pcBoundColor {nullptr};
124 SoPickStyle* pickStyle {nullptr};
125
126 App::Material materialAppearance;
127 };
128
129 } // namespace Gui
130
131
132 #endif // GUI_VIEWPROVIDER_GEOMETRYOBJECT_H