Developer Documentation
PlanePlugin.hh
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2020, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42#pragma once
43
44#include <QObject>
45
47#include <ObjectTypes/Plane/QtPlaneSelect.hh>
59
60class PlanePlugin : public QObject,
69 Q_OBJECT
70 Q_INTERFACES(BaseInterface)
71 Q_INTERFACES(MouseInterface)
72 Q_INTERFACES(KeyInterface)
73 Q_INTERFACES(PickingInterface)
74 Q_INTERFACES(LoggingInterface)
75 Q_INTERFACES(ToolbarInterface)
76 Q_INTERFACES(ScriptInterface)
77 Q_INTERFACES(LoadSaveInterface)
78
79 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Plane")
80
81signals:
82 // BaseInterface
83 void updateView();
84 void updatedObject(int, const UpdateType & );
85 void setSlotDescription(QString _slotName, QString _slotDescription,
86 QStringList _parameters, QStringList _descriptions);
87
88 // LoadSaveInterface
89 void addEmptyObject(DataType _type, int &_id);
90 void copyObject(int _oldId, int &_newId);
91 void deleteObject(int _id);
92
93 // ToolBarInterface
94 void addToolbar(QToolBar *_toolbar);
95 void getToolBar(QString _name, QToolBar *&_toolbar);
96
97 // ToolboxInterface
98 void defineViewMode(QString _mode, QStringList _usedWidgets);
99
100 // KeyInterfae
101 void registerKey(int _key, Qt::KeyboardModifiers _modifiers,
102 QString _description, bool _multiUse = false);
103
104 // PickingInterface
105 void addPickMode(const std::string& _mode);
106
107 // ScriptInterface
108 void scriptInfo(QString _functionName);
109
110 // LoggingInterface
111 void log(Logtype _type, QString _message);
112 void log(QString _message);
113
114private slots:
115
116 // BaseInterface
117 void initializePlugin();
118 void pluginsInitialized();
119
120 // PickingInterface
121 void slotPickModeChanged(const std::string &_mode);
122
123 // MouseInterface:
124 void slotMouseEvent(QMouseEvent *_event);
125
126 // KeyInterface:
127 void slotKeyEvent(QKeyEvent *_event);
128 void slotKeyReleaseEvent(QKeyEvent *_event);
129
130 bool getIntersectionParams(BaseObjectData &_obj, ACG::Vec3d &_center,
131 double &_radius);
132
133public:
134 PlanePlugin();
135 ~PlanePlugin() {}
136
137 void exit() {}
138
139 QString name() { return (QString("Plane")); }
140 QString description() { return (QString("Handle plane objects.")); }
141
142 //===========================================================================
145 //===========================================================================
146
148 template <class MeshT>
149 std::vector<ACG::Vec3d>
150 getIntersectionPoints(MeshT *_mesh, uint _fh, ACG::Vec3d _planeNormal,
151 ACG::Vec3d _planePoint, bool &_closed);
152
154 template <class MeshT>
155 typename MeshT::EdgeHandle getCuttedEdge(MeshT &_mesh,
156 ACG::Vec3d &_planeNormal,
157 ACG::Vec3d &_planePoint);
158
161 //===========================================================================
164 //===========================================================================
165
166private slots:
167
169 void slotCreatePlaneNode();
172
173private:
174 // Plane Selection Tools
176
178
180 // In Picking Mode for plane resize, are we currently dragging or not
181 bool dragging_ = false;
182 bool ortho_ = false;
183
184 // In Picking Mode for plane resize, which corner did we pick?
186
187 // world space coords of the dragging start position (through raycast)
192 // currently dragged plane
194 // copy of the plane, to avoid getting lost in floating point error realm
196 // needed for notifying the renderer to draw the plane correctly
197 int lastObjId_ = -1;
200 //===========================================================================
203 //===========================================================================
204
205public slots:
206 QString version() { return QString("1.0"); }
207
210private:
212 void setDescriptions();
213};
214
215#if defined(INCLUDE_TEMPLATES) && !defined(PLANEPLUGIN_CC)
216#define PLANEPLUGIN_TEMPLATES
217#include "PlanePluginT_impl.hh"
218#endif
Logtype
Log types for Message Window.
Interface class from which all plugins have to be created.
Predefined datatypes.
Definition: DataTypes.hh:83
Keyboard Event Interface.
Definition: KeyInterface.hh:59
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which do logging to the logging window of the framework.
Interface class for receiving mouse events.
Allow access to picking functions.
QString name()
Return a name for the plugin.
Definition: PlanePlugin.hh:139
bool dragging_
additional information
Definition: PlanePlugin.hh:181
void slotCreatePlaneTriggered()
Create a plane node when position/normal have been drawn.
Definition: PlanePlugin.cc:434
ACG::Vec3d viewCoord_
additional information
Definition: PlanePlugin.hh:190
PlanePlugin()
Constructor.
Definition: PlanePlugin.cc:59
PlaneObject * curPlane_
additional information
Definition: PlanePlugin.hh:193
bool ortho_
additional information
Definition: PlanePlugin.hh:182
ACG::Vec3d wCurrMousePos_
additional information
Definition: PlanePlugin.hh:189
void slotKeyReleaseEvent(QKeyEvent *_event)
a keyRelease event occured
Definition: PlanePlugin.cc:148
int pickedCorner_
additional information
Definition: PlanePlugin.hh:185
QAction * planeNodeAction_
additional information
Definition: PlanePlugin.hh:177
ACG::Vec3d wMouseDownPosition_
additional information
Definition: PlanePlugin.hh:188
void slotPickModeChanged(const std::string &_mode)
the pickMode changed
Definition: PlanePlugin.cc:123
std::vector< ACG::Vec3d > getIntersectionPoints(MeshT *_mesh, uint _fh, ACG::Vec3d _planeNormal, ACG::Vec3d _planePoint, bool &_closed)
get the points from the intersection between mesh and plane
MeshT::EdgeHandle getCuttedEdge(MeshT &_mesh, ACG::Vec3d &_planeNormal, ACG::Vec3d &_planePoint)
get an edge of the mesh that is cut by the plane
QtPlaneSelect * createPlane_
additional information
Definition: PlanePlugin.hh:175
void setDescriptions()
set scripting slot descriptions
void slotCreatePlaneNode()
Plane Node Button.
Definition: PlanePlugin.cc:427
Plane origPlane_
additional information
Definition: PlanePlugin.hh:195
void slotKeyEvent(QKeyEvent *_event)
a key event occured
Definition: PlanePlugin.cc:135
void initializePlugin()
Initialize the plugin.
Definition: PlanePlugin.cc:73
QString description()
Return a description of what the plugin is doing.
Definition: PlanePlugin.hh:140
int lastObjId_
additional information
Definition: PlanePlugin.hh:197
void slotMouseEvent(QMouseEvent *_event)
a mouse event occured
Definition: PlanePlugin.cc:166
ACG::Vec3d viewDirection_
additional information
Definition: PlanePlugin.hh:191
void pluginsInitialized()
Second initialization phase.
Definition: PlanePlugin.cc:86
Interface for all Plugins which provide scriptable Functions.
Add a toolbox to OpenFlipper.
Update type class.
Definition: UpdateType.hh:59