Developer Documentation

BSplineSurfaceSelectionPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, 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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef BSPLINESURFACESELECTIONPLUGIN_HH
51 #define BSPLINESURFACESELECTIONPLUGIN_HH
52
53 #include <QObject>
54
55 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
56 #include <OpenFlipper/BasePlugin/KeyInterface.hh>
57 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
58 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
59 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
60 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
61 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
62 #include <OpenFlipper/BasePlugin/INIInterface.hh>
63 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
64 #include <OpenFlipper/BasePlugin/SelectionInterface.hh>
65 #include <OpenFlipper/common/Types.hh>
66 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
67 #include <OpenFlipper/INIFile/INIFile.hh>
68
69 #include <ObjectTypes/BSplineSurface/BSplineSurface.hh>
70
71 class BSplineSurfaceSelectionPlugin : public QObject, BaseInterface, KeyInterface,
72 INIInterface, BackupInterface, LoggingInterface, ScriptInterface, SelectionInterface
73 {
74 Q_OBJECT
75 Q_INTERFACES(BaseInterface)
76 Q_INTERFACES(KeyInterface)
77 Q_INTERFACES(INIInterface)
78 Q_INTERFACES(BackupInterface)
79 Q_INTERFACES(LoggingInterface)
80 Q_INTERFACES(ScriptInterface)
81 Q_INTERFACES(SelectionInterface)
82
83 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionBSplineSurface")
84
85 public:
86
88 BSplineSurfaceSelectionPlugin();
89
91 ~BSplineSurfaceSelectionPlugin();
92
93 signals:
94
95 // BaseInterface
96 void updateView();
97 void updatedObject(int, const UpdateType&);
98 void nodeVisibilityChanged(int _identifier);
99 void setSlotDescription(QString _slotName, QString _slotDescription,
100 QStringList _parameters, QStringList _descriptions);
101
102 // LoggingInterface
103 void log(Logtype _type, QString _message);
104 void log(QString _message);
105
106 // BackupInterface
107 void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
108
109 // ScriptInterface
110 void scriptInfo(QString _functionName);
111
112 // SelectionInterface
113 void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
114 void registerType(QString _handleName, DataType _type);
115 void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
116 void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
117 void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
118 void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
119
120 void getActiveDataTypes(SelectionInterface::TypeList& _types);
121 void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
122 void targetObjectsOnly(bool& _targetsOnly);
123
124 void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
125
126 private slots:
127
128 // INIInterface
129 void loadIniFile(INIFile& _ini, int _id);
130 void saveIniFile(INIFile& _ini, int _id);
131
132 // BaseInterface
133 void initializePlugin();
134 void pluginsInitialized();
135 void noguiSupported() {};
136
137 // SelectionInterface
138 void slotSelectionOperation(QString _operation);
139 void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
140 void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
141
142 void slotLoadSelection(const INIFile& _file);
143 void slotSaveSelection(INIFile& _file);
144
145 void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
146
147 public slots:
148
149 // SelectionInterface
150 void loadSelection(int _objId, const QString& _filename);
151
152 public:
153
154 // BaseInterface
155 QString name() {
156 return (QString(tr("BSplineSurface Selection")));
157 };
158
159 QString description() {
160 return (QString(tr("Allows to select B-Spline surfaces")));
161 };
162
163 //===========================================================================
166 //===========================================================================
167 private:
168
169 enum SelectionViewMode {CP, K};
170
172 void setSelectionViewMode(const SelectionViewMode _mode);
173
175 void updateSlotDescriptions();
176
179 public slots:
180
181 QString version() {
182 return QString("1.0");
183 };
184
185 //===========================================================================
188 //===========================================================================
189
190 // Control point selection:
191
193 void selectAllControlPoints(int _objectId);
194
196 void deselectAllControlPoints(int _objectId);
197
199 void invertControlPointSelection(int _objectId);
200
202 // void deleteSelectedControlPointsU(int _objectId);
203 // void deleteSelectedControlPointsV(int _objectId);
204
206 void selectControlPoints(int _objectId, const IdList& _ids, bool _deselect = false);
207
209 IdList getControlPointSelection(int _objectId);
210
211 // Knot selection:
212
214 void selectAllKnots(int _objectId);
215
217 void deselectAllKnots(int _objectId);
218
220 void invertKnotSelection(int _objectId);
221
223 void deleteSelectedKnotsU(int _objectId);
224 void deleteSelectedKnotsV(int _objectId);
225
227 void selectKnots(int _objectId, const IdList& _ids_u, const IdList& _ids_v, bool _deselect = false);
228
230 IdList getKnotSelectionU(int _objectId);
231 IdList getKnotSelectionV(int _objectId);
232
235 //===========================================================================
238 //===========================================================================
239
240 private:
241
243 QString environmentHandle_;
244
246 unsigned int controlPointType_;
247 unsigned int knotType_;
248
249 unsigned int allSupportedTypes_;
250
252 QVector<QPoint> volumeLassoPoints_;
253
256 };
257
258 //=============================================================================
259 #endif // BSPLINESURFACESELECTIONPLUGIN_HH defined
260 //=============================================================================
SelectionInterface.hh
BSplineSurface.hh
ScriptInterface.hh
ToolboxInterface.hh
BSplineSurfaceSelectionPlugin::slotToggleSelection
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
Definition: BSplineSurfaceSelectionPlugin.cc:317
BSplineSurfaceSelectionPlugin::selectControlPoints
void selectControlPoints(int _objectId, const IdList &_ids, bool _deselect=false)
Delete selected control points.
Definition: BSplineSurfaceSelectionFunctions.cc:196
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
LoadSaveInterface.hh
BSplineSurfaceSelectionPlugin::slotLoadSelection
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
Definition: BSplineSurfaceSelectionPlugin.cc:593
BSplineSurfaceSelectionPlugin::deleteSelectedKnotsU
void deleteSelectedKnotsU(int _objectId)
Delete selected knots.
Definition: BSplineSurfaceSelectionFunctions.cc:344
BSplineSurfaceSelectionPlugin::getKnotSelectionU
IdList getKnotSelectionU(int _objectId)
Get current knot selection.
Definition: BSplineSurfaceSelectionFunctions.cc:454
BSplineSurfaceSelectionPlugin
Definition: BSplineSurfaceSelectionPlugin.hh:71
BSplineSurfaceSelectionPlugin::invertControlPointSelection
void invertControlPointSelection(int _objectId)
Invert control point selection.
Definition: BSplineSurfaceSelectionFunctions.cc:94
BSplineSurfaceSelectionPlugin::selectKnots
void selectKnots(int _objectId, const IdList &_ids_u, const IdList &_ids_v, bool _deselect=false)
Select specific knots of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:409
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
BSplineSurfaceSelectionPlugin::updateSlotDescriptions
void updateSlotDescriptions()
Set slot descriptions for scripting functions.
Definition: BSplineSurfaceSelectionPlugin.cc:156
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
PluginFunctions.hh
BSplineSurfaceSelectionPlugin::slotVolumeLassoSelection
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
Definition: BSplineSurfaceSelectionPlugin.cc:433
BSplineSurfaceSelectionPlugin::volumeLassoPoints_
QVector< QPoint > volumeLassoPoints_
Keep volume lasso points.
Definition: BSplineSurfaceSelectionPlugin.hh:252
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
LoggingInterface.hh
BSplineSurfaceSelectionPlugin::selectAllKnots
void selectAllKnots(int _objectId)
Select all knots of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:259
IdList
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
BSplineSurfaceSelectionPlugin::deselectAllKnots
void deselectAllKnots(int _objectId)
Deselect all knots of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:287
BSplineSurfaceSelectionPlugin::deselectAllControlPoints
void deselectAllControlPoints(int _objectId)
Deselect all control points of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:73
BSplineSurfaceSelectionPlugin::setSelectionViewMode
void setSelectionViewMode(const SelectionViewMode _mode)
Change selection view mode for every B-spline surface in the scene.
Definition: BSplineSurfaceSelectionPlugin.cc:702
BSplineSurfaceSelectionPlugin::deleteSelectedKnotsV
void deleteSelectedKnotsV(int _objectId)
Select all control points of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:372
BSplineSurfaceSelectionPlugin::selectAllControlPoints
void selectAllControlPoints(int _objectId)
Select all control points of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:46
ToolbarInterface.hh
BSplineSurfaceSelectionPlugin::invertKnotSelection
void invertKnotSelection(int _objectId)
Invert knot selection.
Definition: BSplineSurfaceSelectionFunctions.cc:310
BSplineSurfaceSelectionPlugin::getControlPointSelection
IdList getControlPointSelection(int _objectId)
Get current control point selection.
Definition: BSplineSurfaceSelectionFunctions.cc:233
BSplineSurfaceSelectionPlugin::~BSplineSurfaceSelectionPlugin
~BSplineSurfaceSelectionPlugin()
Default destructor.
Definition: BSplineSurfaceSelectionPlugin.cc:87
BSplineSurfaceSelectionPlugin::getKnotSelectionV
IdList getKnotSelectionV(int _objectId)
Select all control points of a curve.
Definition: BSplineSurfaceSelectionFunctions.cc:476
SelectionInterface
Interface for all plugins which want to use selection functions.
Definition: SelectionInterface.hh:67
BSplineSurfaceSelectionPlugin::BSplineSurfaceSelectionPlugin
BSplineSurfaceSelectionPlugin()
Default constructor.
Definition: BSplineSurfaceSelectionPlugin.cc:79
UpdateType
Update type class.
Definition: UpdateType.hh:60
BSplineSurfaceSelectionPlugin::slotSelectionOperation
void slotSelectionOperation(QString _operation)
A specific operation is requested.
Definition: BSplineSurfaceSelectionPlugin.cc:186
BSplineSurfaceSelectionPlugin::SelectionViewMode
SelectionViewMode
Change selection view mode for every B-spline surface in the scene.
Definition: BSplineSurfaceSelectionPlugin.hh:169
BSplineSurfaceSelectionPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: BSplineSurfaceSelectionPlugin.hh:159
BSplineSurfaceSelectionPlugin::slotKeyShortcutEvent
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.
Definition: BSplineSurfaceSelectionPlugin.cc:651
KeyInterface
Keyboard Event Interface.
Definition: KeyInterface.hh:59
INIInterface
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
INIFile
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
BSplineSurfaceSelectionPlugin::name
QString name()
Return a name for the plugin.
Definition: BSplineSurfaceSelectionPlugin.hh:155
BSplineSurfaceSelectionPlugin::controlPointType_
unsigned int controlPointType_
Primitive type handles:
Definition: BSplineSurfaceSelectionPlugin.hh:246
BSplineSurfaceSelectionPlugin::slotSaveSelection
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
Definition: BSplineSurfaceSelectionPlugin.cc:630
BSplineSurfaceSelectionPlugin::allSupportedTypes_
unsigned int allSupportedTypes_
Handle to selection environment.
Definition: BSplineSurfaceSelectionPlugin.hh:249
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
Types.hh
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
BaseInterface.hh
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
BSplineSurfaceSelectionPlugin::environmentHandle_
QString environmentHandle_
Handle to selection environment.
Definition: BSplineSurfaceSelectionPlugin.hh:243
BackupInterface.hh
BSplineSurfaceSelectionPlugin::knotType_
unsigned int knotType_
Handle to selection environment.
Definition: BSplineSurfaceSelectionPlugin.hh:247
KeyInterface.hh