50#ifndef SELECTIONBASEPLUGIN_HH
51#define SELECTIONBASEPLUGIN_HH
67#include <OpenFlipper/BasePlugin/INIInterface.hh>
72#include <ACG/Scenegraph/GlutPrimitiveNode.hh>
73#include <ACG/Scenegraph/LineNode.hh>
78#include "widgets/SelectionBaseToolbox.hh"
79#include "widgets/SelectionTypeFrame.hh"
81#include <OpenFlipper/INIFile/INIFile.hh>
83#include "HelperClasses.hh"
101 Q_PLUGIN_METADATA(IID
"org.OpenFlipper.Plugins.Plugin-SelectionBase")
111 QString
name() {
return (QString(tr(
"SelectionBase"))); };
112 QString
description( ) {
return (QString(tr(
"Provides basic selection functions"))); };
120 void log(
Logtype _type, QString _message);
121 void log(QString _message);
124 void addToolbar(QToolBar* _toolbar);
127 void toggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
128 void lassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
129 void volumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
130 void surfaceLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
131 void sphereSelection(QMouseEvent* _event,
double _radius, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
132 void closestBoundarySelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
133 void floodFillSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
134 void componentsSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
135 void customSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier,
bool _deselect);
137 void selectionOperation(QString _operation);
138 void loadSelection(
const INIFile& _file);
139 void saveSelection(
INIFile& _file);
141 void keyShortcutEvent(
int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
144 void addPickMode(
const std::string& _mode);
145 void setPickModeMouseTracking(
const std::string& _mode,
bool _mouseTracking);
146 void setPickModeCursor(
const std::string& _mode, QCursor _cursor);
147 void setPickModeToolbar (
const std::string& _mode, QToolBar * _toolbar);
150 void registerKey(
int _key, Qt::KeyboardModifiers _modifiers, QString _description,
bool _multiUse =
false);
153 void addToolbox(QString _name, QWidget* _widget, QIcon* _icon);
158 void initializePlugin();
159 void pluginsInitialized();
162 void slotMouseWheelEvent(QWheelEvent* _event,
const std::string& _mode);
163 void slotMouseEvent(QMouseEvent* _event);
166 void slotAddSelectionEnvironment(QString _modeName,
const QString &_description,
const QString &_icon, QString& _handleName);
167 void slotRegisterType(
const QString &_handleName,
DataType _type);
168 void slotAddPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
169 void slotAddCustomSelectionMode(
const QString& _handleName,
const QString& _modeName,
const QString& _description,
const QString& _icon,
170 SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier);
171 void slotAddCustomSelectionMode(
const QString &_handleName,
const QString &_modeName,
const QString &_description,
const QString &_icon,
172 SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
175 void slotAddSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
176 void slotAddSelectionParameters(QString _handleName, QWidget* _widget, QString _category, SelectionInterface::PrimitiveType _type = 0u);
178 void slotShowToggleSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
179 void slotShowLassoSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
180 void slotShowVolumeLassoSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
181 void slotShowSurfaceLassoSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
182 void slotShowSphereSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
183 void slotShowClosestBoundarySelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
184 void slotShowFloodFillSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
185 void slotShowComponentsSelectionMode(
const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
187 void slotGetActiveDataTypes(SelectionInterface::TypeList& _types);
188 void slotGetActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
190 void slotTargetObjectsOnly(
bool& _targetsOnly);
191 void slotRegisterKeyShortcut(
int _key, Qt::KeyboardModifiers _modifiers);
194 void addedEmptyObject (
int _id);
195 void objectDeleted (
int _id);
198 void slotPickModeChanged (
const std::string& _pickmode);
201 void slotKeyEvent(QKeyEvent* _event);
202 void slotKeyReleaseEvent(QKeyEvent* _event);
205 void loadIniFileOptionsLast(
INIFile& _ini);
210 void slotMouseToggleSelection(QMouseEvent* _event);
211 void slotMouseLassoSelection(QMouseEvent* _event);
212 void slotMouseVolumeLassoSelection(QMouseEvent* _event);
213 void slotMouseSurfaceLassoSelection(QMouseEvent* _event);
214 void slotMouseSphereSelection(QMouseEvent* _event);
215 void slotMouseBoundarySelection(QMouseEvent* _event);
216 void slotMouseFloodFillSelection(QMouseEvent* _event);
217 void slotMouseComponentsSelection(QMouseEvent* _event);
218 void slotMouseCustomSelection(QMouseEvent* _event);
220 void slotLoadSelectionButton();
221 void slotSaveSelectionButton();
223 void slotOperationRequested();
224 void slotShowAndHideOperations();
225 void slotShowAndHideParameters();
229 void slotSelectionEnvironmentRequested(
bool _checked);
231 void slotEnterSelectionMode(
bool _checked);
233 void updateActivePrimitiveTypes(
bool _checked);
236 QString version() {
return QString(
"1.0"); };
277 std::vector<DataType> types;
279 std::set<HandleAction*> defaultSelectionModes;
281 std::set<HandleAction*> customSelectionModes;
285 QHBoxLayout* primitivesBar;
287 QVBoxLayout* operationsBar;
289 std::map<QString,std::pair<FillingLayout*,QGroupBox*> > categories;
291 QActionGroup* primitiveActions;
293 unsigned int primitiveTypes;
296 std::multimap<PrimitiveType, QPushButton*> operations;
299 std::multimap<PrimitiveType, QWidget*> parameters;
321 void showSelectionMode(
const QString &_mode,
const QString &_icon,
const QString &_desc,
322 const QString &_handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes,
323 QString& _customIdentifier,
bool _custom =
false,
DataType _objectTypeRestriction =
DATA_ALL);
327 SelectionInterface::PrimitiveType& _associatedTypes);
339 void updateTabsOrder();
342 std::map<QString,SelectionEnvironment> selectionEnvironments_;
347 std::map<PrimitiveType,QAction*> primitiveTypeButtons_;
356 QActionGroup* primitivesBarGroup_;
357 QToolBar* pickModeToolBar_;
359 QActionGroup* selectionModesGroup_;
371 std::set<std::pair<int,Qt::KeyboardModifiers> > registeredKeys_;
376 QString currentPickMode_;
379 QString lastPickMode_;
382 QString currentSelectionMode_;
385 SelectionInterface::PrimitiveType currentPrimitiveType_;
388 unsigned int nextFreePrimitiveType_;
402 double sphere_radius_;
408 bool lassoSelection_;
411 std::vector<ACG::Vec3d> linePoints_;
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
Logtype
Log types for Message Window.
Interface class from which all plugins have to be created.
Class for the handling of simple configuration files.
Interface class for Plugins which have to store information in ini files.
Keyboard Event Interface.
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.
Interface for all Plugins which provide scriptable Functions.
bool typeExists(DataType _type, int _excludeId=-1)
Test if at least one object of type _type is in the scene graph.
QMap< DataType, int > typeCounter_
Caches the number of available elements of a certain data type for the typeExists function.
void setSelectionPrimitiveType(const QString &_primitive)
Enables setting the selection primitive via scripting The default primitives for OpenMesh are:
QString name()
Return a name for the plugin.
void updatePickModeToolBar()
Update the pickmode toolbar.
void showSelectionMode(const QString &_mode, const QString &_icon, const QString &_desc, const QString &_handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes, QString &_customIdentifier, bool _custom=false, DataType _objectTypeRestriction=DATA_ALL)
bool findObjectType(BaseObjectData *&obj, bool &found, SelectionEnvironment *&env, int _id)
helper function to find a baseObjectData and selection environment given a specific id
void setSelectionMetaphor(const QString &_metaphor)
Enables setting the selection metaphor via scripting The default selection metaphors are:
QString getUniqueHandleName(const QString &_name, int _num=0)
Get a unique handle name.
SelectionBasePlugin()
Default constructor.
SelectionTypeFrameWidget * createNewTypeFrame(SelectionEnvironment &_env)
Create new type frame for tabs widget.
QString description()
Return a description of what the plugin is doing.
bool getSelectionEnvironment(SelectionEnvironment *&env, const QString &_handleName)
Get a selectionEnvironment by a given name.
QString getUniqueIdentifierName(const QString &_name, int _num=0)
Get a unique pickmode name.
void selectionModeShowSwitch(bool _show, SelectionEnvironment *&env, HandleAction *toggleSelectionAction_, SelectionInterface::PrimitiveType &_associatedTypes)
helper function for showSelectionMode
Interface for all plugins which want to use selection functions.