Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
BSplineCurveSelectionPlugin.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 BSPLINECURVESELECTIONPLUGIN_HH
51 #define BSPLINECURVESELECTIONPLUGIN_HH
52 
53 #include <QObject>
54 
62 #include <OpenFlipper/BasePlugin/INIInterface.hh>
67 #include <OpenFlipper/INIFile/INIFile.hh>
68 
70 
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 #if QT_VERSION >= 0x050000
84  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionBSplineCurve")
85 #endif
86 
87 public:
88 
91 
94 
95 signals:
96 
97  // BaseInterface
98  void updateView();
99  void updatedObject(int, const UpdateType&);
100  void nodeVisibilityChanged(int _identifier);
101  void setSlotDescription(QString _slotName, QString _slotDescription,
102  QStringList _parameters, QStringList _descriptions);
103 
104  // BackupInterface
105  void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
106 
107  // LoggingInterface
108  void log(Logtype _type, QString _message);
109  void log(QString _message);
110 
111  // ScriptInterface
112  void scriptInfo(QString _functionName);
113 
114  // SelectionInterface
115  void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
116  void registerType(QString _handleName, DataType _type);
117  void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
118  void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
119  void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
120  void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
121 
122  void getActiveDataTypes(SelectionInterface::TypeList& _types);
123  void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
124  void targetObjectsOnly(bool& _targetsOnly);
125 
126  void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
127 
128 private slots:
129 
130  // INIInterface
131  void loadIniFile(INIFile& _ini, int _id);
132  void saveIniFile(INIFile& _ini, int _id);
133 
134  // BaseInterface
135  void initializePlugin();
136  void pluginsInitialized();
137  void noguiSupported() {};
138 
139  // SelectionInterface
140  void slotSelectionOperation(QString _operation);
141  void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
142  void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
143 
144  void slotLoadSelection(const INIFile& _file);
145  void slotSaveSelection(INIFile& _file);
146 
147  void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
148 
149 public slots:
150 
151  // SelectionInterface
152  void loadSelection(int _objId, const QString& _filename);
153 
154 public:
155 
156  // BaseInterface
157  QString name() {
158  return (QString(tr("BSplineCurve Selection")));
159  };
160 
161  QString description() {
162  return (QString(tr("Allows to select B-Spline curves")));
163  };
164 
165  //===========================================================================
168  //===========================================================================
169 private:
170 
171  enum SelectionViewMode {CP, K};
172 
174  void setSelectionViewMode(const SelectionViewMode _mode);
175 
177  void updateSlotDescriptions();
178 
181 public slots:
182 
183  QString version() {
184  return QString("1.0");
185  };
186 
187  //===========================================================================
190  //===========================================================================
191 
192  // Control point selection:
193 
195  void selectAllControlPoints(int _objectId);
196 
198  void deselectAllControlPoints(int _objectId);
199 
201  void invertControlPointSelection(int _objectId);
202 
204  void deleteSelectedControlPoints(int _objectId);
205 
207  void selectControlPoints(int _objectId, const IdList& _ids, bool _deselect = false);
208 
210  IdList getControlPointSelection(int _objectId);
211 
212  // Knot selection:
213 
215  void selectAllKnots(int _objectId);
216 
218  void deselectAllKnots(int _objectId);
219 
221  void invertKnotSelection(int _objectId);
222 
224  void deleteSelectedKnots(int _objectId);
225 
227  void selectKnots(int _objectId, const IdList& _ids, bool _deselect = false);
228 
230  IdList getKnotSelection(int _objectId);
231 
234  //===========================================================================
237  //===========================================================================
238 
239 private:
240 
243 
245  unsigned int controlPointType_;
246  unsigned int knotType_;
247 
248  unsigned int allSupportedTypes_;
249 
251  QVector<QPoint> volumeLassoPoints_;
252 
255 };
256 
257 //=============================================================================
258 #endif // BSPLINECURVESELECTIONPLUGIN_HH defined
259 //=============================================================================
void deleteSelectedKnots(int _objectId)
Delete selected knots.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
void deselectAllKnots(int _objectId)
Deselect all knots of a curve.
unsigned int controlPointType_
Primitive type handles:
void invertKnotSelection(int _objectId)
Invert knot selection.
void invertControlPointSelection(int _objectId)
Invert control point selection.
void selectAllControlPoints(int _objectId)
Select all control points of a curve.
QString environmentHandle_
Handle to selection environment.
IdList getKnotSelection(int _objectId)
Get current knot selection.
void selectControlPoints(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific control points of a curve.
~BSplineCurveSelectionPlugin()
Default destructor.
IdList getControlPointSelection(int _objectId)
Get current control point selection.
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
Interface for all Plugins which provide scriptable Functions.
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
void setSelectionViewMode(const SelectionViewMode _mode)
Change selection view mode for every B-spline curve in the scene.
Interface class for backup handling.
Interface for all Plugins which do logging to the logging window of the framework.
SelectionViewMode
Change selection view mode for every B-spline curve in the scene.
void updateSlotDescriptions()
Set slot descriptions for scripting functions.
QVector< QPoint > volumeLassoPoints_
Keep volume lasso points.
Interface for all plugins which want to use selection functions.
Update type class.
Definition: UpdateType.hh:70
QString description()
Return a description of what the plugin is doing.
unsigned int knotType_
Handle to selection environment.
BSplineCurveSelectionPlugin()
Default constructor.
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
void selectKnots(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific knots of a curve.
void deleteSelectedControlPoints(int _objectId)
Delete selected control points.
Keyboard Event Interface.
Definition: KeyInterface.hh:76
unsigned int allSupportedTypes_
Handle to selection environment.
void selectAllKnots(int _objectId)
Select all knots of a curve.
Interface class from which all plugins have to be created.
Logtype
Log types for Message Window.
Predefined datatypes.
Definition: DataTypes.hh:96
QString name()
Return a name for the plugin.
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:81
void slotSelectionOperation(QString _operation)
A specific operation is requested.
void deselectAllControlPoints(int _objectId)
Deselect all control points of a curve.
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.