X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGeometryGUI.cxx;h=e5ec40e3785335b3cc3ccf1c029442596d960c1d;hb=aeddae77192d933be1aee8855d8f7c525878cad9;hp=e8745c0f2f7add00ac97d28139de21b9fff59940;hpb=97d9c2c6b1eb1b8c37b74e9409ebdb89c42c8c27;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e8745c0f2..e5ec40e37 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -30,7 +30,6 @@ #include "GeometryGUI.h" #include "GeometryGUI_Operations.h" #include "GEOMPluginGUI.h" -#include "GEOMGUI_XmlHandler.h" #include "GEOMGUI_OCCSelector.h" #include "GEOMGUI_Selection.h" #include "GEOMGUI_CreationInfoWdg.h" @@ -38,6 +37,7 @@ #include "GEOM_Constants.h" #include "GEOM_Displayer.h" #include "GEOM_AISShape.hxx" +#include "GEOMUtils_XmlHandler.hxx" #include "GEOM_Actor.h" @@ -65,6 +65,8 @@ #include #include +#include + #include #include #include @@ -433,6 +435,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) SUIT_ViewWindow* window = desk->activeWindow(); bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() ); // if current viewframe is not of OCC and not of VTK type - return immediately // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example) QList NotViewerDependentCommands; @@ -447,7 +450,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) << GEOMOp::OpPointMarker << GEOMOp::OpCreateFolder << GEOMOp::OpSortChildren; - if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) { + if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) { // activate OCC viewer getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true); } @@ -464,8 +467,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS createOriginAndBaseVectors(); // internal operation return; - case GEOMOp::OpImport: // MENU FILE - IMPORT - case GEOMOp::OpExport: // MENU FILE - EXPORT case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE @@ -517,11 +518,13 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpHide: // MENU VIEW - ERASE case GEOMOp::OpShow: // MENU VIEW - DISPLAY case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE + case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME case GEOMOp::OpShading: // POPUP MENU - SHADING case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES case GEOMOp::OpTexture: // POPUP MENU - TEXTURE case GEOMOp::OpVectors: // POPUP MENU - VECTORS + case GEOMOp::OpVertices: // POPUP MENU - VERTICES libName = "DisplayGUI"; break; case GEOMOp::OpPoint: // MENU BASIC - POINT @@ -660,10 +663,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS libName = "BlocksGUI"; break; - case GEOMOp::OpExportXAO: // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO - case GEOMOp::OpImportXAO: // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO - libName = "ImportExportGUI"; - break; //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base) //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS @@ -896,9 +895,6 @@ void GeometryGUI::initialize( CAM_Application* app ) // ----- create actions -------------- - createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I ); - createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E ); - createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete ); createGeomAction( GEOMOp::OpPoint, "POINT" ); @@ -1040,6 +1036,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" ); createGeomAction( GEOMOp::OpShow, "DISPLAY" ); createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE"); + createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE"); createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true ); createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true ); @@ -1061,6 +1058,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH"); createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH"); createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true ); + createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true ); createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" ); createGeomAction( GEOMOp::OpColor, "POP_COLOR" ); createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" ); @@ -1096,10 +1094,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false, "Geometry:Decrease number of isolines"); - // Import/Export XAO - createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" ); - createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" ); - //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); @@ -1109,13 +1103,6 @@ void GeometryGUI::initialize( CAM_Application* app ) // ---- create menus -------------------------- int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 ); - createMenu( separator(), fileId, 10 ); - createMenu( GEOMOp::OpImport, fileId, 10 ); - createMenu( GEOMOp::OpExport, fileId, 10 ); - int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), fileId, -1, 10 ); - createMenu( GEOMOp::OpExportXAO, impexpId, -1 ); - createMenu( GEOMOp::OpImportXAO, impexpId, -1 ); - createMenu( separator(), fileId, -1 ); int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 ); createMenu( GEOMOp::OpDelete, editId, -1 ); @@ -1316,6 +1303,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 ); createMenu( separator(), dispmodeId, -1 ); createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 ); + createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 ); createMenu( separator(), viewId, -1 ); createMenu( GEOMOp::OpShowAll, viewId, -1 ); @@ -1336,7 +1324,7 @@ void GeometryGUI::initialize( CAM_Application* app ) // ---- create toolbars -------------------------- - int basicTbId = createTool( tr( "TOOL_BASIC" ) ); + int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) ); createTool( GEOMOp::OpPoint, basicTbId ); createTool( GEOMOp::OpLine, basicTbId ); createTool( GEOMOp::OpCircle, basicTbId ); @@ -1351,11 +1339,11 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId ); -// int sketchTbId = createTool( tr( "TOOL_SKETCH" ) ); +// int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) ); // createTool( GEOMOp::Op2dSketcher, sketchTbId ); // createTool( GEOMOp::Op3dSketcher, sketchTbId ); - int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); + int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) ); createTool( GEOMOp::OpBox, primTbId ); createTool( GEOMOp::OpCylinder, primTbId ); createTool( GEOMOp::OpSphere, primTbId ); @@ -1365,17 +1353,17 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpDisk, primTbId ); //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc - //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) ); + //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) ); //createTool( GEOMOp::OpDividedDisk, blocksTbId ); //createTool( GEOMOp::OpDividedCylinder, blocksTbId ); - int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); + int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) ); createTool( GEOMOp::OpFuse, boolTbId ); createTool( GEOMOp::OpCommon, boolTbId ); createTool( GEOMOp::OpCut, boolTbId ); createTool( GEOMOp::OpSection, boolTbId ); - int genTbId = createTool( tr( "TOOL_GENERATION" ) ); + int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) ); createTool( GEOMOp::OpPrism, genTbId ); createTool( GEOMOp::OpRevolution, genTbId ); createTool( GEOMOp::OpFilling, genTbId ); @@ -1384,7 +1372,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpPipePath, genTbId ); #endif - int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) ); + int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) ); createTool( GEOMOp::OpTranslate, transTbId ); createTool( GEOMOp::OpRotate, transTbId ); createTool( GEOMOp::OpChangeLoc, transTbId ); @@ -1396,14 +1384,14 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpMultiTranslate, transTbId ); createTool( GEOMOp::OpMultiRotate, transTbId ); - int operTbId = createTool( tr( "TOOL_OPERATIONS" ) ); + int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) ); createTool( GEOMOp::OpExplode, operTbId ); createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId ); - int featTbId = createTool( tr( "TOOL_FEATURES" ) ); + int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) ); createTool( GEOMOp::OpFillet1d, featTbId ); createTool( GEOMOp::OpFillet2d, featTbId ); createTool( GEOMOp::OpFillet3d, featTbId ); @@ -1415,7 +1403,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpCurveCreator, featTbId ); #endif - int buildTbId = createTool( tr( "TOOL_BUILD" ) ); + int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) ); createTool( GEOMOp::OpEdge, buildTbId ); createTool( GEOMOp::OpWire, buildTbId ); createTool( GEOMOp::OpFace, buildTbId ); @@ -1423,7 +1411,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpSolid, buildTbId ); createTool( GEOMOp::OpCompound, buildTbId ); - int measureTbId = createTool( tr( "TOOL_MEASURES" ) ); + int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) ); createTool( GEOMOp::OpPointCoordinates, measureTbId ); createTool( GEOMOp::OpProperties, measureTbId ); createTool( GEOMOp::OpCenterMass, measureTbId ); @@ -1444,16 +1432,12 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpGetNonBlocks, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId ); - int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); + int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) ); createTool( GEOMOp::OpPictureImport, picturesTbId ); #ifdef WITH_OPENCV createTool( GEOMOp::OpFeatureDetect, picturesTbId ); #endif - int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) ); - createTool( GEOMOp::OpExportXAO, impexpTbId ); - createTool( GEOMOp::OpImportXAO, impexpTbId ); - //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 @@// @@ -1517,6 +1501,9 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); + mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices + mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color @@ -1528,8 +1515,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker - //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule ); - mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule ); // material properties mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); @@ -1657,131 +1643,77 @@ void GeometryGUI::addPluginActions() SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if (!resMgr) return; - // Find names of a resource XML files ("GEOMActions.xml" and others); - QString PluginsXml; - char* cenv = getenv("GEOM_PluginsList"); - if (cenv) - PluginsXml.sprintf("%s", cenv); - - QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts); - if (PluginsXmlList.count() == 0) return; - - // get full names of xml files from PluginsXmlList - QStringList xmlFiles; - xmlFiles.append(QDir::home().filePath("CustomGeomPlugins.xml")); // may be inexistent - for (int i = 0; i < PluginsXmlList.count(); i++) { - PluginsXml = PluginsXmlList[ i ]; - - // Find full path to the resource XML file - QString xmlFile = resMgr->path("resources", "GEOM", PluginsXml + ".xml"); - if ( xmlFile.isEmpty() ) // try PLUGIN resources - xmlFile = resMgr->path("resources", PluginsXml, PluginsXml + ".xml"); - if ( !xmlFile.isEmpty() ) - xmlFiles.append( xmlFile ); - } - - // create "Advanced Operations" menu and corresponding toolbar - //int advancedMenuId = createMenu(tr("MEN_ADVANCED"), -1, -1, 10); - //int advancedTbarId = createTool(tr("TOOL_ADVANCED")); - int id = GEOMOp::OpLastOperationID; // TODO? + SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); + if (!appStudy) return; - // loop on xmlFiles - QString aNoAccessFiles; - for (int i = 0; i < xmlFiles.count(); i++) { - QString xmlFile = xmlFiles[ i ]; - - QFile file (xmlFile); - if (file.exists() && file.open(QIODevice::ReadOnly)) { - file.close(); - - GEOMGUI_XmlHandler* aXmlHandler = new GEOMGUI_XmlHandler(); - ASSERT(aXmlHandler); - - QXmlInputSource source (&file); - QXmlSimpleReader reader; - reader.setContentHandler(aXmlHandler); - reader.setErrorHandler(aXmlHandler); - bool ok = reader.parse(source); - file.close(); - - if (ok) { - // bind action lib and label to its ID for activateOperation() method proper work - myPluginLibs[aXmlHandler->myPluginData.myName] = aXmlHandler->myPluginData.myClientLib; - - QListIterator anActionsIter (aXmlHandler->myPluginData.myListOfActions); - while (anActionsIter.hasNext()) { - GEOMGUI_ActionData anActionData = anActionsIter.next(); - - //QPixmap icon = resMgr->loadPixmap("GEOM", tr(anActionData.myIcon.toLatin1().constData())); - QPixmap icon = resMgr->loadPixmap(aXmlHandler->myPluginData.myName, - anActionData.myIcon.toLatin1().constData()); - - // path to action in menu - QStringList smenus = anActionData.myMenu.split( "/" ); - QString actionName = smenus.last(); - actionName = actionName.toUpper().prepend("MEN_"); - smenus.removeLast(); - - // path to action in toolbar - QStringList stools = anActionData.myTooltip.split( "/" ); - QString actionTool = stools.last(); - actionTool = actionTool.toUpper().prepend("TOP_"); - stools.removeLast(); - - QString actionStat = anActionData.myStatusBar; - actionStat = actionStat.toUpper().prepend("STB_"); - - createAction(id, // ~ anActionData.myLabel - tr(actionTool.toLatin1().constData()), - icon, - tr(actionName.toLatin1().constData()), - tr(actionStat.toLatin1().constData()), - 0 /*accel*/, - application()->desktop(), - false /*toggle*/, - this, SLOT(OnGUIEvent()), - QString() /*shortcutAction*/); - - int menuId = -1; - foreach (QString subMenu, smenus) { - subMenu = subMenu.toUpper().prepend("MEN_"); - menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1); - } - //createMenu(id, pluginMenuId, -1); - createMenu(id, menuId, -1); + // Find names of a resource XML files ("AdvancedGEOM.xml" and others); - QString subTool = stools[0]; - subTool = subTool.toUpper().prepend("TOOL_"); - int toolId = createTool(tr(subTool.toLatin1().constData())); - //createTool(id, advancedTbarId); - createTool(id, toolId); + GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo(); - // add action id to map - PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel); - myPluginActions[id] = anAction; + int id = GEOMOp::OpLastOperationID; // TODO? - id++; - } + // loop on plugins + GEOMUtils::PluginInfo::const_iterator it; + for ( it = plugins.begin(); it != plugins.end(); ++it ) { + // bind action lib and label to its ID for activateOperation() method proper work + GEOMUtils::PluginData pdata = (*it); + myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str(); + std::list actions = (*it).actions; + std::list::const_iterator ait; + for ( ait = actions.begin(); ait != actions.end(); ++ait ) { + GEOMUtils::ActionData adata = (*ait); + // icon + QPixmap icon; + if ( !adata.icon.empty() ) + icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() ); + // menu text (path) + QStringList smenus = QString( adata.menuText.c_str() ).split( "/" ); + QString actionName = smenus.last(); + actionName = actionName.toUpper().prepend( "MEN_" ); + smenus.removeLast(); + + // path to action in toolbar + QStringList stools = QString( adata.toolTip.c_str() ).split( "/" ); + QString actionTool = stools.last(); + actionTool = actionTool.toUpper().prepend( "TOP_" ); + stools.removeLast(); + + QString actionStat = adata.statusText.c_str(); + actionStat = actionStat.toUpper().prepend( "STB_" ); + + createAction( id, // ~ adata.label + tr( actionTool.toLatin1().constData() ), + icon, + tr( actionName.toLatin1().constData() ), + tr( actionStat.toLatin1().constData() ), + QKeySequence( tr( adata.accel.c_str() ) ), + application()->desktop(), + false /*toggle*/, + this, SLOT( OnGUIEvent() ), + QString() /*shortcutAction*/ ); + + int menuId = -1; + foreach ( QString subMenu, smenus ) { + QStringList subMenuList = subMenu.split( ":" ); + QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" ); + int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1; + menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup ); } - else { - SUIT_MessageBox::critical(application()->desktop(), - tr("INF_PARSE_ERROR"), - tr(aXmlHandler->errorProtocol().toLatin1().data())); + createMenu( id, menuId, -1 ); + + if ( !stools.isEmpty() ) { + QString subTool = stools[0]; + subTool = subTool.toUpper().prepend( "TOOL_" ); + int toolId = createTool( tr( subTool.toLatin1().constData() ) ); + createTool(id, toolId); } - delete aXmlHandler; - } - else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml - if (aNoAccessFiles.isEmpty()) - aNoAccessFiles = xmlFile; - else - aNoAccessFiles += ", " + xmlFile; - } - } // end loop on xmlFiles - if (!aNoAccessFiles.isEmpty()) { - QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; - aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE"); - SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess); + // add action id to map + PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() ); + myPluginActions[id] = anAction; + + id++; + } } } @@ -1822,8 +1754,6 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); // Reset actions accelerator keys - action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I - action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete GUIMap::Iterator it; @@ -1912,8 +1842,6 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) it.value()->deactivate(); // Unset actions accelerator keys - action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I - action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete qDeleteAll(myOCCSelectors); @@ -2089,15 +2017,22 @@ void GeometryGUI::updateCreationInfo() 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 ); + + QString plugin_name; + for ( size_t i = 0; i < info->params.length(); ++i ) { + myCreationInfoWdg->addParam( info->params[i].name.in(), + info->params[i].value.in() ); + QString value = info->params[i].name.in(); + if( value == PLUGIN_NAME ) { + plugin_name = info->params[i].value.in(); + } + } + QString prefix = plugin_name.isEmpty() ? "GEOM" : plugin_name; + icon = resMgr->loadPixmap( prefix, 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() ); } } } @@ -2338,8 +2273,8 @@ void GeometryGUI::createPreferences() int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup, LightApp_Preferences::Selector, "Geometry", "toplevel_dm" ); - int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup, + LightApp_Preferences::IntSpin, "Geometry", "transparency" ); int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); @@ -2375,6 +2310,9 @@ void GeometryGUI::createPreferences() setPreferenceProperty( wd[i], "max", 5 ); } + int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, + LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup, LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" ); @@ -2523,6 +2461,10 @@ void GeometryGUI::createPreferences() setPreferenceProperty( step, "max", 10000 ); setPreferenceProperty( step, "precision", 3 ); + // Set property for trandparency value for spinboxes + setPreferenceProperty( transparency, "min", 0 ); + setPreferenceProperty( transparency, "max", 100 ); + // Set property for deflection value for spinboxes setPreferenceProperty( defl, "min", GEOM::minDeflection() ); setPreferenceProperty( defl, "max", 1.0 ); @@ -2878,6 +2820,11 @@ void GeometryGUI::storeVisualParameters (int savePoint) ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString()); } + if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) { + param = occParam + GEOM::propertyName( GEOM::Vertices ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString()); + } + if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) { param = occParam + GEOM::propertyName( GEOM::Deflection ); ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString()); @@ -3048,6 +2995,8 @@ void GeometryGUI::restoreVisualParameters (int savePoint) aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val ); } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1"); + } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1"); } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) { aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble()); } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) { @@ -3101,13 +3050,19 @@ void GeometryGUI::onViewAboutToShow() { SUIT_ViewWindow* window = application()->desktop()->activeWindow(); QAction* a = action( GEOMOp::OpSwitchVectors ); + QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices ); if ( window ) { a->setEnabled(true); bool vmode = window->property("VectorsMode").toBool(); a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") ); + aVerticesAction->setEnabled(true); + vmode = window->property("VerticesMode").toBool(); + aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") ); } else { a->setText ( tr("MEN_VECTOR_MODE_ON") ); a->setEnabled(false); + aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") ); + aVerticesAction->setEnabled(false); } }