Commit 7aa601d6 authored by Mike Kremer's avatar Mike Kremer
Browse files

Cleaned up a bit!

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6472 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ae8a5d77
...@@ -325,27 +325,24 @@ bool SelectionPlugin::initializeToolbox(QWidget*& _widget) ...@@ -325,27 +325,24 @@ bool SelectionPlugin::initializeToolbox(QWidget*& _widget)
// Set combo box entries for the different modes // Set combo box entries for the different modes
tool_->convertFrom->addItem("Modeling Area"); tool_->convertFrom->addItem("Modeling Area");
tool_->convertFrom->addItem("Handle Region"); tool_->convertFrom->addItem("Handle Area");
tool_->convertFrom->addItem("Feature"); tool_->convertFrom->addItem("Feature Area");
tool_->convertTo->addItem("Modeling Area"); tool_->convertTo->addItem("Modeling Area");
tool_->convertTo->addItem("Handle Region"); tool_->convertTo->addItem("Handle Area");
tool_->convertTo->addItem("Feature"); tool_->convertTo->addItem("Feature Area");
// Convert button
connect(tool_->convertButton, SIGNAL(clicked()), this, SLOT(slotConvertSelectionType()));
// Set combo box entries for the different selection types // Set combo box entries for the different selection types
tool_->convertSelectionFrom->addItem("Vertex Selection"); tool_->convertFrom->addItem("Vertex Selection");
tool_->convertSelectionFrom->addItem("Edge Selection"); tool_->convertFrom->addItem("Edge Selection");
tool_->convertSelectionFrom->addItem("Face Selection"); tool_->convertFrom->addItem("Face Selection");
tool_->convertSelectionTo->addItem("Vertex Selection"); tool_->convertTo->addItem("Vertex Selection");
tool_->convertSelectionTo->addItem("Edge Selection"); tool_->convertTo->addItem("Edge Selection");
tool_->convertSelectionTo->addItem("Face Selection"); tool_->convertTo->addItem("Face Selection");
// Convert button // Convert button
connect(tool_->convertSelectionButton, SIGNAL(clicked()), this, SLOT(slotConvertSelection())); connect(tool_->convertButton, SIGNAL(clicked()), this, SLOT(slotConvertSelectionType()));
connect (tool_->restrictOnTargets, SIGNAL(clicked()), this, SLOT(slotToggleSelectionRestriction()) ); connect (tool_->restrictOnTargets, SIGNAL(clicked()), this, SLOT(slotToggleSelectionRestriction()) );
...@@ -364,11 +361,7 @@ bool SelectionPlugin::initializeToolbox(QWidget*& _widget) ...@@ -364,11 +361,7 @@ bool SelectionPlugin::initializeToolbox(QWidget*& _widget)
connect( tool_->loadSelection, SIGNAL(clicked()), this,SLOT(slotLoadSelection()) ); connect( tool_->loadSelection, SIGNAL(clicked()), this,SLOT(slotLoadSelection()) );
connect( tool_->saveSelection, SIGNAL(clicked()), this,SLOT(slotSaveSelection()) ); connect( tool_->saveSelection, SIGNAL(clicked()), this,SLOT(slotSaveSelection()) );
//Mesh Properties //Clear Mesh Properties
connect( tool_->setModelingArea, SIGNAL(clicked()), this,SLOT(slotSetArea()) );
connect( tool_->setHandleRegion, SIGNAL(clicked()), this,SLOT(slotSetHandle()) );
connect( tool_->setFeatures, SIGNAL(clicked()), this,SLOT(slotSetFeatures()) );
connect( tool_->clearModelingArea, SIGNAL(clicked()), this,SLOT(slotClearArea()) ); connect( tool_->clearModelingArea, SIGNAL(clicked()), this,SLOT(slotClearArea()) );
connect( tool_->clearHandleRegion, SIGNAL(clicked()), this,SLOT(slotClearHandle())); connect( tool_->clearHandleRegion, SIGNAL(clicked()), this,SLOT(slotClearHandle()));
connect( tool_->clearFeatures, SIGNAL(clicked()), this,SLOT(slotClearFeatures())); connect( tool_->clearFeatures, SIGNAL(clicked()), this,SLOT(slotClearFeatures()));
...@@ -605,12 +598,23 @@ void SelectionPlugin::slotSetArea() { ...@@ -605,12 +598,23 @@ void SelectionPlugin::slotSetArea() {
for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ; for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
set_area(PluginFunctions::triMesh(*o_it)); // Add selection to existing modeling area
if ( o_it->dataType( DATA_POLY_MESH ) ) // if corresponding checkbox is checked
set_area(PluginFunctions::polyMesh(*o_it)); if (tool_->checkAddArea->checkState() == Qt::Checked) {
o_it->update(); idList list = getModelingVertices(o_it->id());
} selectVertices(o_it->id(), list);
}
if (o_it->dataType(DATA_TRIANGLE_MESH)) {
set_area(PluginFunctions::triMesh(*o_it));
}
if (o_it->dataType(DATA_POLY_MESH)) {
set_area(PluginFunctions::polyMesh(*o_it));
}
o_it->update();
}
emit updateView(); emit updateView();
} }
...@@ -630,14 +634,22 @@ void SelectionPlugin::slotSetHandle() { ...@@ -630,14 +634,22 @@ void SelectionPlugin::slotSetHandle() {
for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ; for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
set_handle(PluginFunctions::triMesh(*o_it));
if ( o_it->dataType( DATA_POLY_MESH ) )
set_handle(PluginFunctions::polyMesh(*o_it));
o_it->update();
}
emit updateView(); // Add selection to existing handle area
// if corresponding checkbox is checked
if (tool_->checkAddArea->checkState() == Qt::Checked) {
idList list = getHandleVertices(o_it->id());
selectVertices(o_it->id(), list);
}
if (o_it->dataType(DATA_TRIANGLE_MESH))
set_handle(PluginFunctions::triMesh(*o_it));
if (o_it->dataType(DATA_POLY_MESH))
set_handle(PluginFunctions::polyMesh(*o_it));
o_it->update();
}
emit updateView();
} }
...@@ -647,22 +659,23 @@ void SelectionPlugin::slotSetHandle() { ...@@ -647,22 +659,23 @@ void SelectionPlugin::slotSetHandle() {
/** \brief convert current selection to feature /** \brief convert current selection to feature
*/ */
void SelectionPlugin::slotSetFeatures() { void SelectionPlugin::slotSetFeatures() {
PluginFunctions::IteratorRestriction restriction; PluginFunctions::IteratorRestriction restriction;
if ( !tool_->restrictOnTargets->isChecked() ) if (!tool_->restrictOnTargets->isChecked())
restriction = PluginFunctions::ALL_OBJECTS; restriction = PluginFunctions::ALL_OBJECTS;
else else
restriction = PluginFunctions::TARGET_OBJECTS; restriction = PluginFunctions::TARGET_OBJECTS;
for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ; for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_TRIANGLE_MESH | DATA_POLY_MESH)); o_it
o_it != PluginFunctions::objectsEnd(); ++o_it) { != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
set_features(PluginFunctions::triMesh(*o_it));
if ( o_it->dataType( DATA_POLY_MESH ) )
set_features(PluginFunctions::polyMesh(*o_it));
o_it->update();
}
emit updateView(); if (o_it->dataType(DATA_TRIANGLE_MESH))
set_features(PluginFunctions::triMesh(*o_it));
if (o_it->dataType(DATA_POLY_MESH))
set_features(PluginFunctions::polyMesh(*o_it));
o_it->update();
}
emit updateView();
} }
//****************************************************************************** //******************************************************************************
...@@ -937,57 +950,59 @@ void SelectionPlugin::loadIniFile( INIFile& _ini, int _id ) ...@@ -937,57 +950,59 @@ void SelectionPlugin::loadIniFile( INIFile& _ini, int _id )
void SelectionPlugin::slotConvertSelectionType() { void SelectionPlugin::slotConvertSelectionType() {
StatusBits from, to; QString sfrom, sto;
// Default: Modeling Area sfrom = tool_->convertFrom->currentText();
from = to = AREA; sto = tool_->convertTo->currentText();
if(tool_->convertFrom->currentText() == tr("Handle Region")) { // Clear selection after selection conversion
from = HANDLEAREA; bool unselectAfter = tool_->checkSelectionConvert->checkState() == Qt::Checked;
} // Clear area after area conversion
// Feature still to be implemented bool clearAfter = tool_->checkConvert->checkState() == Qt::Checked;
else if(tool_->convertTo->currentText() == tr("Handle Region")) { if(sfrom == tr("Vertex Selection") && sto == tr("Edge Selection")) {
to = HANDLEAREA; convertVtoESelection(unselectAfter);
} }
// Feature still to be implemented else if(sfrom == tr("Vertex Selection") && sto == tr("Face Selection")) {
convertVtoFSelection(unselectAfter);
convertSelectionType(from, to);
}
//******************************************************************************
void SelectionPlugin::slotConvertSelection() {
QString from, to;
from = tool_->convertSelectionFrom->currentText();
to = tool_->convertSelectionTo->currentText();
if(from == tr("Vertex Selection") && to == tr("Edge Selection")) {
convertVtoESelection();
} }
else if(from == tr("Vertex Selection") && to == tr("Face Selection")) { else if(sfrom == tr("Edge Selection") && sto == tr("Vertex Selection")) {
convertVtoFSelection(); convertEtoVSelection(unselectAfter);
} }
else if(from == tr("Edge Selection") && to == tr("Vertex Selection")) { else if(sfrom == tr("Edge Selection") && sto == tr("Face Selection")) {
convertEtoVSelection(); convertEtoFSelection(unselectAfter);
} }
else if(from == tr("Edge Selection") && to == tr("Face Selection")) { else if(sfrom == tr("Face Selection") && sto == tr("Vertex Selection")) {
convertEtoFSelection(); convertFtoVSelection(unselectAfter);
} }
else if(from == tr("Face Selection") && to == tr("Vertex Selection")) { else if(sfrom == tr("Face Selection") && sto == tr("Edge Selection")) {
convertFtoVSelection(); convertFtoESelection(unselectAfter);
} }
else if(from == tr("Face Selection") && to == tr("Edge Selection")) { else if(sfrom == tr("Modeling Area") && sto == tr("Handle Area")) {
convertFtoESelection(); StatusBits from = AREA;
StatusBits to = HANDLEAREA;
convertSelectionType(from, to, clearAfter);
} }
else if(sfrom == tr("Handle Area") && sto == tr("Modeling Area")) {
StatusBits from = HANDLEAREA;
StatusBits to = AREA;
convertSelectionType(from, to, clearAfter);
}
else if(sfrom == tr("Vertex Selection") && sto == tr("Modeling Area")) {
slotSetArea();
}
else if(sfrom == tr("Vertex Selection") && sto == tr("Handle Area")) {
slotSetHandle();
}
else if(sfrom == tr("Vertex Selection") && sto == tr("Feature Area")) {
slotSetFeatures();
}
// Feature still to be implemented
} }
//****************************************************************************** //******************************************************************************
void SelectionPlugin::convertSelectionType(StatusBits from, StatusBits to) { void SelectionPlugin::convertSelectionType(StatusBits _from, StatusBits _to, bool _clearAfter) {
PluginFunctions::IteratorRestriction restriction; PluginFunctions::IteratorRestriction restriction;
if ( !tool_->restrictOnTargets->isChecked() ) { if ( !tool_->restrictOnTargets->isChecked() ) {
...@@ -997,25 +1012,39 @@ void SelectionPlugin::convertSelectionType(StatusBits from, StatusBits to) { ...@@ -997,25 +1012,39 @@ void SelectionPlugin::convertSelectionType(StatusBits from, StatusBits to) {
restriction = PluginFunctions::TARGET_OBJECTS; restriction = PluginFunctions::TARGET_OBJECTS;
} }
if(from == AREA && to == HANDLEAREA) { if(_from == AREA && _to == HANDLEAREA) {
for ( PluginFunctions::ObjectIterator o_it(restriction, DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )); for ( PluginFunctions::ObjectIterator o_it(restriction, DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH ));
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
// Delete current handle region if
// checkbox "Add to area" is NOT checked
if (tool_->checkAddArea->checkState() != Qt::Checked &&
selectionType_ == VERTEX) {
clearHandleVertices(o_it->id());
}
idList list = getModelingVertices(o_it->id()); idList list = getModelingVertices(o_it->id());
clearModelingVertices(o_it->id()); if(_clearAfter) { clearModelingVertices(o_it->id()); }
selectHandleVertices(o_it->id(), list); selectHandleVertices(o_it->id(), list);
o_it->update(); o_it->update();
} }
} }
else if(from == HANDLEAREA && to == AREA) { else if(_from == HANDLEAREA && _to == AREA) {
for ( PluginFunctions::ObjectIterator o_it(restriction, DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )); for ( PluginFunctions::ObjectIterator o_it(restriction, DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH ));
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
// Delete current modeling area if
// checkbox "Add to area" is NOT checked
if (tool_->checkAddArea->checkState() != Qt::Checked &&
selectionType_ == VERTEX) {
clearModelingVertices(o_it->id());
}
idList list = getHandleVertices(o_it->id()); idList list = getHandleVertices(o_it->id());
clearHandleVertices(o_it->id()); if(_clearAfter) { clearHandleVertices(o_it->id()); }
selectModelingVertices(o_it->id(), list); selectModelingVertices(o_it->id(), list);
o_it->update(); o_it->update();
......
...@@ -339,9 +339,6 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter ...@@ -339,9 +339,6 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
/// Convert selection types (modeling area, handle region or feature) /// Convert selection types (modeling area, handle region or feature)
void slotConvertSelectionType(); void slotConvertSelectionType();
/// Convert selection types (vertex, edge or face selection)
void slotConvertSelection();
/** @} */ /** @} */
...@@ -492,7 +489,7 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter ...@@ -492,7 +489,7 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
//====================================================== //======================================================
/// Convert selection types (modeling area, handle region or feature) /// Convert selection types (modeling area, handle region or feature)
void convertSelectionType(StatusBits from, StatusBits to); void convertSelectionType(StatusBits _from, StatusBits _to, bool _clearAfter);
/// Convert selections (vertex, edge, face) /// Convert selections (vertex, edge, face)
void convertSelection(); void convertSelection();
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string> Selection Mode </string> <string> Selection Mode </string>
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string> Selection </string> <string> Selection </string>
...@@ -307,77 +307,20 @@ ...@@ -307,77 +307,20 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string> Mesh Properties </string> <string> Mesh Properties </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QGridLayout" name="gridLayout_2">
<item> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Convert Selection to:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="setModelingArea">
<property name="toolTip">
<string>Convert the selection of all (target) objects to a modeling area</string>
</property>
<property name="statusTip">
<string>Convert the selection of all (target) objects to a modeling area</string>
</property>
<property name="text">
<string>Modeling Area</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setHandleRegion">
<property name="toolTip">
<string>Convert the selection of all (target) objects to a handle region</string>
</property>
<property name="statusTip">
<string>Convert the selection of all (target) objects to a handle region</string>
</property>
<property name="text">
<string>Handle Region</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setFeatures">
<property name="toolTip">
<string>Convert the selection of all (target) objects to a feature</string>
</property>
<property name="statusTip">
<string>Convert the selection of all (target) objects to a feature</string>
</property>
<property name="text">
<string>Feature</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
...@@ -431,14 +374,14 @@ ...@@ -431,14 +374,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="3" column="0">
<widget class="Line" name="line_4"> <widget class="Line" name="line_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="4" column="0">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
...@@ -453,12 +396,36 @@ ...@@ -453,12 +396,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkAddArea">
<property name="text">
<string>Add to existing area</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkConvert">
<property name="text">
<string>Clear source area after conversion</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkSelectionConvert">
<property name="text">
<string>Clear source selection after conversion</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QComboBox" name="convertFrom"> <widget class="QComboBox" name="convertFrom">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -484,12 +451,6 @@ ...@@ -484,12 +451,6 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer> </spacer>
</item> </item>
<item> <item>
...@@ -510,24 +471,12 @@ ...@@ -510,24 +471,12 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer> </spacer>