Commit 1ffd490f authored by Martin Schultz's avatar Martin Schultz

removed maxAngle from slots in SelectionMeshObject and SelectionVolumeMesh plugins

added a widget to SelectionVolumeMesh plugin to control maxAngle.
added maxAngle spinbox to parameter widget of MeshObjectSelection plugin.
added get and set functions for maxAngle to both plugins.
parent f916a122
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "ParameterWidget.hh"
ParameterWidget::ParameterWidget(QWidget* _parent)
: QWidget(_parent) {
setupUi(this);
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "ui_ParameterWidget.hh"
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
class ParameterWidget : public QWidget, public Ui::ParameterWidget
{
Q_OBJECT
public:
explicit ParameterWidget(QWidget* _parent = 0);
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ParameterWidget</class>
<widget class="QWidget" name="ParameterWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>121</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Flood Fill</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum Angle</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="maxAngle">
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="value">
<double>15.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -48,6 +48,7 @@
\*===========================================================================*/
#include "VolumeMeshSelectionPlugin.hh"
#include "ParameterWidget.hh"
// Primitive type icons
#define VERTEX_TYPE "selection_vertex.png"
......@@ -83,8 +84,8 @@
/// Default constructor
VolumeMeshSelectionPlugin::VolumeMeshSelectionPlugin() :
vertexType_(0), edgeType_(0), allSupportedTypes_(0), lastPickedCell_(HexahedralMesh::InvalidCellHandle),
lastPickedOrientation_(0) {
vertexType_(0), edgeType_(0), allSupportedTypes_(0), parameterWidget_(nullptr), max_angle_(2*M_PI),
lastPickedCell_(HexahedralMesh::InvalidCellHandle), lastPickedOrientation_(0) {
}
//==============================================================================================
......@@ -98,6 +99,8 @@ void VolumeMeshSelectionPlugin::initializePlugin() {
// Tell core about all scriptable slots
updateSlotDescriptions();
if(!OpenFlipper::Options::nogui())
parameterWidget_ = new ParameterWidget(nullptr);
}
//==============================================================================================
......@@ -177,6 +180,9 @@ void VolumeMeshSelectionPlugin::pluginsInitialized() {
emit
addSelectionOperations(environmentHandle_, cellOperations, "Cell Operations", cellType_);
if(!OpenFlipper::Options::nogui())
emit addSelectionParameters(environmentHandle_, parameterWidget_, "Selection Parameters");
// Register key shortcuts:
// Select (a)ll
......@@ -488,7 +494,7 @@ void VolumeMeshSelectionPlugin::slotVolumeLassoSelection(QMouseEvent* _event,
}
void VolumeMeshSelectionPlugin::slotFloodFillSelection(QMouseEvent* _event,
double _maxAngle, PrimitiveType _currentType, bool _deselect)
PrimitiveType _currentType, bool _deselect)
{
// Return if none of the currently active types is handled by this plugin
if ((_currentType & floodFillSupportedTypes_) == 0)
......@@ -497,6 +503,8 @@ void VolumeMeshSelectionPlugin::slotFloodFillSelection(QMouseEvent* _event,
size_t node_idx, target_idx;
ACG::Vec3d hit_point;
if(!OpenFlipper::Options::nogui())
max_angle_ = parameterWidget_->maxAngle->value();
// pick Anything to find all possible objects
if (PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING,
_event->pos(), node_idx, target_idx, &hit_point))
......@@ -515,7 +523,7 @@ void VolumeMeshSelectionPlugin::slotFloodFillSelection(QMouseEvent* _event,
if (object->dataType(DATA_POLYHEDRAL_MESH))
{
floodFillSelection(PluginFunctions::polyhedralMesh(object),
target_idx, _maxAngle, _currentType, _deselect);
target_idx, max_angle_, _currentType, _deselect);//TODO max angle
emit updatedObject(object->id(), UPDATE_SELECTION);
}
......@@ -532,7 +540,7 @@ void VolumeMeshSelectionPlugin::slotFloodFillSelection(QMouseEvent* _event,
if(object->dataType(DATA_HEXAHEDRAL_MESH))
{
floodFillSelection(PluginFunctions::hexahedralMesh(object),
target_idx, _maxAngle, _currentType, _deselect);
target_idx, max_angle_, _currentType, _deselect);
emit updatedObject(object->id(), UPDATE_SELECTION);
}
......@@ -550,7 +558,7 @@ void VolumeMeshSelectionPlugin::slotFloodFillSelection(QMouseEvent* _event,
if(object->dataType(DATA_TETRAHEDRAL_MESH))
{
floodFillSelection(PluginFunctions::tetrahedralMesh(object),
target_idx, _maxAngle, _currentType, _deselect);
target_idx, max_angle_, _currentType, _deselect);
emit updatedObject(object->id(), UPDATE_SELECTION);
}
......@@ -847,6 +855,16 @@ OpenVolumeMesh::StatusAttrib* VolumeMeshSelectionPlugin::getStatus(BaseObjectDat
return NULL;
}
void VolumeMeshSelectionPlugin::set_max_angle(const double _a)
{
max_angle_ = _a;
}
double VolumeMeshSelectionPlugin::get_max_angle()
{
return max_angle_;
}
//==============================================================================================
void VolumeMeshSelectionPlugin::loadSelection(int _objId, const QString& _filename) {
......
......@@ -72,6 +72,8 @@
#include <ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh>
#endif
class ParameterWidget;
class VolumeMeshSelectionPlugin : public QObject, BaseInterface, KeyInterface,
INIInterface, BackupInterface, LoggingInterface, ScriptInterface, SelectionInterface
{
......@@ -98,6 +100,11 @@ public:
friend class SelectVolumeAction;
/// set max angle for flood fill selection
void set_max_angle(const double _a);
/// get max angle for flood fill selection
double get_max_angle();
signals:
// BaseInterface
......@@ -119,6 +126,7 @@ signals:
void registerType(QString _handleName, DataType _type);
void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
void addSelectionParameters(QString _handleName, QWidget* _widget, QString _category, SelectionInterface::PrimitiveType _type = 0u);
void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
......@@ -149,7 +157,7 @@ private slots:
void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotFloodFillSelection(QMouseEvent* _event, double _maxAngle, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotFloodFillSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
void slotCustomSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier, bool _deselect);
void slotLoadSelection(const INIFile& _file);
......@@ -366,6 +374,10 @@ private:
PrimitiveType allSupportedTypes_;
PrimitiveType floodFillSupportedTypes_;
ParameterWidget* parameterWidget_;
double max_angle_;
/// Keep volume lasso points
QVector<QPoint> volumeLassoPoints_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment