Commit 46fa1d5c authored by Jan Möbius's avatar Jan Möbius

Added the plugin collection for selection



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15691 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 47b37ecd
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Author$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef BSPLINECURVESELECTIONPLUGIN_HH
#define BSPLINECURVESELECTIONPLUGIN_HH
#include <QObject>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/INIInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/SelectionInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/INIFile/INIFile.hh>
#include <ObjectTypes/BSplineCurve/BSplineCurve.hh>
class BSplineCurveSelectionPlugin : public QObject, BaseInterface, KeyInterface,
INIInterface, BackupInterface, LoggingInterface, ScriptInterface, SelectionInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(INIInterface)
Q_INTERFACES(BackupInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(SelectionInterface)
public:
/// Default constructor
BSplineCurveSelectionPlugin();
/// Default destructor
~BSplineCurveSelectionPlugin();
signals:
// BaseInterface
void updateView();
void updatedObject(int, const UpdateType&);
void nodeVisibilityChanged(int _identifier);
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
// BackupInterface
void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
// LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
// ScriptInterface
void scriptInfo(QString _functionName);
// SelectionInterface
void addSelectionEnvironment(QString _modeName, QString _description, QIcon _icon, QString& _handleName);
void registerType(QString _handleName, DataType _type);
void addPrimitiveType(QString _handleName, QString _name, QIcon _icon, SelectionInterface::PrimitiveType& _typeHandle);
void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
void getActiveDataTypes(SelectionInterface::TypeList& _types);
void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
void targetObjectsOnly(bool& _targetsOnly);
void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
private slots:
// INIInterface
void loadIniFile(INIFile& _ini, int _id);
void saveIniFile(INIFile& _ini, int _id);
// BaseInterface
void initializePlugin();
void pluginsInitialized();
void noguiSupported() {};
// SelectionInterface
void slotSelectionOperation(QString _operation);
void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotLoadSelection(const INIFile& _file);
void slotSaveSelection(INIFile& _file);
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
public slots:
// SelectionInterface
void loadSelection(int _objId, const QString& _filename);
public:
// BaseInterface
QString name() {
return (QString(tr("BSplineCurve Selection")));
};
QString description() {
return (QString(tr("Allows to select B-Spline curves")));
};
//===========================================================================
/** @name Private methods
* @{ */
//===========================================================================
private:
enum SelectionViewMode {CP, K};
/// Change selection view mode for every B-spline curve in the scene
void setSelectionViewMode(const SelectionViewMode _mode);
/// Set slot descriptions for scripting functions
void updateSlotDescriptions();
/** @} */
public slots:
QString version() {
return QString("1.0");
};
//===========================================================================
/** @name Scriptable slots
* @{ */
//===========================================================================
// Control point selection:
/// Select all control points of a curve
void selectAllControlPoints(int _objectId);
/// Deselect all control points of a curve
void deselectAllControlPoints(int _objectId);
/// Invert control point selection
void invertControlPointSelection(int _objectId);
/// Delete selected control points
void deleteSelectedControlPoints(int _objectId);
/// Select specific control points of a curve
void selectControlPoints(int _objectId, const IdList& _ids, bool _deselect = false);
/// Get current control point selection
IdList getControlPointSelection(int _objectId);
// Knot selection:
/// Select all knots of a curve
void selectAllKnots(int _objectId);
/// Deselect all knots of a curve
void deselectAllKnots(int _objectId);
/// Invert knot selection
void invertKnotSelection(int _objectId);
/// Delete selected knots
void deleteSelectedKnots(int _objectId);
/// Select specific knots of a curve
void selectKnots(int _objectId, const IdList& _ids, bool _deselect = false);
/// Get current knot selection
IdList getKnotSelection(int _objectId);
/** @} */
//===========================================================================
/** @name Member variables
* @{ */
//===========================================================================
private:
/// Handle to selection environment
QString environmentHandle_;
/// Primitive type handles:
unsigned int controlPointType_;
unsigned int knotType_;
unsigned int allSupportedTypes_;
/// Keep volume lasso points
QVector<QPoint> volumeLassoPoints_;
/** @} */
};
//=============================================================================
#endif // BSPLINECURVESELECTIONPLUGIN_HH defined
//=============================================================================
include (plugin)
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/BSplineCurve)
openflipper_plugin (INSTALLDATA Icons)
endif()
include (plugin)
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/BSplineSurface)
openflipper_plugin (INSTALLDATA Icons)
endif()
include (plugin)
openflipper_plugin (DIRS widgets
INSTALLDATA Icons)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Author$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef HELPERCLASSES_HH_INCLUDED
#define HELPERCLASSES_HH_INCLUDED
#include <OpenFlipper/common/DataTypes.hh>
#include <QAction>
#include <QPushButton>
#include <QGridLayout>
class HandleAction : public QAction {
public:
/// Default constructor
HandleAction(QIcon _icon, QString _description, QObject* _parent = 0, DataType _objectTypeRestriction = DATA_ALL) :
QAction(_icon, _description, _parent),
associatedTypes_(0u),
objectTypeRestriction_(_objectTypeRestriction) {}
/// Default destructor
~HandleAction() {}
/// Get/Set selection environment handle name
void selectionEnvironmentHandle(QString _handle) { selectionEnvHandle_ = _handle; }
QString selectionEnvironmentHandle() { return selectionEnvHandle_; }
/// Get/Set selection mode handle name
void selectionModeHandle(QString _handle) { selectionModeHandle_ = _handle; }
QString selectionModeHandle() { return selectionModeHandle_; }
/// Get/Set associated primitive types
void addAssociatedType(unsigned int _associatedType) { associatedTypes_ |= _associatedType; }
void removeAssociatedType(unsigned int _associatedType) { associatedTypes_ &= ~_associatedType; }
bool isAssociated(unsigned int _type, bool _associatedWithAll = false) {
if(_associatedWithAll && _type != 0u)
return ((associatedTypes_ | _type) == associatedTypes_);
else
return ((associatedTypes_ & _type) != 0);
}
void objectTypeRestriction(const DataType& _type) {
objectTypeRestriction_ = _type;
}
const DataType& objectTypeRestriction() const {
return objectTypeRestriction_;
}
private:
QString selectionEnvHandle_;
QString selectionModeHandle_;
unsigned int associatedTypes_;
DataType objectTypeRestriction_;
};
class PrimitiveAction : public QAction {
public:
/// Default constructor
PrimitiveAction(QIcon _icon, QString _description, QObject* _parent = 0) :
QAction(_icon, _description, _parent),
primitiveType_(0),
selectionEnvironmentHandle_("")
{};
/// Default destructor
~PrimitiveAction() {};
/// Get/Set primitive type
void primitiveType(unsigned int _type) { primitiveType_ = _type; }
unsigned int primitiveType() { return primitiveType_; }
/// Get/Set associated selection environment handle
void selectionEnvironmentHandle(const QString _handle) {
selectionEnvironmentHandle_ = _handle;
}
QString selectionEnvironmentHandle() const {
return selectionEnvironmentHandle_;
}
private:
unsigned int primitiveType_;
QString selectionEnvironmentHandle_;
};
class ActionButton : public QPushButton {
Q_OBJECT
public:
/// Default constructor
ActionButton(QAction* _action, QWidget* _parent = 0) :
QPushButton(_parent), action_(_action) {
// Initialize button with action parameters
setCheckable(true);
setIcon(action_->icon());
setIconSize(QSize(48,48));
setToolTip(action_->text());
connect(action_, SIGNAL(toggled(bool)), this, SLOT(setChecked(bool)));
connect(this, SIGNAL(toggled(bool)), action_, SLOT(setChecked(bool)));
};
/// Default destructor
~ActionButton() {};
private slots:
// Avoid back sending of signal (this results in an infinite loop)
void setChecked(bool _checked) {
blockSignals(true);
QPushButton::setChecked(_checked);
blockSignals(false);
}
void changeRegistered() {
setChecked(action_->isChecked());
}
private:
QAction* action_;
};
class FillingLayout : public QGridLayout {
public:
/// Default Constructor
FillingLayout(int _numColumns) :
QGridLayout(),
currentRow_(0),
currentColumn_(0),
numColumns_(_numColumns) {};
void addWidget(QWidget* _widget) {
QGridLayout::addWidget(_widget, currentRow_, currentColumn_);
currentColumn_++;
if(currentColumn_ == numColumns_) {
currentColumn_ = 0;
currentRow_++;
}
};
private:
unsigned int currentRow_;
unsigned int currentColumn_;
unsigned int numColumns_;
};
#endif // HELPERCLASSES_HH_INCLUDED
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.47 r22583"
width="48"
height="48"
sodipodi:docname="Neues Dokument 1"
inkscape:export-filename="/home/wilden/projects/OF-Free-Clean/build-release/Build/share/OpenFlipper/Icons/selection_base.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2828"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1092"
inkscape:window-height="777"
id="namedview4"
showgrid="false"
inkscape:zoom="5.2291667"
inkscape:cx="24"
inkscape:cy="24"
inkscape:window-x="277"
inkscape:window-y="235"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<image
xlink:href="file:///home/wilden/projects/OF-Free-Clean/Plugin-SelectionBase/Icons/selection_base.png"
width="48"
height="48"
id="image12"
x="0"
y="0" />
<path
style="fill:#ffffff;stroke:#151515;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.87539935;stroke-miterlimit:4;stroke-dasharray:none"
d="M 18.836653,13.96016 21.896414,39.968127 28.207171,34.42231 39.107569,47.235059 46.948207,41.498008 35.856573,28.111553 43.123506,23.904382 18.836653,13.96016 z"
id="path2818" />
</svg>
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *