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 
60 class 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 
81 signals:
82  // BaseInterface
83  void updateView();
84  void updatedObject(int, 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 
114 private 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 slotKeyReleaseEvent(QKeyEvent *_event);
128 
129  bool getIntersectionParams(BaseObjectData &_obj, ACG::Vec3d &_center,
130  double &_radius);
131 
132 public:
133  PlanePlugin();
134  ~PlanePlugin() {}
135 
136  void exit() {}
137 
138  QString name() { return (QString("Plane")); }
139  QString description() { return (QString("Handle plane objects.")); }
140 
141  //===========================================================================
144  //===========================================================================
145 
147  template <class MeshT>
148  std::vector<ACG::Vec3d>
149  getIntersectionPoints(MeshT *_mesh, uint _fh, ACG::Vec3d _planeNormal,
150  ACG::Vec3d _planePoint, bool &_closed);
151 
153  template <class MeshT>
154  typename MeshT::EdgeHandle getCuttedEdge(MeshT &_mesh,
155  ACG::Vec3d &_planeNormal,
156  ACG::Vec3d &_planePoint);
157 
160  //===========================================================================
163  //===========================================================================
164 
165 private slots:
166 
168  void slotCreatePlaneNode();
171 
172 private:
173  // Plane Selection Tools
175 
177 
179  // In Picking Mode for plane resize, are we currently dragging or not
180  bool dragging_;
181 
182  // In Picking Mode for plane resize, which corner did we pick?
184 
185  // world space coords of the dragging start position (through raycast)
189  // currently dragged plane
190  PlaneObject *curPlane_ = nullptr;
191  // copy of the plane, to avoid getting lost in floating point error realm
193  // needed for notifying the renderer to draw the plane correctly
194  int lastObjId_ = -1;
197  //===========================================================================
200  //===========================================================================
201 
202 public slots:
203  QString version() { return QString("1.0"); }
204 
207 private:
209  void setDescriptions();
210 };
211 
212 #if defined(INCLUDE_TEMPLATES) && !defined(PLANEPLUGIN_CC)
213 #define PLANEPLUGIN_TEMPLATES
214 #include "PlanePluginT_impl.hh"
215 #endif
ACG::Vec3d wMouseDownPosition_
additional information
Definition: PlanePlugin.hh:186
QString description()
Return a description of what the plugin is doing.
Definition: PlanePlugin.hh:139
void slotMouseEvent(QMouseEvent *_event)
a mouse event occured
Definition: PlanePlugin.cc:145
Add a toolbox to OpenFlipper.
Interface class for receiving mouse events.
ACG::Vec3d wCurrMousePos_
additional information
Definition: PlanePlugin.hh:187
void initializePlugin()
Initialize the plugin.
Definition: PlanePlugin.cc:73
QtPlaneSelect * createPlane_
additional information
Definition: PlanePlugin.hh:174
MeshT::EdgeHandle getCuttedEdge(MeshT &_mesh, ACG::Vec3d &_planeNormal, ACG::Vec3d &_planePoint)
get an edge of the mesh that is cut by the plane
bool dragging_
additional information
Definition: PlanePlugin.hh:180
Logtype
Log types for Message Window.
void slotCreatePlaneTriggered()
Create a plane node when position/normal have been drawn.
Definition: PlanePlugin.cc:374
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
QAction * planeNodeAction_
additional information
Definition: PlanePlugin.hh:176
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
void setDescriptions()
set scripting slot descriptions
PlaneObject * curPlane_
additional information
Definition: PlanePlugin.hh:190
QString name()
Return a name for the plugin.
Definition: PlanePlugin.hh:138
int pickedCorner_
additional information
Definition: PlanePlugin.hh:183
Update type class.
Definition: UpdateType.hh:59
int lastObjId_
additional information
Definition: PlanePlugin.hh:194
ACG::Vec3d viewDirection_
additional information
Definition: PlanePlugin.hh:188
Keyboard Event Interface.
Definition: KeyInterface.hh:59
void slotKeyReleaseEvent(QKeyEvent *_event)
a keyRelease event occured
Definition: PlanePlugin.cc:132
void slotPickModeChanged(const std::string &_mode)
the pickMode changed
Definition: PlanePlugin.cc:120
Interface for all Plugins which provide scriptable Functions.
void pluginsInitialized()
Second initialization phase.
Definition: PlanePlugin.cc:83
PlanePlugin()
Constructor.
Definition: PlanePlugin.cc:59
void slotCreatePlaneNode()
Plane Node Button.
Definition: PlanePlugin.cc:367
Plane origPlane_
additional information
Definition: PlanePlugin.hh:192
Interface class from which all plugins have to be created.
Allow access to picking functions.
Interface for all plugins which want to Load or Save files and create Objects.