X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGeometryGUI.cxx;h=3a786e03a0dcc00bb19bfcdce72b1e2bccaead11;hb=c9f33420c0a3ff3a3b9602adeb05401e9adc7347;hp=e23e3f185da7dd4a7ada2bb23ad7c03401d832aa;hpb=6e9871bc532e543f4539feebfb029cad2a187490;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e23e3f185..3a786e03a 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -31,6 +31,7 @@ #include "GeometryGUI_Operations.h" #include "GEOMGUI_OCCSelector.h" #include "GEOMGUI_Selection.h" +#include "GEOMGUI_CreationInfoWdg.h" #include "GEOM_Constants.h" #include "GEOM_Displayer.h" #include "GEOM_AISShape.hxx" @@ -107,9 +108,11 @@ #include #include -#include +#include +#include -#include "GEOMImpl_Types.hxx" +#include "GEOM_version.h" +#include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all extern "C" { Standard_EXPORT CAM_Module* createModule() { @@ -208,6 +211,8 @@ GeometryGUI::GeometryGUI() : myDisplayer = 0; myLocalSelectionMode = GEOM_ALLOBJECTS; + myCreationInfoWdg = 0; + connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) ); } @@ -542,8 +547,10 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE + case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES + case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES libName = "RepairGUI"; break; case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES @@ -582,6 +589,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER + case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// libName = "AdvancedGUI"; break; @@ -608,6 +616,8 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) } else SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) ); + + updateCreationInfo(); } //================================================================================= @@ -705,7 +715,7 @@ void GeometryGUI::createOriginAndBaseVectors() GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" ); GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" ); - getApp()->updateObjectBrowser( false ); + getApp()->updateObjectBrowser( true ); } } } @@ -821,8 +831,10 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" ); createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" ); createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" ); + createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" ); createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" ); createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" ); + createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" ); createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" ); createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" ); @@ -906,6 +918,7 @@ void GeometryGUI::initialize( CAM_Application* app ) // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" ); createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); + createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create menus -------------------------- @@ -955,9 +968,9 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpPipePath, genId, -1 ); #endif -// int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); - - //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// + int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 ); + createMenu( GEOMOp::OpSmoothingSurface, advId, -1 ); + //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// createMenu( separator(), newEntId, -1 ); @@ -1051,8 +1064,10 @@ void GeometryGUI::initialize( CAM_Application* app ) //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 ); //createMenu( GEOMOp::OpFreeFaces, repairId, -1 ); createMenu( GEOMOp::OpOrientation, repairId, -1 ); + createMenu( GEOMOp::OpRemoveWebs, repairId, -1 ); createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 ); createMenu( GEOMOp::OpFuseEdges, repairId, -1 ); + createMenu( GEOMOp::OpUnionFaces, repairId, -1 ); int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 ); createMenu( GEOMOp::OpPointCoordinates, measurId, -1 ); @@ -1231,8 +1246,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpFeatureDetect, picturesTbId ); #endif -// int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); - + int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); + createTool( GEOMOp::OpSmoothingSurface, advancedTbId ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create popup menus -------------------------- @@ -1442,6 +1457,12 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) LightApp_SelectionMgr* sm = getApp()->selectionMgr(); + connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() )); + if ( !myCreationInfoWdg ) + myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() ); + getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg ); + getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea ); + SUIT_ViewManager* vm; ViewManagerList OCCViewManagers, VTKViewManagers; @@ -1513,6 +1534,12 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); + LightApp_SelectionMgr* selMrg = getApp()->selectionMgr(); + + disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() )); + getApp()->removeDockWindow( myCreationInfoWdg->getWinID() ); + myCreationInfoWdg = 0; + EmitSignalCloseAllDialogs(); GUIMap::Iterator it; @@ -1526,11 +1553,11 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) qDeleteAll(myOCCSelectors); myOCCSelectors.clear(); - getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() ); + selMrg->setEnabled( true, OCCViewer_Viewer::Type() ); qDeleteAll(myVTKSelectors); myVTKSelectors.clear(); - getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() ); + selMrg->setEnabled( true, SVTK_Viewer::Type() ); return SalomeApp_Module::deactivateModule( study ); } @@ -1566,6 +1593,8 @@ void GeometryGUI::windows( QMap& mappa ) const { mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); + if ( myCreationInfoWdg ) + mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea ); } void GeometryGUI::viewManagers( QStringList& lst ) const @@ -1638,6 +1667,78 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) } } +//================================================================================ +/*! + * \brief Slot called when selection changed. Shows creation info of a selected object + */ +//================================================================================ + +void GeometryGUI::updateCreationInfo() +{ + myCreationInfoWdg->clear(); + + // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again + // if ( !myCreationInfoWdg->isVisible() ) + // return; + + // look for a sole selected GEOM_Object + GEOM::GEOM_Object_var geomObj; + + SALOME_ListIO selected; + getApp()->selectionMgr()->selectedObjects( selected ); + + _PTR(Study) study = dynamic_cast( getApp()->activeStudy() )->studyDS(); + SALOME_ListIteratorOfListIO selIt( selected ); + for ( ; selIt.More(); selIt.Next() ) + { + Handle(SALOME_InteractiveObject) io = selIt.Value(); + if ( !io->hasEntry() ) continue; + _PTR(SObject) sobj = study->FindObjectID( io->getEntry() ); + if ( !sobj ) continue; + CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj ); + GEOM::GEOM_Object_var gobj = GEOM::GEOM_Object::_narrow( obj ); + if ( !gobj->_is_nil() ) + { + if ( !geomObj->_is_nil() ) + return; // several GEOM objects selected + geomObj = gobj; + } + } + if ( geomObj->_is_nil() ) return; + + // pass creation info of geomObj to myCreationInfoWdg + + QPixmap icon; + QString operationName; + myCreationInfoWdg->setOperation( icon, operationName ); + + try + { + OCC_CATCH_SIGNALS; + GEOM::CreationInformation_var info = geomObj->GetCreationInformation(); + if ( &info.in() ) + { + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + QString name = info->operationName.in(); + if ( !name.isEmpty() ) + { + icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false ); + operationName = tr( ("MEN_"+name).toLatin1().constData() ); + if ( operationName.startsWith( "MEN_" )) + operationName = name; // no translation + myCreationInfoWdg->setOperation( icon, operationName ); + + for ( size_t i = 0; i < info->params.length(); ++i ) + myCreationInfoWdg->addParam( info->params[i].name.in(), + info->params[i].value.in() ); + } + } + } + catch (...) + { + } +} + QString GeometryGUI::engineIOR() const { if ( !CORBA::is_nil( GetGeomGen() ) ) @@ -1737,10 +1838,10 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& // Set checked if this material is current Material_Model aModel; aModel.fromResources( material ); - if ( !found && aModel.toProperties() == curModel ) { - menAct->setChecked( true ); - found = true; - } + if ( !found && aModel.toProperties() == curModel ) { + menAct->setChecked( true ); + found = true; + } } matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) ); matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) ); @@ -1814,11 +1915,11 @@ void GeometryGUI::createPreferences() LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup, - LightApp_Preferences::Bool, "Geometry", "predef_materials" ); + LightApp_Preferences::Bool, "Geometry", "predef_materials" ); int material = addPreference( tr( "PREF_MATERIAL" ), genGroup, - LightApp_Preferences::Selector, - "Geometry", "material" ); + LightApp_Preferences::Selector, + "Geometry", "material" ); addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup, LightApp_Preferences::Color, "Geometry", "editgroup_color" ); @@ -2095,10 +2196,10 @@ void GeometryGUI::storeVisualParameters (int savePoint) if (aProps.contains(GEOM::propertyName( GEOM::Color ))) { QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value(); - QStringList val; - val << QString::number(c.redF()); - val << QString::number(c.greenF()); - val << QString::number(c.blueF()); + QStringList val; + val << QString::number(c.redF()); + val << QString::number(c.greenF()); + val << QString::number(c.blueF()); param = occParam + GEOM::propertyName( GEOM::Color ); ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString()); } @@ -2241,7 +2342,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() ); } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) { - aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1"); + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1"); } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt()); } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) { @@ -2514,7 +2615,7 @@ void GeometryGUI::updateMaterials() QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true ); if ( prefItem ) { setPreferenceProperty( prefItem->id(), - "strings", materials ); + "strings", materials ); prefItem->retrieve(); } }