Commit 75a7e079 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

reworked ui

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5331 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 81cb527f
......@@ -528,7 +528,7 @@ bool SelectionPlugin::volumeSelection(MeshT* _mesh, ACG::GLState& _state, QRegio
typename MeshT::VertexIter v_it, v_end( _mesh->vertices_end() );
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it)
_mesh->status(v_it).set_tagged(false);
printf("Volume selection\n");
//tag all vertives that are projected into region
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it)
{
......
......@@ -241,6 +241,19 @@ void SelectionPlugin::pluginsInitialized() {
connect( toolBarActions_, SIGNAL( triggered(QAction*) ), this, SLOT(toolBarActionClicked(QAction*)) );
connect( toolBarTypes_, SIGNAL( triggered(QAction*) ), this, SLOT(toolBarActionClicked(QAction*)) );
//connect the toolbar Actions to the Toolbox Buttons
connect( tool_->objectSelection, SIGNAL(clicked(bool)), objectAction_, SLOT(setChecked(bool)) );
connect( tool_->vertexSelection, SIGNAL(clicked(bool)), vertexAction_, SLOT(setChecked(bool)) );
connect( tool_->edgeSelection, SIGNAL(clicked(bool)), edgeAction_, SLOT(setChecked(bool)) );
connect( tool_->faceSelection, SIGNAL(clicked(bool)), faceAction_, SLOT(setChecked(bool)) );
connect( objectAction_, SIGNAL(toggled(bool)),tool_->objectSelection , SLOT(setChecked(bool)) );
connect( vertexAction_, SIGNAL(toggled(bool)),tool_->vertexSelection , SLOT(setChecked(bool)) );
connect( edgeAction_, SIGNAL(toggled(bool)),tool_->edgeSelection , SLOT(setChecked(bool)) );
connect( faceAction_, SIGNAL(toggled(bool)),tool_->faceSelection , SLOT(setChecked(bool)) );
}
//***********************************************************************************
......@@ -296,36 +309,39 @@ bool SelectionPlugin::initializeToolbox(QWidget*& _widget)
QSize size(300, 300);
tool_->resize(size);
connect( tool_->selectBoundaryVerticesButton,SIGNAL(clicked()), this,SLOT(slotSelectBoundaryVertices()) );
connect( tool_->selectBoundaryFacesButton,SIGNAL(clicked()), this,SLOT(slotSelectBoundaryFaces()) );
//Selection Mode
QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
tool_->objectSelection->setIcon( QIcon(iconPath + "selection_object.png") );
tool_->vertexSelection->setIcon( QIcon(iconPath + "selection_vertex.png") );
tool_->edgeSelection->setIcon( QIcon(iconPath + "selection_edge.png") );
tool_->faceSelection->setIcon( QIcon(iconPath + "selection_face.png") );
connect (tool_->restrictOnTargets, SIGNAL(clicked()), this, SLOT(slotToggleSelectionRestriction()) );
connect( tool_->clearVertexSelectionButton ,SIGNAL(clicked()), this,SLOT(slotClearVertexSelection()) );
connect( tool_->clearFaceSelectionButton ,SIGNAL(clicked()), this,SLOT(slotClearFaceSelection()) );
//Selection Buttons
connect( tool_->selectAll, SIGNAL(clicked()), this,SLOT(slotSelectAll()) );
connect( tool_->clearSelection, SIGNAL(clicked()), this,SLOT(slotClearSelection()) );
connect( tool_->selectAllVerticesButton ,SIGNAL(clicked()), this,SLOT(slotSelectAllVertices()) );
connect( tool_->selectAllFacesButton ,SIGNAL(clicked()), this,SLOT(slotSelectAllFaces()) );
connect( tool_->growSelection, SIGNAL(clicked()), this,SLOT(slotGrowSelection()) );
connect( tool_->shrinkSelection, SIGNAL(clicked()), this,SLOT(slotShrinkSelection()) );
connect( tool_->invertVertexSelectionButton ,SIGNAL(clicked()), this,SLOT(slotInvertVertexSelection()) );
connect( tool_->invertFaceSelectionButton ,SIGNAL(clicked()), this,SLOT(slotInvertFaceSelection()) );
connect( tool_->invertSelection, SIGNAL(clicked()), this,SLOT(slotInvertSelection()) );
connect( tool_->selectBoundary, SIGNAL(clicked()), this,SLOT(slotSelectBoundary()) );
connect( tool_->growVertexSelectionButton ,SIGNAL(clicked()), this,SLOT(slotGrowVertexSelection()) );
connect( tool_->growFaceSelectionButton ,SIGNAL(clicked()), this,SLOT(slotGrowFaceSelection()) );
connect( tool_->deleteSelection, SIGNAL(clicked()), this,SLOT(slotDeleteSelection()) );
connect( tool_->shrinkVertexSelectionButton ,SIGNAL(clicked()), this,SLOT(slotShrinkVertexSelection()) );
connect( tool_->shrinkFaceSelectionButton ,SIGNAL(clicked()), this,SLOT(slotShrinkFaceSelection()) );
connect( tool_->loadSelection, SIGNAL(clicked()), this,SLOT(slotLoadSelection()) );
connect( tool_->saveSelection, SIGNAL(clicked()), this,SLOT(slotSaveSelection()) );
connect( tool_->setAreaButton ,SIGNAL(clicked()), this,SLOT(slotSetArea()) );
connect( tool_->setHandleButton ,SIGNAL(clicked()), this,SLOT(slotSetHandle()) );
connect( tool_->clearAreaButton ,SIGNAL(clicked()), this,SLOT(slotClearArea()) );
connect( tool_->clearHandleButton ,SIGNAL(clicked()), this,SLOT(slotClearHandle()));
// connect( tool_->saveModelingArea ,SIGNAL(clicked()), this,SLOT(slotSaveModelingArea()));
// connect( tool_->loadModelingArea ,SIGNAL(clicked()), this,SLOT(slotLoadModelingArea()));
// connect( tool_->saveHandleRegion ,SIGNAL(clicked()), this,SLOT(slotSaveHandleRegion()));
// connect( tool_->loadHandleRegion ,SIGNAL(clicked()), this,SLOT(slotLoadHandleRegion()));
// connect( tool_->saveSelection ,SIGNAL(clicked()), this,SLOT(slotSaveSelection()));
// connect( tool_->loadSelection ,SIGNAL(clicked()), this,SLOT(slotLoadSelection()));
// connect( tool_->saveSelectionFaces ,SIGNAL(clicked()), this,SLOT(slotSaveFaceSelection()));
// connect( tool_->loadSelectionFaces ,SIGNAL(clicked()), this,SLOT(slotLoadFaceSelection()));
//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_->clearHandleRegion, SIGNAL(clicked()), this,SLOT(slotClearHandle()));
connect( tool_->clearFeatures, SIGNAL(clicked()), this,SLOT(slotClearFeatures()));
return true;
}
......@@ -544,7 +560,7 @@ void SelectionPlugin::toolBarActionClicked(QAction * _action)
*/
void SelectionPlugin::slotSetArea() {
PluginFunctions::IteratorRestriction restriction;
if ( tool_->selectOnAll->isChecked() )
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
......@@ -569,7 +585,7 @@ void SelectionPlugin::slotSetArea() {
*/
void SelectionPlugin::slotSetHandle() {
PluginFunctions::IteratorRestriction restriction;
if ( tool_->selectOnAll->isChecked() )
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
......@@ -590,11 +606,35 @@ void SelectionPlugin::slotSetHandle() {
//******************************************************************************
/** \brief convert current selection to feature
*/
void SelectionPlugin::slotSetFeatures() {
PluginFunctions::IteratorRestriction restriction;
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ;
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();
}
//******************************************************************************
/** \brief Clear Handle Bits
*/
void SelectionPlugin::slotClearHandle() {
PluginFunctions::IteratorRestriction restriction;
if ( tool_->selectOnAll->isChecked() )
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
......@@ -618,7 +658,7 @@ void SelectionPlugin::slotClearHandle() {
*/
void SelectionPlugin::slotClearArea() {
PluginFunctions::IteratorRestriction restriction;
if ( tool_->selectOnAll->isChecked() )
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
......@@ -636,13 +676,36 @@ void SelectionPlugin::slotClearArea() {
}
//******************************************************************************
/** \brief Clear Features
*/
void SelectionPlugin::slotClearFeatures() {
PluginFunctions::IteratorRestriction restriction;
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
for ( PluginFunctions::ObjectIterator o_it(restriction,DataType( DATA_TRIANGLE_MESH | DATA_POLY_MESH )) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
clear_features(PluginFunctions::triMesh(*o_it));
if ( o_it->dataType( DATA_POLY_MESH ) )
clear_features(PluginFunctions::polyMesh(*o_it));
o_it->update();
}
emit updateView();
}
//******************************************************************************
/** \brief Delete all selected elements of the target meshes
*/
void SelectionPlugin::slotDeleteSelection() {
PluginFunctions::IteratorRestriction restriction;
if ( tool_->selectOnAll->isChecked() )
if ( !tool_->restrictOnTargets->isChecked() )
restriction = PluginFunctions::ALL_OBJECTS;
else
restriction = PluginFunctions::TARGET_OBJECTS;
......@@ -663,6 +726,16 @@ void SelectionPlugin::slotDeleteSelection() {
}
/** \brief Toggle the selection Restriction
*
*/
void SelectionPlugin::slotToggleSelectionRestriction(){
if ( tool_->restrictOnTargets->isChecked() )
tool_->restrictOnTargets->setText("Select on target objects only");
else
tool_->restrictOnTargets->setText("Select on all objects");
}
//******************************************************************************
/** \brief store selections of a given object to a given ini file
......@@ -708,7 +781,7 @@ void SelectionPlugin::saveIniFile( INIFile& _ini , int _id) {
*/
void SelectionPlugin::loadIniFile( INIFile& _ini, int _id )
{
std::cerr << "a" << std::endl;
BaseObjectData* object;
if ( !PluginFunctions::getObject(_id,object) ) {
emit log(LOGERR,"Cannot find object for id " + QString::number(_id) + " in saveFile" );
......
......@@ -197,6 +197,10 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
template< typename MeshType >
void set_handle(MeshType* _mesh);
/// convert current selection to features
template< typename MeshType >
void set_features(MeshType* _mesh);
/// Clear Handle vertices
template< typename MeshType >
void clear_handle(MeshType* _mesh);
......@@ -205,6 +209,10 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
template< typename MeshType >
void clear_area(MeshType* _mesh);
/// Clear Features
template< typename MeshType >
void clear_features(MeshType* _mesh);
/// Delete all selected elements of a mesh
template< typename MeshT >
bool deleteSelection(MeshT* _mesh);
......@@ -270,15 +278,24 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
/// Use current selection to set Handle bits
void slotSetHandle();
/// convert current selection to feature
void slotSetFeatures();
/// Clear Handle Bits
void slotClearHandle();
/// Clear Area Bits
void slotClearArea();
/// Clear Features
void slotClearFeatures();
/// Delete all selected elements of the target meshes
void slotDeleteSelection();
/// Toggle the selection Restriction
void slotToggleSelectionRestriction();
private:
/// Select mesh elements for each object in the list
......@@ -308,45 +325,12 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
/// Grow the current selection
void slotGrowSelection();
//==========================================
/// Select all vertices of the active object
void slotSelectAllVertices();
/// Clear Vertex selection of current objects
void slotClearVertexSelection();
/// Invert the current vertex selection
void slotInvertVertexSelection();
/// Select all vertices which lie on the boundary of the object
void slotSelectBoundaryVertices();
/// load a selection
void slotLoadSelection();
/// Shrink the current vertex selection
void slotShrinkVertexSelection();
/// Grow the current vertex selection
void slotGrowVertexSelection();
//==========================================
/// Select all faces of the active object
void slotSelectAllFaces();
/// Clear Face selection of current objects
void slotClearFaceSelection();
/// Save the current selection
void slotSaveSelection();
/// Invert the current face selection
void slotInvertFaceSelection();
/// Select all Faces which lie on the boundary of the object
void slotSelectBoundaryFaces();
/// Shrink the current face selection
void slotShrinkFaceSelection();
/// Grow the current face selection
void slotGrowFaceSelection();
/** @} */
......
......@@ -90,13 +90,57 @@ template< typename MeshType >
void SelectionPlugin::set_area( MeshType* _mesh)
{
typename MeshType::VertexIter v_it, v_end=_mesh->vertices_end();
if (selectionType_ & VERTEX){
typename MeshType::VertexIter v_it, v_end=_mesh->vertices_end();
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
_mesh->status(v_it).change_bit(AREA, _mesh->status(v_it).selected());
_mesh->status(v_it).set_selected(false);
}
} else {
//reset tagged status
typename MeshType::VertexIter v_it, v_end( _mesh->vertices_end() );
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it)
_mesh->status(v_it).set_tagged(false);
if (selectionType_ & EDGE){
typename MeshType::EdgeIter e_it, e_end( _mesh->edges_end() );
for (e_it=_mesh->edges_begin(); e_it!=e_end; ++e_it){
if ( _mesh->status(e_it).selected() ){
typename MeshType::HalfedgeHandle h0 = _mesh->halfedge_handle(e_it,0);
_mesh->status( _mesh->from_vertex_handle(h0) ).set_tagged(true);
_mesh->status( _mesh->to_vertex_handle(h0) ).set_tagged(true);
_mesh->status(e_it).set_selected(false);
}
}
}
if (selectionType_ & FACE){
typename MeshType::FaceIter f_it, f_end( _mesh->faces_end() );
for (f_it=_mesh->faces_begin(); f_it!=f_end; ++f_it){
if ( _mesh->status(f_it).selected() ){
for (typename MeshType::FaceVertexIter fv_it(*_mesh,f_it) ; fv_it; ++fv_it ){
_mesh->status( fv_it ).set_tagged(true);
_mesh->status(f_it).set_selected(false);
}
}
}
}
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
_mesh->status(v_it).change_bit(AREA, _mesh->status(v_it).selected());
_mesh->status(v_it).set_selected(false);
}
//set area bit for tagged handles
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
_mesh->status(v_it).change_bit(AREA, _mesh->status(v_it).tagged());
_mesh->status(v_it).set_selected(false);
}
}
update_regions(_mesh);
}
......@@ -110,18 +154,126 @@ void SelectionPlugin::set_area( MeshType* _mesh)
template< typename MeshType >
void SelectionPlugin::set_handle(MeshType* _mesh)
{
typename MeshType::VertexIter v_it, v_end=_mesh->vertices_end();
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
if (_mesh->status(v_it).selected()) {
_mesh->status(v_it).change_bit(HANDLEAREA, true);
_mesh->status(v_it).set_selected(false);
if (selectionType_ & VERTEX){
typename MeshType::VertexIter v_it, v_end=_mesh->vertices_end();
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
_mesh->status(v_it).change_bit(HANDLEAREA, _mesh->status(v_it).selected());
_mesh->status(v_it).set_selected(false);
}
} else {
//reset tagged status
typename MeshType::VertexIter v_it, v_end( _mesh->vertices_end() );
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it)
_mesh->status(v_it).set_tagged(false);
if (selectionType_ & EDGE){
typename MeshType::EdgeIter e_it, e_end( _mesh->edges_end() );
for (e_it=_mesh->edges_begin(); e_it!=e_end; ++e_it){
if ( _mesh->status(e_it).selected() ){
typename MeshType::HalfedgeHandle h0 = _mesh->halfedge_handle(e_it,0);
_mesh->status( _mesh->from_vertex_handle(h0) ).set_tagged(true);
_mesh->status( _mesh->to_vertex_handle(h0) ).set_tagged(true);
_mesh->status(e_it).set_selected(false);
}
}
}
if (selectionType_ & FACE){
typename MeshType::FaceIter f_it, f_end( _mesh->faces_end() );
for (f_it=_mesh->faces_begin(); f_it!=f_end; ++f_it){
if ( _mesh->status(f_it).selected() ){
for (typename MeshType::FaceVertexIter fv_it(*_mesh,f_it) ; fv_it; ++fv_it ){
_mesh->status( fv_it ).set_tagged(true);
_mesh->status(f_it).set_selected(false);
}
}
}
}
}
//set area bit for tagged handles
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it) {
_mesh->status(v_it).change_bit(HANDLEAREA, _mesh->status(v_it).tagged());
_mesh->status(v_it).set_selected(false);
}
}
update_regions(_mesh);
}
/** \brief Set current selection as feature for a mesh
*
* @param _mesh a mesh
*/
template< typename MeshType >
void SelectionPlugin::set_features(MeshType* _mesh)
{
if (selectionType_ & VERTEX){
typename MeshType::VertexIter v_it, v_end=_mesh->vertices_end();
for (v_it=_mesh->vertices_begin(); v_it!=v_end; ++v_it){
_mesh->status(v_it).set_feature( _mesh->status(v_it).selected() );
_mesh->status(v_it).set_selected( false );
}
}
if (selectionType_ & EDGE){
typename MeshType::EdgeIter e_it, e_end( _mesh->edges_end() );
for (e_it=_mesh->edges_begin(); e_it!=e_end; ++e_it){
_mesh->status(e_it).set_feature( _mesh->status(e_it).selected() );
_mesh->status(e_it).set_selected( false );
}
}
update_regions(_mesh);
if (selectionType_ & FACE){
typename MeshType::FaceIter f_it, f_end( _mesh->faces_end() );
for (f_it=_mesh->faces_begin(); f_it!=f_end; ++f_it){
_mesh->status(f_it).set_feature( _mesh->status(f_it).selected() );
_mesh->status(f_it).set_selected( false );
}
}
}
/** \brief Clear the features of a mesh
*
* @param _mesh a mesh
*/
template< typename MeshType >
void SelectionPlugin::clear_features(MeshType* _mesh)
{