X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGeometryGUI.cxx;h=f94d3902d8c10921d60dcc65205651e5bdcdd0f6;hb=2dbe613765884256942925d8a95293e3c473caec;hp=3f462d90d08a8fcecfb42519b9a97aff5dc9c094;hpb=49047f7d298f22733ce9bb55676486c1e7115855;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 3f462d90d..f94d3902d 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1,30 +1,27 @@ -// GEOM GEOMGUI : GUI for Geometry component +// GEOM GEOMGUI : GUI for Geometry component // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library 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 2.1 of the License. +// This library 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 2.1 of the License. // -// This library 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. +// This library 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 Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : GeometryGUI.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -// -// File : GeometryGUI.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ #include "GeometryGUI.h" #include "GEOMGUI_OCCSelector.h" @@ -50,10 +47,12 @@ #include #include #include +#include #include #include #include #include +#include // External includes #include @@ -349,17 +348,17 @@ void GeometryGUI::OnGUIEvent( int id ) id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND - id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL + id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL id == 31 || // MENU EDIT - COPY id == 33 || // MENU EDIT - DELETE id == 411 || // MENU SETTINGS - ADD IN STUDY id == 412 || // MENU SETTINGS - SHADING COLOR - id == 413 || // MENU SETTINGS - ISOS - id == 414 || // MENU SETTINGS - STEP VALUE FOR SPIN BOXES id == 5103 || // MENU TOOLS - CHECK GEOMETRY id == 8032 || // POPUP VIEWER - COLOR id == 8033 || // POPUP VIEWER - TRANSPARENCY id == 8034 || // POPUP VIEWER - ISOS + id == 8035 || // POPUP VIEWER - AUTO COLOR + id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR id == 804 || // POPUP VIEWER - ADD IN STUDY id == 901 || // OBJECT BROWSER - RENAME id == 9024 ) { // OBJECT BROWSER - OPEN @@ -469,7 +468,8 @@ void GeometryGUI::OnGUIEvent( int id ) id == 504 || // MENU OPERATION - ARCHIMEDE id == 505 || // MENU OPERATION - FILLET id == 506 || // MENU OPERATION - CHAMFER - id == 507 ) { // MENU OPERATION - CLIPPING RANGE + id == 507 || // MENU OPERATION - CLIPPING RANGE + id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE #ifndef WNT library = getLibrary( "libOperationGUI.so" ); #else @@ -483,10 +483,11 @@ void GeometryGUI::OnGUIEvent( int id ) id == 606 || // MENU REPAIR - CLOSE CONTOUR id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES id == 608 || // MENU REPAIR - ADD POINT ON EDGE - id == 609 || // MENU REPAIR - FREE BOUNDARIES - id == 610 || // MENU REPAIR - FREE FACES + id == 609 || // MENU MEASURE - FREE BOUNDARIES + id == 610 || // MENU MEASURE - FREE FACES id == 611 || // MENU REPAIR - CHANGE ORIENTATION - id == 602 ) { // MENU REPAIR - GLUE FACES + id == 602 || // MENU REPAIR - GLUE FACES + id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES #ifndef WNT library = getLibrary( "libRepairGUI.so" ); #else @@ -496,8 +497,10 @@ void GeometryGUI::OnGUIEvent( int id ) else if( id == 701 || // MENU MEASURE - PROPERTIES id == 702 || // MENU MEASURE - CDG id == 703 || // MENU MEASURE - INERTIA + id == 704 || // MENU MEASURE - NORMALE id == 7041 || // MENU MEASURE - BOUNDING BOX id == 7042 || // MENU MEASURE - MIN DISTANCE + id == 7043 || // MENU MEASURE - ANGLE id == 705 || // MENU MEASURE - TOLERANCE id == 706 || // MENU MEASURE - WHATIS id == 707 || // MENU MEASURE - CHECK @@ -738,7 +741,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) ); createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) ); - createGeomAction( 33, "DELETE" ); + createGeomAction( 33, "DELETE", "", Qt::Key_Delete ); createGeomAction( 4011, "POINT" ); createGeomAction( 4012, "LINE" ); @@ -797,6 +800,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 505, "FILLET" ); createGeomAction( 506, "CHAMFER" ); //createGeomAction( 507, "CLIPPING" ); + createGeomAction( 508, "GET_SHAPES_ON_SHAPES" ); createGeomAction( 9998, "MUL_TRANSFORM" ); createGeomAction( 9995, "EXPLODE_BLOCKS" ); @@ -813,24 +817,26 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 609, "CHECK_FREE_BNDS" ); createGeomAction( 610, "CHECK_FREE_FACES" ); createGeomAction( 611, "CHANGE_ORIENTATION" ); + createGeomAction( 612, "REMOVE_EXTRA_EDGES" ); createGeomAction( 708, "POINT_COORDS" ); createGeomAction( 701, "BASIC_PROPS" ); createGeomAction( 702, "MASS_CENTER" ); createGeomAction( 703, "INERTIA" ); + createGeomAction( 704, "NORMALE" ); createGeomAction( 7041, "BND_BOX" ); createGeomAction( 7042, "MIN_DIST" ); + createGeomAction( 7043, "MEASURE_ANGLE" ); createGeomAction( 705, "TOLERANCE" ); createGeomAction( 706, "WHAT_IS" ); createGeomAction( 707, "CHECK" ); createGeomAction( 7072, "CHECK_COMPOUND" ); +#ifdef _DEBUG_ // PAL16821 createGeomAction( 5103, "CHECK_GEOMETRY" ); - +#endif createGeomAction( 412, "SHADING_COLOR" ); - createGeomAction( 413, "ISOS" ); - createGeomAction( 414, "STEP_VALUE" ); createGeomAction( 211, "SHADING" ); createGeomAction( 212, "DISPLAY_ALL" ); @@ -847,12 +853,14 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 213, "DISPLAY_ONLY" ); createGeomAction( 215, "ERASE" ); - createGeomAction( 901, "POP_RENAME" ); + createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 ); createGeomAction( 80311, "POP_WIREFRAME", "", 0, true ); createGeomAction( 80312, "POP_SHADING", "", 0, true ); createGeomAction( 8032, "POP_COLOR" ); createGeomAction( 8033, "POP_TRANSPARENCY" ); createGeomAction( 8034, "POP_ISOS" ); + createGeomAction( 8035, "POP_AUTO_COLOR" ); + createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" ); createGeomAction( 8001, "POP_CREATE_GROUP" ); // make wireframe-shading items to be exclusive (only one at a time is selected) @@ -942,6 +950,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 503, operId, -1 ); createMenu( 504, operId, -1 ); + createMenu( 508, operId, -1 ); createMenu( separator(), operId, -1 ); createMenu( 505, transId, -1 ); createMenu( 506, transId, -1 ); @@ -961,9 +970,10 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 601, repairId, -1 ); createMenu( 602, repairId, -1 ); createMenu( 608, repairId, -1 ); - createMenu( 609, repairId, -1 ); - createMenu( 610, repairId, -1 ); + //createMenu( 609, repairId, -1 ); + //createMenu( 610, repairId, -1 ); createMenu( 611, repairId, -1 ); + createMenu( 612, repairId, -1 ); int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 ); createMenu( 708, measurId, -1 ); @@ -971,11 +981,18 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( separator(), measurId, -1 ); createMenu( 702, measurId, -1 ); createMenu( 703, measurId, -1 ); + createMenu( 704, measurId, -1 ); + // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure" + createMenu( separator(), measurId, -1 ); + createMenu( 609, measurId, -1 ); + createMenu( 610, measurId, -1 ); + // NPAL16572 END createMenu( separator(), measurId, -1 ); int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 ); createMenu( 7041, dimId, -1 ); createMenu( 7042, dimId, -1 ); + createMenu( 7043, dimId, -1 ); createMenu( separator(), measurId, -1 ); createMenu( 705, measurId, -1 ); @@ -984,16 +1001,15 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 707, measurId, -1 ); createMenu( 7072, measurId, -1 ); +#ifdef _DEBUG_ // PAL16821 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 ); createMenu( separator(), toolsId, -1 ); createMenu( 5103, toolsId, -1 ); - +#endif //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 ); //createMenu( separator(), prefId, -1 ); //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 ); //createMenu( 412, geomId, -1 ); - //createMenu( 413, geomId, -1 ); - //createMenu( 414, geomId, -1 ); //createMenu( separator(), prefId, -1 ); int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 ); @@ -1066,9 +1082,17 @@ void GeometryGUI::initialize( CAM_Application* app ) QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')"; QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible"; + QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')"; + QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible"; + + QString autoColorPrefix = + "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true"; + QtxPopupMgr* mgr = popupMgr(); mgr->insert( action( 901 ), -1, -1 ); // rename mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule ); + mgr->insert( action( 33 ), -1, -1 ); // delete + mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->insert( action( 8001 ), -1, -1 ); // create group mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->insert( action( 801 ), -1, -1 ); // edit group @@ -1083,11 +1107,16 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( 8032 ), -1, -1 ); // color - mgr->setRule( action( 8032 ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); + mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( 8033 ), -1, -1 ); // transparency mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->insert( action( 8034 ), -1, -1 ); // isos - mgr->setRule( action( 8034 ), QString("client='OCCViewer' and selcount>0 and isVisible"), QtxPopupMgr::VisibleRule ); + mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); + mgr->insert( separator(), -1, -1 ); // ----------- + mgr->insert( action( 8035 ), -1, -1 ); // auto color + mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule ); + mgr->insert( action( 8036 ), -1, -1 ); // disable auto color + mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- @@ -1106,7 +1135,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule ); QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)"; - + int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu mgr->insert( action(2171), selectolnyId, -1); //Vertex mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule); @@ -1133,7 +1162,6 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule); mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule); - mgr->insert( action( 213 ), -1, -1 ); // display only mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); @@ -1164,14 +1192,17 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) // Reset actions accelerator keys //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export - action(111)->setEnabled(true); // Import - action(121)->setEnabled(true); // Export + action(111)->setEnabled( true ); // Import: CTRL + Key_I + action(121)->setEnabled( true ); // Export: CTRL + Key_E + action( 33)->setEnabled( true ); // Delete: Key_Delete + action(901)->setEnabled( true ); // Rename: Key_F2 GUIMap::Iterator it; for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) it.value()->activate( application()->desktop() ); LightApp_SelectionMgr* sm = getApp()->selectionMgr(); + SUIT_ViewManager* vm; ViewManagerList OCCViewManagers, VTKViewManagers; @@ -1185,13 +1216,18 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) while ( itVTK.hasNext() && (vm = itVTK.next()) ) myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast( vm->getViewModel() ), sm ) ); + //NPAL 19674 + SALOME_ListIO selected; + sm->selectedObjects( selected ); + sm->clearSelected(); + // disable OCC selectors getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); QListIterator itOCCSel( myOCCSelectors ); while ( itOCCSel.hasNext() ) if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() ) sr->setEnabled(true); - + // disable VTK selectors getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() ); QListIterator itVTKSel( myVTKSelectors ); @@ -1199,6 +1235,8 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) if ( LightApp_VTKSelector* sr = itVTKSel.next() ) sr->setEnabled(true); + sm->setSelectedObjects( selected, true ); //NPAL 19674 + return true; } @@ -1224,12 +1262,16 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) // Unset actions accelerator keys //action(111)->setAccel(QKeySequence()); // Import //action(121)->setAccel(QKeySequence()); // Export - action(111)->setEnabled(false); // Import - action(121)->setEnabled(false); // Export + action(111)->setEnabled( false ); // Import: CTRL + Key_I + action(121)->setEnabled( false ); // Export: CTRL + Key_E + action( 33)->setEnabled( false ); // Delete: Key_Delete + action(901)->setEnabled( false ); // Rename: Key_F2 + qDeleteAll(myOCCSelectors); myOCCSelectors.clear(); getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() ); + qDeleteAll(myVTKSelectors); myVTKSelectors.clear(); getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() ); @@ -1255,7 +1297,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win ) return; const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() ); -// const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() ); + const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() ); // disable non-OCC viewframe menu commands // action( 404 )->setEnabled( ViewOCC ); // SKETCHER @@ -1265,7 +1307,6 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win ) action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge // action( 609 )->setEnabled( ViewOCC ); // Free boundaries - action( 413 )->setEnabled( ViewOCC ); // Isos Settings action( 800 )->setEnabled( ViewOCC ); // Create Group action( 801 )->setEnabled( ViewOCC ); // Edit Group @@ -1350,19 +1391,14 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) QString GeometryGUI::engineIOR() const { - QString anIOR = QString::null; if ( !CORBA::is_nil( GetGeomGen() ) ) - { - CORBA::String_var objStr = getApp()->orb()->object_to_string( GetGeomGen() ); - anIOR = QString( objStr.in() ); -// free( objStr ); ASV : 26.07.06 : commented out because it raises exception and blocks application - } - return anIOR; + return QString( getApp()->orb()->object_to_string( GetGeomGen() ) ); + return ""; } -LightApp_Selection* GeometryGUI::createSelection( const QString& client, LightApp_SelectionMgr* mgr ) const +LightApp_Selection* GeometryGUI::createSelection() const { - return new GEOMGUI_Selection( client, mgr ); + return new GEOMGUI_Selection(); } void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title ) @@ -1385,10 +1421,11 @@ void GeometryGUI::createPreferences() int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) ); int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId ); - setPreferenceProperty( genGroup, "columns", 1 ); + setPreferenceProperty( genGroup, "columns", 2 ); int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup, - LightApp_Preferences::Selector, "Geometry", "display_mode" ); + LightApp_Preferences::Selector, + "Geometry", "display_mode" ); addPreference( tr( "PREF_SHADING_COLOR" ), genGroup, LightApp_Preferences::Color, "Geometry", "shading_color" ); @@ -1412,6 +1449,7 @@ void GeometryGUI::createPreferences() LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId ); + setPreferenceProperty( VertexGroup, "columns", 2 ); int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup, LightApp_Preferences::Selector, "Geometry", "type_of_marker" ); @@ -1432,7 +1470,7 @@ void GeometryGUI::createPreferences() setPreferenceProperty( dispmode, "indexes", anIndexesList ); // Set property for step value for spinboxes - setPreferenceProperty( step, "min", 0.001 ); + setPreferenceProperty( step, "min", 1 ); setPreferenceProperty( step, "max", 10000 ); setPreferenceProperty( step, "precision", 3 );