-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
ViewProviderDocumentObject.h
155 lines (129 loc) · 6.13 KB
/
ViewProviderDocumentObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/***************************************************************************
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_VIEWPROVIDER_DOCUMENTOBJECT_H
#define GUI_VIEWPROVIDER_DOCUMENTOBJECT_H
#include <Inventor/SoType.h>
#include "ViewProvider.h"
#include <App/DocumentObject.h>
class SoMaterial;
class SoDrawStyle;
class SoNode;
class SoType;
namespace App
{
class DocumentObject;
class Material;
}
namespace Gui {
class MDIView;
class GuiExport ViewProviderDocumentObject : public ViewProvider
{
PROPERTY_HEADER(Gui::ViewProviderDocumentObject);
public:
/// constructor.
ViewProviderDocumentObject();
/// destructor.
virtual ~ViewProviderDocumentObject();
// Display properties
App::PropertyEnumeration DisplayMode;
App::PropertyBool Visibility;
virtual void attach(App::DocumentObject *pcObject);
/// Get the default display mode
virtual const char* getDefaultDisplayMode() const;
/// Return a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
/// Set the active mode, i.e. the first item of the 'Display' property.
void setActiveMode();
/// Hide the object in the view
virtual void hide(void);
/// Show the object in the view
virtual void show(void);
/// Get a list of TaskBoxes associated with this object
virtual void getTaskViewContent(std::vector<Gui::TaskView::TaskContent*>&) const;
/// Run a redraw
void updateView();
/// Gets called if some of the property hade bin changed
virtual void updateData(const App::Property*){}
/// Get the object of this ViewProvider object
App::DocumentObject *getObject(void) const {return pcObject;}
/// Get the python wrapper for that ViewProvider
PyObject* getPyObject();
/** @name Restoring view provider from document load */
//@{
virtual void startRestoring();
virtual void finishRestoring();
//@}
/** @name drag & drop handling */
//@{
/// get called if the user hover over a object in the tree
virtual bool allowDrop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos);
/// get called if the user drops some objects
virtual void drop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos);
//@}
protected:
/*! Get the active mdi view of the document this view provider is part of.
@note The returned mdi view doesn't need to be a 3d view but can be e.g.
an image view, an SVG view or something else.
*/
Gui::MDIView* getActiveView() const;
/*! Get the mdi view of the document this view provider is part of and
that is in editing mode.
@note In case there is no mdi view in editing mode 0 is returned.
If a value different to 0 is returned it is guaranteed to be a 3d view.
*/
Gui::MDIView* getEditingView() const;
/*! Get any mdi view of the document this view provider is part of.
In case there is an mdi view in editing mode that contains this
view provider that mdi view is returned. Otherwise any other
3d view that contains this view provider is returned.
If a value different to 0 is returned it is guaranteed to be a 3d view.
*/
Gui::MDIView* getInventorView() const;
/*! Get the mdi view of the document that contains the given \a node.
*/
Gui::MDIView* getViewOfNode(SoNode* node) const;
/// get called before the value is changed
virtual void onBeforeChange(const App::Property* prop);
/// Gets called by the container whenever a property has been changed
virtual void onChanged(const App::Property* prop);
/** Searches in all view providers that are attached to an object that
* is part of the same document as the object this view provider is
* attached to for an front root of \a type.
* Before calling this function this view provider has to be attached
* to an object. The method returns after the first front root node
* matches. If no front root node matches, 0 is returned.
*/
SoNode* findFrontRootOfType(const SoType& type) const;
/** @name Transaction handling
*/
//@{
virtual bool isAttachedToDocument() const;
virtual const char* detachFromDocument();
//@}
protected:
App::DocumentObject *pcObject;
private:
std::vector<const char*> aDisplayEnumsArray;
std::vector<std::string> aDisplayModesArray;
};
} // namespace Gui
#endif // GUI_VIEWPROVIDER_DOCUMENTOBJECT_H