1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GeometryGUI.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
30 #include "GeometryGUI.h"
31 #include "GeometryGUI_Operations.h"
32 #include "GEOMPluginGUI.h"
33 #include "GEOMGUI_OCCSelector.h"
34 #include "GEOMGUI_Selection.h"
35 #include "GEOMGUI_CreationInfoWdg.h"
36 #include "GEOMGUI_TextTreeWdg.h"
37 #include "GEOMGUI_DimensionProperty.h"
38 #include "GEOM_Constants.h"
39 #include "GEOM_Displayer.h"
40 #include "GEOM_AISShape.hxx"
41 #include "GEOMUtils_XmlHandler.hxx"
42 #include "GEOMGUI_AnnotationMgr.h"
43 #include "GEOMGUI_TextTreeSelector.h"
45 #include "GEOM_Actor.h"
47 #include <Material_ResourceMgr.h>
48 #include <Material_Model.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_MessageBox.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_Session.h>
54 #include <SUIT_ViewManager.h>
56 #include <OCCViewer_ViewWindow.h>
57 #include <OCCViewer_ViewPort3d.h>
58 #include <OCCViewer_ViewModel.h>
59 #include <OCCViewer_ViewManager.h>
61 #include <SOCC_ViewModel.h>
62 #include <SOCC_ViewWindow.h>
64 #include <SVTK_ViewWindow.h>
65 #include <SVTK_RenderWindowInteractor.h>
66 #include <SVTK_InteractorStyle.h>
67 #include <SVTK_ViewModel.h>
69 #ifndef DISABLE_GRAPHICSVIEW
70 #include <GraphicsView_Viewer.h>
73 #include <SalomeApp_Application.h>
74 #include <SalomeApp_DataObject.h>
75 #include <SalomeApp_Study.h>
76 #include <SalomeApp_Tools.h>
78 #include <LightApp_SelectionMgr.h>
79 #include <LightApp_VTKSelector.h>
80 #include <LightApp_DataObject.h>
81 #include <LightApp_Preferences.h>
83 #include <SALOME_LifeCycleCORBA.hxx>
84 #include <SALOME_ListIO.hxx>
86 #include <SALOMEDSClient_ClientFactory.hxx>
87 #include <SALOMEDSClient_IParameters.hxx>
89 #include <SALOMEDS_SObject.hxx>
91 #include <QtxFontEdit.h>
102 #include <QSignalMapper>
103 #include <QFontDatabase>
105 #include <AIS_ListOfInteractive.hxx>
106 #include <AIS_ListIteratorOfListOfInteractive.hxx>
107 #include <Prs3d_Drawer.hxx>
108 #include <Prs3d_IsoAspect.hxx>
109 #include <Aspect_TypeOfMarker.hxx>
110 #include <OSD_SharedLibrary.hxx>
111 #include <NCollection_DataMap.hxx>
113 #include <TColStd_HArray1OfByte.hxx>
114 #include <TColStd_SequenceOfHAsciiString.hxx>
116 #include <utilities.h>
118 #include <vtkCamera.h>
119 #include <vtkRenderer.h>
121 #include <Standard_Failure.hxx>
122 #include <Standard_ErrorHandler.hxx>
124 #include <Font_SystemFont.hxx>
125 #include <Font_FontMgr.hxx>
126 #include <TCollection_HAsciiString.hxx>
128 #include "GEOM_version.h"
129 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
132 Standard_EXPORT CAM_Module* createModule() {
133 return new GeometryGUI();
136 Standard_EXPORT char* getModuleVersion() {
137 return (char*)GEOM_VERSION_STR;
141 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
143 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
145 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
146 if (CORBA::is_nil(myComponentGeom))
148 return GeometryGUI::myComponentGeom;
151 bool GeometryGUI::InitGeomGen()
154 if ( CORBA::is_nil( myComponentGeom ) ) return false;
158 //=======================================================================
159 // function : ClientSObjectToObject
161 //=======================================================================
162 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
164 _PTR(GenericAttribute) anAttr;
165 CORBA::Object_var anObj;
167 std::string aValue = theSObject->GetIOR();
168 if (strcmp(aValue.c_str(), "") != 0) {
169 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
170 anObj = anORB->string_to_object(aValue.c_str());
173 INFOS("ClientSObjectToObject - Unknown exception has occurred!!!");
175 return anObj._retn();
178 //=======================================================================
179 // function : GetStudy
181 //=======================================================================
182 SALOMEDS::Study_var GeometryGUI::getStudyServant()
184 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
185 CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
186 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
187 return aStudy._retn();
190 void GeometryGUI::Modified (bool theIsUpdateActions)
192 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
193 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
194 appStudy->Modified();
195 if ( theIsUpdateActions )
196 app->updateActions();
201 //=======================================================================
202 // function : GeometryGUI::GeometryGUI()
203 // purpose : Constructor
204 //=======================================================================
205 GeometryGUI::GeometryGUI() :
206 SalomeApp_Module( "GEOM" ),
209 if ( CORBA::is_nil( myComponentGeom ) )
211 Engines::EngineComponent_var comp =
212 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
213 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
216 myActiveDialogBox = 0;
218 gp_Pnt origin = gp_Pnt(0., 0., 0.);
219 gp_Dir direction = gp_Dir(0., 0., 1.);
220 myWorkingPlane = gp_Ax3(origin, direction);
223 myLocalSelectionMode = GEOM_ALLOBJECTS;
225 myCreationInfoWdg = 0;
229 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ), Qt::UniqueConnection );
231 Q_INIT_RESOURCE( GEOMGUI );
234 //=======================================================================
235 // function : GeometryGUI::~GeometryGUI()
236 // purpose : Destructor
237 //=======================================================================
238 GeometryGUI::~GeometryGUI()
240 while (!myOCCSelectors.isEmpty())
241 delete myOCCSelectors.takeFirst();
243 while (!myVTKSelectors.isEmpty())
244 delete myVTKSelectors.takeFirst();
246 qDeleteAll(myGUIMap);
249 //=======================================================================
250 // function : GeometryGUI::getLibrary()
251 // purpose : get or load GUI library by name [ internal ]
252 //=======================================================================
253 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
254 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
256 if ( !myGUIMap.contains( libraryName ) ) {
257 // try to load library if it is not loaded yet
259 QString dirs = getenv( "PATH" );
260 #elif defined(__APPLE__)
261 QString dirs = getenv( "DYLD_LIBRARY_PATH" );
263 QString dirs = getenv( "LD_LIBRARY_PATH" );
271 if ( !dirs.isEmpty() ) {
272 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
273 QListIterator<QString> it( dirList ); it.toBack();
274 while ( it.hasPrevious() ) {
275 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
277 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
278 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
280 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
281 continue; // continue search further
283 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
284 if ( osdF != NULL ) {
285 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
286 GEOMGUI* libGUI = (*func)( this );
288 myGUIMap[ libraryName ] = libGUI;
289 break; // found and loaded!
296 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
299 //=======================================================================
300 // function : GeometryGUI::getPluginLibrary()
301 // purpose : get or load GUI Plugin library by name [ internal ]
302 //=======================================================================
303 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
304 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
306 if ( !myGUIMap.contains( libraryName ) ) {
307 // try to load library if it is not loaded yet
310 QString dirs = getenv( "PATH" );
311 #elif defined(__APPLE__)
312 QString dirs = getenv( "DYLD_LIBRARY_PATH" );
314 QString dirs = getenv( "LD_LIBRARY_PATH" );
322 if ( !dirs.isEmpty() ) {
323 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
324 QListIterator<QString> it( dirList ); it.toBack();
325 while ( it.hasPrevious() ) {
326 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
328 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
329 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
331 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
332 continue; // continue search further
334 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
335 if ( osdF != NULL ) {
336 PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
337 GEOMPluginGUI* libGUI = (*func)( this );
339 myGUIMap[ libraryName ] = libGUI;
340 break; // found and loaded!
347 return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
350 //=======================================================================
351 // function : GeometryGUI::ActiveWorkingPlane()
352 // purpose : Activate Working Plane View
353 //=======================================================================
354 void GeometryGUI::ActiveWorkingPlane()
356 gp_Dir DZ = myWorkingPlane.Direction();
357 gp_Dir DY = myWorkingPlane.YDirection();
359 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
360 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
361 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
364 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
366 Handle(V3d_View) view3d = vw->getViewPort()->getView();
368 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
369 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
373 else if ( ViewVTK ) {
374 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
376 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
378 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
379 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
380 camera->SetFocalPoint(0,0,0);
387 //=======================================================================
388 // function : GeometryGUI::SetActiveDialogBox()
389 // purpose : Set active dialog box
390 //=======================================================================
391 GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
393 if ( !myAnnotationMgr )
394 myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
395 return myAnnotationMgr;
398 //=======================================================================
399 // function : GeometryGUI::SetActiveDialogBox()
400 // purpose : Set active dialog box
401 //=======================================================================
402 GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
404 return myTextTreeWdg;
407 //=======================================================================
408 // function : GeometryGUI::SetActiveDialogBox()
409 // purpose : Set active dialog box
410 //=======================================================================
411 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
413 myActiveDialogBox = (QDialog*)aDlg;
416 //=======================================================================
417 // function : GeometryGUI::EmitSignalDeactivateDialog()
418 // purpose : Emit a signal to deactivate the active dialog Box
419 //=======================================================================
420 void GeometryGUI::EmitSignalDeactivateDialog()
422 emit SignalDeactivateActiveDialog();
425 //=======================================================================
426 // function : GeometryGUI::EmitSignalCloseAllDialogs()
427 // purpose : Emit a signal to close all non modal dialogs box
428 //=======================================================================
429 void GeometryGUI::EmitSignalCloseAllDialogs()
431 emit SignalCloseAllDialogs();
434 //=======================================================================
435 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
436 // purpose : Emit a signal to inform that default real spin box step has
438 //=======================================================================
439 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
441 emit SignalDefaultStepValueChanged(newVal);
444 //=======================================================================
445 // function : GeometryGUI::OnGUIEvent()
446 // purpose : common slot for all menu/toolbar actions
447 //=======================================================================
448 void GeometryGUI::OnGUIEvent()
450 const QObject* obj = sender();
451 if ( !obj || !obj->inherits( "QAction" ) )
453 int id = actionId((QAction*)obj);
458 //=======================================================================
459 // function : GeometryGUI::OnGUIEvent()
460 // purpose : manage all events on GUI [static]
461 //=======================================================================
462 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
464 SUIT_Application* anApp = application();
466 SUIT_Desktop* desk = anApp->desktop();
468 // check type of the active viewframe
469 SUIT_ViewWindow* window = desk->activeWindow();
470 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
471 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
472 #ifndef DISABLE_GRAPHICSVIEW
473 bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
477 // if current viewframe is not of OCC and not of VTK type - return immediately
478 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
479 QList<int> NotViewerDependentCommands;
480 NotViewerDependentCommands << GEOMOp::OpDelete
482 << GEOMOp::OpShowOnly
483 << GEOMOp::OpShowOnlyChildren
484 << GEOMOp::OpDiscloseChildren
485 << GEOMOp::OpConcealChildren
486 << GEOMOp::OpUnpublishObject
487 << GEOMOp::OpPublishObject
488 << GEOMOp::OpPointMarker
489 << GEOMOp::OpCreateFolder
490 << GEOMOp::OpSortChildren;
491 if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
492 // activate OCC viewer
493 getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
496 // fix for IPAL9103, point 2
497 if ( CORBA::is_nil( GetGeomGen() ) ) {
498 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
503 // find corresponding GUI library
505 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
506 createOriginAndBaseVectors(); // internal operation
508 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
509 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
510 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
511 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
512 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
513 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
514 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
515 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
516 case GEOMOp::OpDelete: // MENU EDIT - DELETE
517 #ifndef DISABLE_PYCONSOLE
518 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
520 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
521 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
522 case GEOMOp::OpColor: // POPUP MENU - COLOR
523 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
524 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
525 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
526 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
527 case GEOMOp::OpIsos: // POPUP MENU - ISOS
528 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
529 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
530 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
531 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
532 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
533 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
534 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
535 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
536 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
537 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
538 case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
539 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
540 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
541 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
542 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
543 case GEOMOp::OpClsBringToFront: //
544 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
545 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
546 #ifndef DISABLE_GRAPHICSVIEW
547 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
549 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
550 libName = "GEOMToolsGUI";
552 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
553 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
554 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
555 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
556 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
557 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
558 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
559 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
560 case GEOMOp::OpHide: // MENU VIEW - ERASE
561 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
562 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
563 case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
564 case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
565 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
566 case GEOMOp::OpShading: // POPUP MENU - SHADING
567 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
568 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
569 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
570 case GEOMOp::OpVertices: // POPUP MENU - VERTICES
571 case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
572 libName = "DisplayGUI";
574 case GEOMOp::OpPoint: // MENU BASIC - POINT
575 case GEOMOp::OpLine: // MENU BASIC - LINE
576 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
577 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
578 case GEOMOp::OpArc: // MENU BASIC - ARC
579 case GEOMOp::OpVector: // MENU BASIC - VECTOR
580 case GEOMOp::OpPlane: // MENU BASIC - PLANE
581 case GEOMOp::OpCurve: // MENU BASIC - CURVE
582 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
583 libName = "BasicGUI";
585 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
586 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
587 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
588 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
589 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
590 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
591 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
592 libName = "PrimitiveGUI";
594 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
595 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
596 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
597 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
598 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
599 case GEOMOp::OpThickness: // MENU GENERATION - THICKNESS
600 libName = "GenerationGUI";
602 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
603 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
604 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
605 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
606 case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
608 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
610 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
611 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
612 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
613 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
614 case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
615 libName = "EntityGUI";
617 case GEOMOp::OpEdge: // MENU BUILD - EDGE
618 case GEOMOp::OpWire: // MENU BUILD - WIRE
619 case GEOMOp::OpFace: // MENU BUILD - FACE
620 case GEOMOp::OpShell: // MENU BUILD - SHELL
621 case GEOMOp::OpSolid: // MENU BUILD - SOLID
622 case GEOMOp::OpCompound: // MENU BUILD - COMPOUND
623 libName = "BuildGUI";
625 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
626 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
627 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
628 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
629 libName = "BooleanGUI";
631 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
632 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
633 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
634 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
635 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
636 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
637 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
638 case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
639 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
640 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
641 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
642 case GEOMOp::OpExtension: // MENU TRANSFORMATION - EXTENSION
643 libName = "TransformationGUI";
645 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
646 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
647 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
648 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
649 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
650 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
651 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
652 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
653 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
654 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
655 case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
656 case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
657 libName = "OperationGUI";
659 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
660 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
661 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
662 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
663 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
664 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
665 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
666 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
667 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
668 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
669 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
670 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
671 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
672 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
673 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
674 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
675 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
676 case GEOMOp::OpInspectObj: // MENU REPAIR - INSPECT OBJECT
677 libName = "RepairGUI";
679 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
680 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
681 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
682 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
683 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
684 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
685 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
686 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
687 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
688 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
689 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
690 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
691 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
692 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
693 case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
694 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
695 case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
696 case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
697 case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
698 #ifndef DISABLE_PLOT2DVIEWER
699 case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
701 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
702 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
703 case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
704 case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
705 libName = "MeasureGUI";
707 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
708 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
709 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
710 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
711 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
712 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
713 libName = "GroupGUI";
715 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
716 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
717 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
718 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
719 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
720 libName = "BlocksGUI";
722 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
723 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
724 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
725 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
726 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
727 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
728 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
729 //libName = "AdvancedGUI";
732 if (myPluginActions.contains(id)) {
733 libName = myPluginActions[id].first;
735 GEOMPluginGUI* library = 0;
736 if ( !libName.isEmpty() ) {
738 libName = libName + ".dll";
739 #elif defined(__APPLE__)
740 libName = QString( "lib" ) + libName + ".dylib";
742 libName = QString( "lib" ) + libName + ".so";
744 library = getPluginLibrary( libName );
747 // call method of corresponding GUI library
749 //QString action ("%1");
750 //action = action.arg(id);
752 //if( !theParam.isValid() )
753 library->OnGUIEvent( myPluginActions[id].second, desk );
755 // library->OnGUIEvent( id, desk, theParam);
758 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
760 updateCreationInfo();
766 GEOMGUI* library = 0;
767 if ( !libName.isEmpty() ) {
769 libName = libName + ".dll";
770 #elif defined(__APPLE__)
771 libName = QString( "lib" ) + libName + ".dylib";
773 libName = QString( "lib" ) + libName + ".so";
775 library = getLibrary( libName );
778 // call method of corresponding GUI library
780 if( !theParam.isValid() )
781 library->OnGUIEvent( id, desk );
783 library->OnGUIEvent( id, desk, theParam);
786 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
788 updateCreationInfo();
791 //=================================================================================
792 // function : GeometryGUI::activateOperation()
794 //=================================================================================
795 bool GeometryGUI::activateOperation( int actionId )
797 OnGUIEvent(actionId);
801 //=================================================================================
802 // function : GeometryGUI::activateOperation()
804 //=================================================================================
805 bool GeometryGUI::activateOperation( const QString& actionId )
809 int id = actionId.toInt(&isOk);
816 //=================================================================================
817 // function : GeometryGUI::activateOperation()
819 //=================================================================================
820 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
824 QString pluginLib = plugin;
825 // TODO: if <plugin> is a plugin name, find plugin library name
826 if (myPluginLibs.contains(plugin))
827 pluginLib = myPluginLibs[plugin];
829 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
830 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
831 const PluginAction& anAction = actionsIter.value();
832 if (anAction.first == pluginLib && anAction.second == actionId) {
833 // activate operation
834 OnGUIEvent(actionsIter.key());
842 //=================================================================================
843 // function : GeometryGUI::OnKeyPress()
844 // purpose : Called when any key is pressed by user [static]
845 //=================================================================================
846 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
848 if ( !application() )
850 foreach ( GEOMGUI* lib, myGUIMap )
851 lib->OnKeyPress( e, application()->desktop(), w );
854 //=================================================================================
855 // function : GeometryGUI::OnMouseMove()
856 // purpose : Manages mouse move events [static]
857 //=================================================================================
858 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
860 if ( !application() )
862 foreach ( GEOMGUI* lib, myGUIMap )
863 lib->OnMouseMove( e, application()->desktop(), w );
866 //=================================================================================
867 // function : GeometryGUI::OnMouseRelease()
868 // purpose : Manages mouse release events [static]
869 //=================================================================================
870 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
872 if ( !application() )
874 foreach ( GEOMGUI* lib, myGUIMap )
875 lib->OnMouseRelease( e, application()->desktop(), w );
878 //=================================================================================
879 // function : GeometryGUI::OnMousePress()
880 // purpose : Manage mouse press events [static]
881 //=================================================================================
882 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
884 if ( !application() )
886 foreach ( GEOMGUI* lib, myGUIMap )
887 lib->OnMousePress( e, application()->desktop(), w );
890 //=======================================================================
891 // function : createGeomAction
893 //=======================================================================
894 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
895 const int accel, const bool toggle, const QString& shortcutAction )
897 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
898 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
899 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
901 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
903 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
904 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
906 application()->desktop(),
908 this, SLOT( OnGUIEvent() ),
912 //=======================================================================
913 // function : createOriginAndBaseVectors
915 //=======================================================================
916 void GeometryGUI::createOriginAndBaseVectors()
918 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
919 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
921 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
925 if ( !CORBA::is_nil( GetGeomGen() ) ) {
926 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
927 if ( !aBasicOperations->_is_nil() ) {
928 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
929 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
930 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
931 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
932 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
933 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
935 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
936 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
937 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
938 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
939 anOrigin->UnRegister();
943 aBasicOperations->UnRegister();
945 getApp()->updateObjectBrowser( true );
951 //=======================================================================
952 // function : GeometryGUI::initialize()
953 // purpose : Called when GEOM module is created
954 //=======================================================================
955 void GeometryGUI::initialize( CAM_Application* app )
957 SalomeApp_Module::initialize( app );
959 // ----- create actions --------------
961 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
963 createGeomAction( GEOMOp::OpPoint, "POINT" );
964 createGeomAction( GEOMOp::OpLine, "LINE" );
965 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
966 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
967 createGeomAction( GEOMOp::OpArc, "ARC" );
968 createGeomAction( GEOMOp::OpCurve, "CURVE" );
969 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
970 createGeomAction( GEOMOp::OpVector, "VECTOR" );
971 createGeomAction( GEOMOp::OpPlane, "PLANE" );
972 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
973 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
974 createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
976 createGeomAction( GEOMOp::OpBox, "BOX" );
977 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
978 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
979 createGeomAction( GEOMOp::OpTorus, "TORUS" );
980 createGeomAction( GEOMOp::OpCone, "CONE" );
981 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
982 createGeomAction( GEOMOp::OpDisk, "DISK" );
984 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
985 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
986 createGeomAction( GEOMOp::OpFilling, "FILLING" );
987 createGeomAction( GEOMOp::OpPipe, "PIPE" );
988 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
989 createGeomAction( GEOMOp::OpThickness, "THICKNESS" );
991 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
992 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
993 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
994 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
995 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
997 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
998 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
1000 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
1002 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
1003 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
1005 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
1006 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
1007 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
1009 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1011 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1012 createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1014 createGeomAction( GEOMOp::OpEdge, "EDGE" );
1015 createGeomAction( GEOMOp::OpWire, "WIRE" );
1016 createGeomAction( GEOMOp::OpFace, "FACE" );
1017 createGeomAction( GEOMOp::OpShell, "SHELL" );
1018 createGeomAction( GEOMOp::OpSolid, "SOLID" );
1019 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
1021 createGeomAction( GEOMOp::OpFuse, "FUSE" );
1022 createGeomAction( GEOMOp::OpCommon, "COMMON" );
1023 createGeomAction( GEOMOp::OpCut, "CUT" );
1024 createGeomAction( GEOMOp::OpSection, "SECTION" );
1026 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
1027 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
1028 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
1029 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
1030 createGeomAction( GEOMOp::OpScale, "SCALE" );
1031 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
1032 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
1033 createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
1034 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1035 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
1036 createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
1038 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
1039 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
1040 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
1041 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
1042 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
1043 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
1044 createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
1045 createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
1046 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
1047 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
1048 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
1049 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
1051 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1052 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
1053 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
1055 createGeomAction( GEOMOp::OpSewing, "SEWING" );
1056 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
1057 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
1058 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
1059 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
1060 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1061 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1062 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1063 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1064 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1065 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1066 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1067 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1068 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1069 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1070 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1071 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1072 createGeomAction( GEOMOp::OpInspectObj, "INSPECT_OBJECT" );
1074 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1075 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1076 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1077 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1078 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1079 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1080 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1081 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1082 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1083 createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
1084 createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
1085 createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1087 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1088 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1089 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1090 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1091 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1092 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1093 createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
1094 #ifndef DISABLE_PLOT2DVIEWER
1095 createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
1098 #ifndef DISABLE_PYCONSOLE
1099 #ifdef _DEBUG_ // PAL16821
1100 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1104 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1105 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1106 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1107 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1108 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1109 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1110 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1111 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1112 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1113 createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
1114 createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
1115 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1116 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1117 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1118 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1119 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1120 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1121 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1122 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1123 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1124 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1125 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1126 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1127 createGeomAction( GEOMOp::OpHide, "ERASE" );
1129 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1130 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1131 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1132 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1133 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1134 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1135 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1136 createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
1137 createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
1138 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1139 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1140 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1141 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1142 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1143 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1144 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1145 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1146 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1147 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1148 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1149 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1150 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1151 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1152 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1153 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1154 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1155 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1156 #ifndef DISABLE_GRAPHICSVIEW
1157 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1159 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1160 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1161 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1162 createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1163 createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1165 // Create actions for increase/decrease transparency shortcuts
1166 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1167 "Geometry:Increase transparency");
1168 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1169 "Geometry:Decrease transparency");
1171 // Create actions for increase/decrease number of isolines
1172 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1173 "Geometry:Increase number of isolines");
1174 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1175 "Geometry:Decrease number of isolines");
1177 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1178 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1179 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1180 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1181 //@@ 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 @@//
1183 // ---- create menus --------------------------
1185 /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1187 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1188 createMenu( GEOMOp::OpDelete, editId, -1 );
1190 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1192 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1193 createMenu( GEOMOp::OpPoint, basicId, -1 );
1194 createMenu( GEOMOp::OpLine, basicId, -1 );
1195 createMenu( GEOMOp::OpCircle, basicId, -1 );
1196 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1197 createMenu( GEOMOp::OpArc, basicId, -1 );
1198 createMenu( GEOMOp::OpCurve, basicId, -1 );
1199 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1200 createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1201 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1202 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1203 createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1204 createMenu( separator(), basicId, -1 );
1205 createMenu( GEOMOp::OpVector, basicId, -1 );
1206 createMenu( GEOMOp::OpPlane, basicId, -1 );
1207 createMenu( GEOMOp::OpLCS, basicId, -1 );
1208 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1210 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1211 createMenu( GEOMOp::OpBox, primId, -1 );
1212 createMenu( GEOMOp::OpCylinder, primId, -1 );
1213 createMenu( GEOMOp::OpSphere, primId, -1 );
1214 createMenu( GEOMOp::OpTorus, primId, -1 );
1215 createMenu( GEOMOp::OpCone, primId, -1 );
1216 createMenu( GEOMOp::OpRectangle, primId, -1 );
1217 createMenu( GEOMOp::OpDisk, primId, -1 );
1218 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1220 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1221 createMenu( GEOMOp::OpPrism, genId, -1 );
1222 createMenu( GEOMOp::OpRevolution, genId, -1 );
1223 createMenu( GEOMOp::OpFilling, genId, -1 );
1224 createMenu( GEOMOp::OpPipe, genId, -1 );
1225 createMenu( GEOMOp::OpPipePath, genId, -1 );
1226 createMenu( GEOMOp::OpThickness, genId, -1 );
1228 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1229 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1230 //@@ 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 @@//
1232 createMenu( separator(), newEntId, -1 );
1234 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1235 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1236 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1237 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1238 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1239 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1241 createMenu( separator(), newEntId, -1 );
1243 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1244 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1245 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1247 createMenu( separator(), newEntId, -1 );
1249 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1250 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1251 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1252 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1253 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1255 createMenu( separator(), newEntId, -1 );
1257 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1259 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1260 createMenu( GEOMOp::OpEdge, buildId, -1 );
1261 createMenu( GEOMOp::OpWire, buildId, -1 );
1262 createMenu( GEOMOp::OpFace, buildId, -1 );
1263 createMenu( GEOMOp::OpShell, buildId, -1 );
1264 createMenu( GEOMOp::OpSolid, buildId, -1 );
1265 createMenu( GEOMOp::OpCompound, buildId, -1 );
1267 createMenu( separator(), newEntId, -1 );
1269 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1271 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1274 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1276 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1277 createMenu( GEOMOp::OpFuse, boolId, -1 );
1278 createMenu( GEOMOp::OpCommon, boolId, -1 );
1279 createMenu( GEOMOp::OpCut, boolId, -1 );
1280 createMenu( GEOMOp::OpSection, boolId, -1 );
1282 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1283 createMenu( GEOMOp::OpTranslate, transId, -1 );
1284 createMenu( GEOMOp::OpRotate, transId, -1 );
1285 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1286 createMenu( GEOMOp::OpMirror, transId, -1 );
1287 createMenu( GEOMOp::OpScale, transId, -1 );
1288 createMenu( GEOMOp::OpOffset, transId, -1 );
1289 createMenu( GEOMOp::OpProjection, transId, -1 );
1290 createMenu( GEOMOp::OpExtension, transId, -1 );
1291 createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
1292 createMenu( separator(), transId, -1 );
1293 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1294 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1296 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1297 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1298 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1299 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1301 createMenu( separator(), operId, -1 );
1303 createMenu( GEOMOp::OpPartition, operId, -1 );
1304 createMenu( GEOMOp::OpArchimede, operId, -1 );
1305 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1306 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1307 createMenu( GEOMOp::OpTransferData, operId, -1 );
1308 createMenu( GEOMOp::OpExtraction, operId, -1 );
1310 createMenu( separator(), operId, -1 );
1312 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1313 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1314 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1315 createMenu( GEOMOp::OpChamfer, operId, -1 );
1316 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1317 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1319 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1320 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1321 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1322 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1323 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1324 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1325 createMenu( GEOMOp::OpSewing, repairId, -1 );
1326 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1327 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1328 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1329 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1330 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1331 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1332 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1333 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1334 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1335 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1336 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1338 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1339 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1340 createMenu( GEOMOp::OpProperties, measurId, -1 );
1341 createMenu( separator(), measurId, -1 );
1342 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1343 createMenu( GEOMOp::OpInertia, measurId, -1 );
1344 createMenu( GEOMOp::OpNormale, measurId, -1 );
1345 createMenu( separator(), measurId, -1 );
1346 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1347 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1348 createMenu( separator(), measurId, -1 );
1350 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1351 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1352 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1353 createMenu( GEOMOp::OpAngle, dimId, -1 );
1354 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1356 createMenu( GEOMOp::OpAnnotation, measurId, -1 );
1358 createMenu( separator(), measurId, -1 );
1359 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1360 createMenu( separator(), measurId, -1 );
1361 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1362 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1363 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1364 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1365 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1366 createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1367 createMenu( GEOMOp::OpInspectObj, measurId, -1 );
1368 #ifndef DISABLE_PLOT2DVIEWER
1369 createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1372 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1373 #ifndef DISABLE_PYCONSOLE
1374 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1375 createMenu( separator(), toolsId, -1 );
1376 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1380 createMenu( separator(), toolsId, -1 );
1381 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1382 createMenu( separator(), toolsId, -1 );
1384 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1385 createMenu( separator(), viewId, -1 );
1387 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1388 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1389 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1390 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1391 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1392 createMenu( separator(), dispmodeId, -1 );
1393 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1394 createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
1395 createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
1397 createMenu( separator(), viewId, -1 );
1398 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1399 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1400 createMenu( separator(), viewId, -1 );
1401 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1402 createMenu( separator(), viewId, -1 );
1406 because of these items are accessible through object browser and viewers
1407 we have removed they from main menu
1409 createMenu( GEOMOp::OpShow, viewId, -1 );
1410 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1411 createMenu( GEOMOp::OpHide, viewId, -1 );
1414 // ---- create toolbars --------------------------
1416 int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1417 createTool( GEOMOp::OpPoint, basicTbId );
1418 createTool( GEOMOp::OpLine, basicTbId );
1419 createTool( GEOMOp::OpCircle, basicTbId );
1420 createTool( GEOMOp::OpEllipse, basicTbId );
1421 createTool( GEOMOp::OpArc, basicTbId );
1422 createTool( GEOMOp::OpCurve, basicTbId );
1423 createTool( GEOMOp::OpVector, basicTbId );
1424 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1425 createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
1426 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1427 createTool( GEOMOp::OpIsoline, basicTbId );
1428 createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
1429 createTool( GEOMOp::OpPlane, basicTbId );
1430 createTool( GEOMOp::OpLCS, basicTbId );
1431 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1433 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1434 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1435 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1437 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1438 createTool( GEOMOp::OpBox, primTbId );
1439 createTool( GEOMOp::OpCylinder, primTbId );
1440 createTool( GEOMOp::OpSphere, primTbId );
1441 createTool( GEOMOp::OpTorus, primTbId );
1442 createTool( GEOMOp::OpCone, primTbId );
1443 createTool( GEOMOp::OpRectangle, primTbId );
1444 createTool( GEOMOp::OpDisk, primTbId );
1445 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1447 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1448 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1449 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1451 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1452 createTool( GEOMOp::OpFuse, boolTbId );
1453 createTool( GEOMOp::OpCommon, boolTbId );
1454 createTool( GEOMOp::OpCut, boolTbId );
1455 createTool( GEOMOp::OpSection, boolTbId );
1457 int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1458 createTool( GEOMOp::OpPrism, genTbId );
1459 createTool( GEOMOp::OpRevolution, genTbId );
1460 createTool( GEOMOp::OpFilling, genTbId );
1461 createTool( GEOMOp::OpPipe, genTbId );
1462 createTool( GEOMOp::OpPipePath, genTbId );
1463 createTool( GEOMOp::OpThickness, genTbId );
1465 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1466 createTool( GEOMOp::OpTranslate, transTbId );
1467 createTool( GEOMOp::OpRotate, transTbId );
1468 createTool( GEOMOp::OpChangeLoc, transTbId );
1469 createTool( GEOMOp::OpMirror, transTbId );
1470 createTool( GEOMOp::OpScale, transTbId );
1471 createTool( GEOMOp::OpOffset, transTbId );
1472 createTool( GEOMOp::OpProjection, transTbId );
1473 createTool( GEOMOp::OpExtension, transTbId );
1474 createTool( GEOMOp::OpProjOnCyl, transTbId );
1475 createTool( separator(), transTbId );
1476 createTool( GEOMOp::OpMultiTranslate, transTbId );
1477 createTool( GEOMOp::OpMultiRotate, transTbId );
1479 int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1480 createTool( GEOMOp::OpExplode, operTbId );
1481 createTool( GEOMOp::OpPartition, operTbId );
1482 createTool( GEOMOp::OpArchimede, operTbId );
1483 createTool( GEOMOp::OpShapesOnShape, operTbId );
1484 createTool( GEOMOp::OpSharedShapes, operTbId );
1485 createTool( GEOMOp::OpTransferData, operTbId );
1486 createTool( GEOMOp::OpExtraction, operTbId );
1488 int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1489 createTool( GEOMOp::OpFillet1d, featTbId );
1490 createTool( GEOMOp::OpFillet2d, featTbId );
1491 createTool( GEOMOp::OpFillet3d, featTbId );
1492 createTool( GEOMOp::OpChamfer, featTbId );
1493 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1494 createTool( GEOMOp::OpExtrudedCut, featTbId );
1496 int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1497 createTool( GEOMOp::OpEdge, buildTbId );
1498 createTool( GEOMOp::OpWire, buildTbId );
1499 createTool( GEOMOp::OpFace, buildTbId );
1500 createTool( GEOMOp::OpShell, buildTbId );
1501 createTool( GEOMOp::OpSolid, buildTbId );
1502 createTool( GEOMOp::OpCompound, buildTbId );
1504 int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1505 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1506 createTool( GEOMOp::OpProperties, measureTbId );
1507 createTool( GEOMOp::OpCenterMass, measureTbId );
1508 createTool( GEOMOp::OpInertia, measureTbId );
1509 createTool( GEOMOp::OpNormale, measureTbId );
1510 createTool( separator(), measureTbId );
1511 createTool( GEOMOp::OpBoundingBox, measureTbId );
1512 createTool( GEOMOp::OpMinDistance, measureTbId );
1513 createTool( GEOMOp::OpAngle, measureTbId );
1514 createTool( GEOMOp::OpAnnotation, measureTbId );
1515 createTool( GEOMOp::OpTolerance , measureTbId );
1516 createTool( separator(), measureTbId );
1517 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1518 createTool( GEOMOp::OpFreeFaces, measureTbId );
1519 createTool( separator(), measureTbId );
1520 createTool( GEOMOp::OpWhatIs, measureTbId );
1521 createTool( GEOMOp::OpCheckShape, measureTbId );
1522 createTool( GEOMOp::OpCheckCompound, measureTbId );
1523 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1524 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1525 createTool( GEOMOp::OpFastCheckInters, measureTbId );
1527 int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1528 createTool( GEOMOp::OpPictureImport, picturesTbId );
1530 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1533 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1534 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1535 //@@ 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 @@//
1537 // ---- create popup menus --------------------------
1539 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1540 QString clientOCC = "(client='OCCViewer')";
1541 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1542 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1544 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1545 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1546 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1547 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1549 QString autoColorPrefix =
1550 "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1552 QtxPopupMgr* mgr = popupMgr();
1554 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1555 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1556 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1557 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1558 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1559 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1560 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1561 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1563 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1564 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1565 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1566 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1567 mgr->insert( separator(), -1, -1 ); // -----------
1569 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1570 QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1571 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1572 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1573 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1574 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1575 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1576 mgr->insert( separator(), -1, -1 ); // -----------
1577 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1578 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1579 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1580 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1581 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1582 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1583 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1584 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1585 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1586 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1587 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1588 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1589 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1590 mgr->insert( separator(), dispmodeId, -1 );
1591 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1592 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1593 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1594 mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1595 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1596 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1597 mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1598 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1599 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1600 mgr->insert( separator(), -1, -1 ); // -----------
1602 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1603 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1604 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1605 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1606 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1607 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1608 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1609 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1610 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1611 mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1613 // material properties
1614 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1615 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1618 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1619 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1621 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1622 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1623 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1625 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1626 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1628 mgr->insert( separator(), -1, -1 ); // -----------
1629 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1630 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1631 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1632 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1633 mgr->insert( separator(), -1, -1 ); // -----------
1635 mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
1636 mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1637 mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
1638 mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1639 mgr->insert( separator(), -1, -1 ); // -----------
1641 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1642 onlyComponent = "((type='Component') and selcount=1)",
1643 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1644 types = "'Shape' 'Group' 'FieldStep'";
1646 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1647 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1649 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1650 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1652 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1653 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1655 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1657 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1658 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1659 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1660 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1661 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1662 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1663 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1664 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1665 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1666 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1667 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1668 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1669 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1670 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1671 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1672 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1673 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1674 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1675 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1676 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1677 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1678 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1679 mgr->insert( separator(), selectonlyId, -1);
1680 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1681 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1682 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1683 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1684 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1685 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1686 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1688 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1690 mgr->insert( separator(), -1, -1 ); // -----------
1691 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1692 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1693 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1694 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1695 mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1696 mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1697 mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1698 mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1700 mgr->insert( separator(), -1, -1 ); // -----------
1701 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1702 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1704 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1705 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1707 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1708 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1710 mgr->insert( separator(), -1, -1 ); // -----------
1711 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1712 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1714 mgr->insert( separator(), -1, -1 ); // -----------
1715 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1716 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1718 #ifndef DISABLE_GRAPHICSVIEW
1719 mgr->insert( separator(), -1, -1 ); // -----------
1720 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1721 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1724 mgr->insert( separator(), -1, -1 ); // -----------
1725 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1726 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1728 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1730 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1732 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1733 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1734 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1737 // create plugin actions and menus
1741 //=======================================================================
1742 // function : GeometryGUI::addPluginActions()
1744 //=======================================================================
1745 void GeometryGUI::addPluginActions()
1748 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1749 if (!resMgr) return;
1751 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1752 if (!appStudy) return;
1754 // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1756 GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1758 int id = GEOMOp::OpLastOperationID; // TODO?
1761 GEOMUtils::PluginInfo::const_iterator it;
1762 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1763 // bind action lib and label to its ID for activateOperation() method proper work
1764 GEOMUtils::PluginData pdata = (*it);
1765 myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1766 std::list<GEOMUtils::ActionData> actions = (*it).actions;
1767 std::list<GEOMUtils::ActionData>::const_iterator ait;
1768 for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1769 GEOMUtils::ActionData adata = (*ait);
1772 if ( !adata.icon.empty() )
1773 icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1775 QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1776 QString actionName = smenus.last();
1777 actionName = actionName.toUpper().prepend( "MEN_" );
1778 smenus.removeLast();
1780 // path to action in toolbar
1781 QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1782 QString actionTool = stools.last();
1783 actionTool = actionTool.toUpper().prepend( "TOP_" );
1784 stools.removeLast();
1786 QString actionStat = adata.statusText.c_str();
1787 actionStat = actionStat.toUpper().prepend( "STB_" );
1789 createAction( id, // ~ adata.label
1790 tr( actionTool.toLatin1().constData() ),
1792 tr( actionName.toLatin1().constData() ),
1793 tr( actionStat.toLatin1().constData() ),
1794 QKeySequence( tr( adata.accel.c_str() ) ),
1795 application()->desktop(),
1797 this, SLOT( OnGUIEvent() ),
1798 QString() /*shortcutAction*/ );
1801 foreach ( QString subMenu, smenus ) {
1802 QStringList subMenuList = subMenu.split( ":" );
1803 QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1804 int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1805 menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1807 createMenu( id, menuId, -1 );
1809 if ( !stools.isEmpty() ) {
1810 QString subTool = stools[0];
1811 subTool = subTool.toUpper().prepend( "TOOL_" );
1812 int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1813 createTool(id, toolId);
1816 // add action id to map
1817 PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1818 myPluginActions[id] = anAction;
1825 //=======================================================================
1826 // function : GeometryGUI::activateModule()
1827 // purpose : Called when GEOM module is activated
1828 //=======================================================================
1829 bool GeometryGUI::activateModule( SUIT_Study* study )
1831 if ( CORBA::is_nil( myComponentGeom ) )
1834 bool res = SalomeApp_Module::activateModule( study );
1838 setMenuShown( true );
1839 setToolShown( true );
1841 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1842 PyGILState_STATE gstate = PyGILState_Ensure();
1843 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1844 if ( !pluginsmanager ) {
1849 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1850 tr("MEN_NEW_ENTITY").toUtf8().data(),
1851 tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1856 PyGILState_Release(gstate);
1857 // end of GEOM plugins loading
1859 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1860 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
1862 // Reset actions accelerator keys
1863 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1865 GUIMap::Iterator it;
1866 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1867 it.value()->activate( application()->desktop() );
1869 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1871 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ), Qt::UniqueConnection );
1872 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ), Qt::UniqueConnection );
1873 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ), Qt::UniqueConnection );
1875 if ( !myCreationInfoWdg )
1876 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1877 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1878 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1880 if ( !myTextTreeWdg ) {
1881 myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1882 new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1885 getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1886 getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1889 SALOME_ListIO selected;
1890 sm->selectedObjects( selected );
1891 sm->clearSelected();
1893 SUIT_ViewManager* vm;
1894 ViewManagerList OCCViewManagers, VTKViewManagers;
1896 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1897 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1898 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1899 onViewManagerAdded(vm);
1901 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1902 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1903 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1904 onViewManagerAdded(vm);
1906 sm->setSelectedObjects( selected, true ); //NPAL 19674
1908 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1910 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ), Qt::UniqueConnection );
1912 // 0020836 (Basic vectors and origin)
1913 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1914 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1915 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1917 _PTR(Study) studyDS = appStudy->studyDS();
1919 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1920 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1921 createOriginAndBaseVectors();
1926 Py_XDECREF(pluginsmanager);
1930 //=======================================================================
1931 // function : GeometryGUI::deactivateModule()
1932 // purpose : Called when GEOM module is deactivated
1933 //=======================================================================
1934 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1936 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1938 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1940 setMenuShown( false );
1941 setToolShown( false );
1943 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1944 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1946 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1948 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1949 //disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1950 if ( myCreationInfoWdg ) {
1951 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1952 myCreationInfoWdg = 0;
1954 if ( myTextTreeWdg ) {
1955 getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
1956 disconnect( application(), 0, myTextTreeWdg, 0 );
1960 EmitSignalCloseAllDialogs();
1962 GUIMap::Iterator it;
1963 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1964 it.value()->deactivate();
1966 // Unset actions accelerator keys
1967 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1969 qDeleteAll(myOCCSelectors);
1970 myOCCSelectors.clear();
1971 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1973 qDeleteAll(myVTKSelectors);
1974 myVTKSelectors.clear();
1975 selMrg->setEnabled( true, SVTK_Viewer::Type() );
1977 return SalomeApp_Module::deactivateModule( study );
1980 //=======================================================================
1981 // function : onWindowActivated()
1982 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1983 //=======================================================================
1984 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1989 const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
1990 //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
1992 // disable non-OCC viewframe menu commands
1993 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1994 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1995 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1996 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1997 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1998 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1999 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2001 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2002 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2003 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2004 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2006 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2009 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2011 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2012 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2013 #ifndef DISABLE_PYCONSOLE
2014 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2016 if ( myCreationInfoWdg )
2017 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2018 if ( myTextTreeWdg )
2019 mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2022 void GeometryGUI::viewManagers( QStringList& lst ) const
2024 lst.append( OCCViewer_Viewer::Type() );
2027 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2029 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2031 qDebug( "connect" );
2032 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
2033 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2034 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2035 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2036 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2037 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2038 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2039 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2041 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2042 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2044 // disable OCC selectors
2045 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2046 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2047 while ( itOCCSel.hasNext() )
2048 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2049 sr->setEnabled(true);
2051 else if ( vm->getType() == SVTK_Viewer::Type() )
2053 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2054 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2056 // disable VTK selectors
2057 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2058 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2059 while ( itVTKSel.hasNext() )
2060 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2061 sr->setEnabled(true);
2065 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2067 SUIT_ViewModel* viewer = vm->getViewModel();
2068 if ( vm->getType() == OCCViewer_Viewer::Type() )
2070 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2071 while ( itOCCSel.hasNext() )
2072 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2073 if ( sr->viewer() == viewer )
2075 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2079 if ( vm->getType() == SVTK_Viewer::Type() )
2081 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2082 while ( itVTKSel.hasNext() )
2083 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2084 if ( sr->viewer() == viewer )
2086 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2090 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2092 GetAnnotationMgr()->RemoveView( aSOCCView );
2096 //================================================================================
2098 * \brief Slot called when selection changed. Shows creation info of a selected object
2100 //================================================================================
2102 void GeometryGUI::updateCreationInfo()
2104 if ( myCreationInfoWdg )
2105 myCreationInfoWdg->clear();
2107 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2108 // if ( !myCreationInfoWdg->isVisible() )
2111 // look for a sole selected GEOM_Object
2112 GEOM::GEOM_BaseObject_var geomObj;
2114 SALOME_ListIO selected;
2115 getApp()->selectionMgr()->selectedObjects( selected );
2117 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2118 SALOME_ListIteratorOfListIO selIt( selected );
2119 for ( ; selIt.More(); selIt.Next() )
2121 Handle(SALOME_InteractiveObject) io = selIt.Value();
2122 if ( !io->hasEntry() ) continue;
2123 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2124 if ( !sobj ) continue;
2125 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2126 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2127 if ( !gobj->_is_nil() )
2129 if ( !geomObj->_is_nil() )
2130 return; // several GEOM objects selected
2134 if ( geomObj->_is_nil() ) return;
2136 // pass creation info of geomObj to myCreationInfoWdg
2138 if ( myCreationInfoWdg ) {
2140 GEOM::CreationInformationSeq_var info;
2143 info = geomObj->GetCreationInformation();
2147 myCreationInfoWdg->setInfo( info );
2151 void GeometryGUI::onAutoBringToFront()
2153 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2154 if( !isAutoBringToFront )
2157 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2158 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2161 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2162 if (!appStudy) return;
2164 GEOM_Displayer displayer;
2166 SALOME_View* window = displayer.GetActiveView();
2167 if ( !window ) return;
2169 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2171 SALOME_ListIO selected;
2172 getApp()->selectionMgr()->selectedObjects( selected );
2173 if (!myTopLevelIOList.IsEmpty())
2175 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2177 Handle( SALOME_InteractiveObject ) io = It.Value();
2178 bool isSelected = false;
2179 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2181 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2182 if( io->isSame( sel_io ) )
2185 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2187 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2188 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2193 myTopLevelIOList.Assign(selected);
2194 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2196 Handle( SALOME_InteractiveObject ) io = It.Value();
2197 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2198 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2201 displayer.UpdateViewer();
2202 GeometryGUI::Modified();
2205 void GeometryGUI::updateFieldColorScale()
2207 GEOM_Displayer aDisplayer;
2208 aDisplayer.UpdateColorScale();
2211 QString GeometryGUI::engineIOR() const
2213 if ( !CORBA::is_nil( GetGeomGen() ) )
2214 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2218 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2220 theWidth = theHeight = 0;
2221 Handle(TColStd_HArray1OfByte) aTexture;
2223 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2224 if ( !aInsOp->_is_nil() ) {
2225 CORBA::Long aWidth, aHeight;
2226 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2227 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2229 theHeight = aHeight;
2231 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2233 for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2234 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2240 LightApp_Selection* GeometryGUI::createSelection() const
2242 return new GEOMGUI_Selection();
2245 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2247 SalomeApp_Module::contextMenuPopup( client, menu, title );
2249 getApp()->selectionMgr()->selectedObjects( lst );
2251 //Add submenu for predefined materials
2252 // RNV: '#23552: Unable to use the contextual menu of Object Browser window' issue:
2253 // Temporary solution: do not show 'Materials' submenu forcibly
2254 //bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
2255 bool isPredefMat = false;
2257 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2258 QtxPopupMgr* mgr = popupMgr();
2259 //get parent for submenu
2260 QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
2262 QMenu* oldMenu = act->menu() ;
2267 QMenu* matMenu = new QMenu();
2268 QSignalMapper* signalMapper = new QSignalMapper( matMenu );
2270 //Get current material model for the object
2272 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2273 if ( anApp && anApp->activeViewManager() ) {
2274 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2276 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2279 QString curModel = "";
2280 if ( v.canConvert<QString>() ) curModel = v.toString();
2281 // get list of all predefined materials
2282 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2284 foreach ( QString material, materials )
2286 QAction* menAct = matMenu->addAction( material );
2287 connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2288 signalMapper->setMapping( menAct, material );
2289 menAct->setCheckable( true );
2290 // Set checked if this material is current
2291 Material_Model aModel;
2292 aModel.fromResources( material );
2293 if ( !found && aModel.toProperties() == curModel ) {
2294 menAct->setChecked( true );
2298 matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
2299 matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
2300 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2301 this, SLOT( OnSetMaterial( const QString & ) ) );
2302 act->setMenu( matMenu );
2306 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2307 Handle(SALOME_InteractiveObject) io = lst.First();
2308 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2309 _PTR(Study) study = appStudy->studyDS();
2310 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2312 QString aName = QString( obj->GetName().c_str() );
2313 aName.remove( QRegExp("\\s+$") );
2319 void GeometryGUI::OnSetMaterial(const QString& theName)
2321 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2325 void GeometryGUI::createPreferences()
2327 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2329 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2331 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2332 setPreferenceProperty( genGroup, "columns", 2 );
2334 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2335 LightApp_Preferences::Selector,
2336 "Geometry", "display_mode" );
2338 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2339 LightApp_Preferences::Color, "Geometry", "shading_color" );
2341 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2342 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2344 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2345 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2347 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2348 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2350 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2351 LightApp_Preferences::Color, "Geometry", "line_color" );
2353 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2354 LightApp_Preferences::Color, "Geometry", "point_color" );
2356 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2357 LightApp_Preferences::Color, "Geometry", "isos_color" );
2359 addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2360 LightApp_Preferences::Color, "Geometry", "label_color" );
2362 addPreference( "", genGroup, LightApp_Preferences::Space );
2364 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2365 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2367 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2368 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2370 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2371 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2373 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2374 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2376 // RNV: Temporary hide this preference, because of the '#23552: Unable to use the contextual menu of Object Browser window' issue
2377 //addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2378 // LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2380 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2381 LightApp_Preferences::Selector,
2382 "Geometry", "material" );
2384 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2385 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2391 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2392 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2394 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2395 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2397 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2398 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2400 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2401 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2403 for (int i = 0; i < nb; i++) {
2404 setPreferenceProperty( wd[i], "min", 1 );
2405 setPreferenceProperty( wd[i], "max", 5 );
2408 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2409 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2411 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2412 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2414 // --------------------------------------------------------------------------
2415 // Dimensions (Measurements) preferences
2416 // --------------------------------------------------------------------------
2418 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2419 setPreferenceProperty( aDimGroupId, "columns", 2 );
2421 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2422 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2424 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2425 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2427 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2428 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2430 int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2432 int f = QtxFontEdit::Family | QtxFontEdit::Size;
2433 setPreferenceProperty( aDimFontId, "features", f );
2434 setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2436 Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2437 QString aFontFile = "";
2438 resMgr->value("resources", "GEOM", aFontFile);
2439 aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2440 // add enginier font into combobox
2441 /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2442 Handle(Font_SystemFont) sf = new Font_SystemFont(
2443 new TCollection_HAsciiString("Y14.5M-2009"),
2445 new TCollection_HAsciiString(aFontFile.toLatin1().data()) );
2446 // register font in OCC font manager
2447 fmgr->RegisterFont( sf, Standard_False );
2449 // get list of supported fonts by OCC
2450 QStringList anOCCFonts;
2451 TColStd_SequenceOfHAsciiString theFontsNames;
2452 fmgr->GetAvailableFontsNames( theFontsNames );
2453 for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2454 Handle(TCollection_HAsciiString) str = theFontsNames(i);
2455 anOCCFonts << str->ToCString();
2457 anOCCFonts.removeDuplicates();
2458 // set the supported fonts into combobox to use its only
2459 setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2461 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2462 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2464 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2465 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2466 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2468 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2469 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2471 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2472 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2474 QStringList aListOfLengthUnits;
2475 aListOfLengthUnits << "m";
2476 aListOfLengthUnits << "cm";
2477 aListOfLengthUnits << "mm";
2478 aListOfLengthUnits << "in.";
2479 aListOfLengthUnits << "ft.";
2481 QStringList aListOfAngUnits;
2482 aListOfAngUnits << "rad";
2483 aListOfAngUnits << "deg";
2485 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2486 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2488 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2489 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2491 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2492 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2494 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2495 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2496 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2498 addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2499 LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2501 // --------------------------------------------------------------------------
2502 // Shape annotation preferences
2503 // --------------------------------------------------------------------------
2505 const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2506 setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2508 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2509 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2510 const int aShapeAnnFont =
2511 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2513 int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2514 setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2515 setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2516 setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2518 const int aShapeAnnLineWidth =
2519 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2521 setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2522 setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2524 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2526 const int aShapeAnnLineStyle =
2527 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2529 QStringList aLineStyleList;
2530 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2531 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2532 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2533 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2535 QList<QVariant> aLineStyleIds;
2536 aLineStyleIds.append(0);
2537 aLineStyleIds.append(1);
2538 aLineStyleIds.append(2);
2539 aLineStyleIds.append(3);
2541 setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2542 setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2544 // --------------------------------------------------------------------------
2545 // Isoline drawing preferences
2546 // --------------------------------------------------------------------------
2548 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2549 setPreferenceProperty( isoGroup, "columns", 2 );
2550 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2551 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2552 setPreferenceProperty( isoU, "min", 0 );
2553 setPreferenceProperty( isoU, "max", 100000 );
2554 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2555 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2556 setPreferenceProperty( isoV, "min", 0 );
2557 setPreferenceProperty( isoV, "max", 100000 );
2559 // Quantities with individual precision settings
2560 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2561 setPreferenceProperty( precGroup, "columns", 2 );
2563 const int nbQuantities = 8;
2564 int prec[nbQuantities], ii = 0;
2565 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2566 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2567 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2568 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2569 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2570 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2571 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2572 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2573 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2574 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2575 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2576 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2577 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2578 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2579 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2580 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2582 // Set property for precision value for spinboxes
2583 for ( ii = 0; ii < nbQuantities; ii++ ){
2584 setPreferenceProperty( prec[ii], "min", -14 );
2585 setPreferenceProperty( prec[ii], "max", 14 );
2586 setPreferenceProperty( prec[ii], "precision", 2 );
2589 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2590 setPreferenceProperty( VertexGroup, "columns", 2 );
2592 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2593 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2595 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2596 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2598 // Set property for default display mode
2599 QStringList aModesList;
2600 aModesList.append( tr("MEN_WIREFRAME") );
2601 aModesList.append( tr("MEN_SHADING") );
2602 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2603 aModesList.append( tr("MEN_TEXTURE") );
2605 QList<QVariant> anIndexesList;
2606 anIndexesList.append(0);
2607 anIndexesList.append(1);
2608 anIndexesList.append(2);
2609 anIndexesList.append(3);
2611 setPreferenceProperty( dispmode, "strings", aModesList );
2612 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2614 // Set property for top level display mode
2615 QStringList aTopModesList;
2616 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2617 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2618 aTopModesList.append( tr("MEN_WIREFRAME") );
2619 aTopModesList.append( tr("MEN_SHADING") );
2620 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2622 QList<QVariant> aTopIndexesList;
2623 aTopIndexesList.append(0);
2624 aTopIndexesList.append(1);
2625 aTopIndexesList.append(2);
2626 aTopIndexesList.append(3);
2627 aTopIndexesList.append(4);
2629 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2630 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2632 // Set property for step value for spinboxes
2633 setPreferenceProperty( step, "min", 1 );
2634 setPreferenceProperty( step, "max", 10000 );
2635 setPreferenceProperty( step, "precision", 3 );
2637 // Set property for trandparency value for spinboxes
2638 setPreferenceProperty( transparency, "min", 0 );
2639 setPreferenceProperty( transparency, "max", 100 );
2641 // Set property for deflection value for spinboxes
2642 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2643 setPreferenceProperty( defl, "max", 1.0 );
2644 setPreferenceProperty( defl, "step", 1.0e-04 );
2645 setPreferenceProperty( defl, "precision", 6 );
2647 // Set property for default material
2648 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2650 // Set property vertex marker type
2651 QList<QVariant> aMarkerTypeIndicesList;
2652 QList<QVariant> aMarkerTypeIconsList;
2654 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2655 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2656 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2657 aMarkerTypeIndicesList << (i-1);
2658 aMarkerTypeIconsList << pixmap;
2661 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2662 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2664 // Set property for vertex marker scale
2665 QList<QVariant> aMarkerScaleIndicesList;
2666 QStringList aMarkerScaleValuesList;
2668 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2669 aMarkerScaleIndicesList << iii;
2670 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2673 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2674 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2676 // Scalar bar for field step presentation
2677 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2678 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2680 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2681 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2682 setPreferenceProperty( sbXPosition, "min", 0 );
2683 setPreferenceProperty( sbXPosition, "max", 1 );
2684 setPreferenceProperty( sbXPosition, "step", 0.05 );
2686 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2687 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2688 setPreferenceProperty( sbYPosition, "min", 0 );
2689 setPreferenceProperty( sbYPosition, "max", 1 );
2690 setPreferenceProperty( sbYPosition, "step", 0.05 );
2692 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2693 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2694 setPreferenceProperty( sbWidth, "min", 0 );
2695 setPreferenceProperty( sbWidth, "max", 1 );
2696 setPreferenceProperty( sbWidth, "step", 0.05 );
2698 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2699 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2700 setPreferenceProperty( sbHeight, "min", 0 );
2701 setPreferenceProperty( sbHeight, "max", 1 );
2702 setPreferenceProperty( sbHeight, "step", 0.05 );
2704 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2705 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2706 setPreferenceProperty( sbTextHeight, "min", 6 );
2707 setPreferenceProperty( sbTextHeight, "max", 24 );
2708 setPreferenceProperty( sbTextHeight, "step", 1 );
2710 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2711 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2712 setPreferenceProperty( sbNbIntervals, "min", 2 );
2713 setPreferenceProperty( sbNbIntervals, "max", 64 );
2714 setPreferenceProperty( sbNbIntervals, "step", 1 );
2716 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2717 setPreferenceProperty( originGroup, "columns", 2 );
2719 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2720 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2721 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2722 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2724 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2725 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2727 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2728 setPreferenceProperty( operationsGroup, "columns", 2 );
2730 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2731 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2733 addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2734 LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2736 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2738 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2740 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2741 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2743 QStringList aHierarchyTypeList;
2744 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2745 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2746 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2748 QList<QVariant> aHierarchyTypeIndexesList;
2749 aHierarchyTypeIndexesList.append(0);
2750 aHierarchyTypeIndexesList.append(1);
2751 aHierarchyTypeIndexesList.append(2);
2753 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2754 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2756 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2757 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2759 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2761 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2762 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2764 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2765 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2766 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2767 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2768 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2769 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2770 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2771 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2773 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2774 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2775 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2776 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2777 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2778 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2785 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2787 if (section == "Geometry") {
2788 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2789 if (param == QString("SettingsGeomStep")) {
2790 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2791 EmitSignalDefaultStepValueChanged(spin_step);
2793 else if (param == QString("toplevel_color")) {
2794 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2795 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2797 else if (param == QString("toplevel_dm")) {
2798 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2800 else if (param == QString("scalar_bar_x_position") ||
2801 param == QString("scalar_bar_y_position") ||
2802 param == QString("scalar_bar_width") ||
2803 param == QString("scalar_bar_height") ||
2804 param == QString("scalar_bar_text_height") ||
2805 param == QString("scalar_bar_nb_intervals")) {
2806 updateFieldColorScale();
2808 else if ( param == QString("dimensions_color") ||
2809 param == QString("dimensions_line_width") ||
2810 param == QString("dimensions_font") ||
2811 param == QString("dimensions_arrow_length") ||
2812 param == QString("dimensions_show_units") ||
2813 param == QString("dimensions_length_units") ||
2814 param == QString("dimensions_angle_units") ||
2815 param == QString("dimensions_use_text3d") ||
2816 param == QString("shape_annotation_font_color") ||
2817 param == QString("shape_annotation_line_color") ||
2818 param == QString("shape_annotation_font") ||
2819 param == QString("shape_annotation_line_width") ||
2820 param == QString("shape_annotation_autohide") ||
2821 param == QString("shape_annotation_line_style") ||
2822 param == QString("shape_annotation_line_style") ||
2823 param == QString("label_color") )
2825 SalomeApp_Application* anApp = getApp();
2831 GEOM_Displayer aDisplayer;
2833 ViewManagerList aVMs;
2834 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2835 ViewManagerList::Iterator anIt = aVMs.begin();
2836 for ( ; anIt != aVMs.end(); ++anIt )
2838 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2844 SALOME_ListIO aVisible;
2845 aViewer->GetVisible( aVisible );
2847 GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2848 if ( anAnnotationMgr ) {
2849 SALOME_ListIteratorOfListIO anIter( aVisible );
2850 while ( anIter.More() ) {
2851 if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2852 aVisible.Remove( anIter );
2860 aDisplayer.Redisplay( aVisible, false, aViewer );
2862 if ( param == QString( "label_color" ) ) {
2863 ViewManagerList aVMsVTK;
2864 anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2865 ViewManagerList::Iterator anIt = aVMsVTK.begin();
2866 for ( ; anIt != aVMsVTK.end(); ++anIt )
2868 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2873 SALOME_ListIO aVisible;
2874 aViewer->GetVisible( aVisible );
2875 aDisplayer.Redisplay( aVisible, false, aViewer );
2878 aDisplayer.UpdateViewer();
2880 else if ( param.startsWith( "dependency_tree") )
2881 emit SignalDependencyTreeParamChanged( section, param );
2885 LightApp_Displayer* GeometryGUI::displayer()
2888 myDisplayer = new GEOM_Displayer();
2892 void GeometryGUI::setLocalSelectionMode(const int mode)
2894 myLocalSelectionMode = mode;
2897 int GeometryGUI::getLocalSelectionMode() const
2899 return myLocalSelectionMode;
2902 const char gSeparator = '_'; // character used to separate parameter names
2903 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2906 * \brief Store visual parameters
2908 * This method is called just before the study document is saved.
2909 * Store visual parameters in AttributeParameter attribute(s)
2911 void GeometryGUI::storeVisualParameters (int savePoint)
2913 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2914 if ( !appStudy || !appStudy->studyDS() )
2917 _PTR(Study) studyDS = appStudy->studyDS();
2919 // componentName is used for encoding of entries when storing them in IParameters
2920 std::string componentName = myComponentGeom->ComponentDataType();
2921 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2922 //if (!aSComponent) return;
2925 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2926 componentName.c_str(),
2928 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2930 QSet<QString> anEntriesToStoreShared;
2931 QList<SUIT_ViewManager*> lst;
2932 QList<SUIT_ViewManager*>::Iterator it;
2934 GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
2936 // main cycle to store parameters of displayed objects
2938 getApp()->viewManagers(lst);
2939 for (it = lst.begin(); it != lst.end(); it++) {
2940 SUIT_ViewManager* vman = *it;
2941 QString vType = vman->getType();
2942 SUIT_ViewModel* vmodel = vman->getViewModel();
2943 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
2945 int aMgrId = vman->getGlobalId();
2946 // saving VTK actors properties
2947 QVector<SUIT_ViewWindow*> views = vman->getViews();
2948 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2949 const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
2950 ObjMap::ConstIterator o_it = anObjects.begin();
2951 for (; o_it != anObjects.end(); o_it++) {
2952 const PropMap& aProps = o_it.value();
2954 //Check that object exists in the study
2955 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toUtf8().data() ) );
2956 if ( !obj || !(aProps.count() > 0))
2958 // entry is "encoded" = it does NOT contain component address, since it is a
2959 // subject to change on next component loading
2961 std::string entry = ip->encodeEntry(o_it.key().toUtf8().data(), componentName);
2963 _PTR(GenericAttribute) anAttr;
2964 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2967 // remember entry of object to store shared GEOM properties
2968 // (e.g. dimension properties).
2969 if ( vType == OCCViewer_Viewer::Type() )
2971 anEntriesToStoreShared.insert( o_it.key() );
2974 QString param, occParam = vType;
2975 occParam += GEOM::sectionSeparator();
2976 occParam += QString::number(aMgrId);
2977 occParam += GEOM::sectionSeparator();
2979 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2980 param = occParam + GEOM::propertyName( GEOM::Visibility );
2981 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2984 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2985 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2986 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2989 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2990 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2992 val << QString::number(c.redF());
2993 val << QString::number(c.greenF());
2994 val << QString::number(c.blueF());
2995 param = occParam + GEOM::propertyName( GEOM::Color );
2996 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2999 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
3000 param = occParam + GEOM::propertyName( GEOM::Texture );
3001 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
3004 if (vType == SVTK_Viewer::Type()) {
3005 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
3006 param = occParam + GEOM::propertyName( GEOM::Opacity );
3007 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
3009 } else if (vType == SOCC_Viewer::Type()) {
3010 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3011 param = occParam + GEOM::propertyName( GEOM::Transparency );
3012 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3015 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3016 param = occParam + GEOM::propertyName( GEOM::TopLevel );
3017 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3021 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3022 param = occParam + GEOM::propertyName( GEOM::NbIsos );
3023 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3026 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3027 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3028 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3031 if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3032 param = occParam + GEOM::propertyName( GEOM::Vertices );
3033 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3036 if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3037 param = occParam + GEOM::propertyName( GEOM::ShowName );
3038 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3041 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3042 param = occParam + GEOM::propertyName( GEOM::Deflection );
3043 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3046 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3047 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3048 param = occParam + GEOM::propertyName( GEOM::PointMarker );
3049 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3052 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3053 param = occParam + GEOM::propertyName( GEOM::Material );
3054 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3057 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3058 param = occParam + GEOM::propertyName( GEOM::LineWidth );
3059 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3062 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3063 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3064 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3067 if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3068 std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3069 o_it.key().toUtf8().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3070 if (!anAnnotationInfo.empty()) {
3071 param = occParam + "ShapeAnnotationVisibleItems";
3072 ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3075 } // object iterator
3077 } // for (viewManagers)
3079 // store shape annotation and dimension attributes of objects:
3080 // since the displayed object always persists in property map, we remember the object entries
3081 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3082 const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3083 const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3084 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3085 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3087 std::string aStudyEntry = (*aEntryIt).toUtf8().data();
3088 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3090 // store dimension parameters
3091 GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3092 if ( aDimensions.GetNumber() != 0 ) {
3093 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toUtf8().data() );
3096 _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3097 const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3098 if ( !aShapeAnnAttr.IsNull() ) {
3099 ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toUtf8().data() );
3105 * \brief Restore visual parameters
3107 * This method is called after the study document is opened.
3108 * Restore visual parameters from AttributeParameter attribute(s)
3110 void GeometryGUI::restoreVisualParameters (int savePoint)
3112 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3113 if (!appStudy || !appStudy->studyDS())
3115 _PTR(Study) studyDS = appStudy->studyDS();
3117 // componentName is used for encoding of entries when storing them in IParameters
3118 std::string componentName = myComponentGeom->ComponentDataType();
3119 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3120 //if (!aSComponent) return;
3123 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3124 componentName.c_str(),
3126 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3128 std::vector<std::string> entries = ip->getEntries();
3130 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3132 // entry is a normal entry - it should be "decoded" (setting base address of component)
3133 QString entry (ip->decodeEntry(*entIt).c_str());
3135 // Check that the entry corresponds to a real object in the Study
3136 // as the object may be deleted or modified after the visual state is saved.
3137 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
3138 if (!so) continue; //Skip the not existent entry
3140 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3141 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3143 std::vector<std::string>::iterator namesIt = paramNames.begin();
3144 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3146 // actors are stored in a map after displaying of them for
3147 // quicker access in the future: map < viewID to actor >
3148 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
3149 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3151 QString viewerTypStr;
3152 QString viewIndexStr;
3154 QVector<PropMap> aListOfMap;
3156 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3158 // visual parameters are stored in strings as follows:
3159 // 1) ViewerType_ViewIndex_ParamName
3160 // 2) ViewerType_ParamName (shared for GEOM module)
3161 // '_' is used as separator and should not be used in viewer type or parameter names.
3162 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3164 bool isShared = lst.size() == 2;
3165 bool isViewer = lst.size() == 3;
3166 if ( !isShared && !isViewer )
3171 // shared visual parameters
3174 QString aParamNameStr( lst[1] );
3175 QString aValuesStr( (*valuesIt).c_str() );
3177 // shared dimension properties are stored as attribute
3178 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3180 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3181 aDimensionProp.SaveToAttribute( entry.toUtf8().data() );
3183 else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3185 Handle(GEOMGUI_AnnotationAttrs) anAttr =
3186 GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3188 anAttr->ImportFromPropertyString( aValuesStr );
3194 // per view visual parameters
3195 viewerTypStr = lst[0];
3196 viewIndexStr = lst[1];
3197 QString paramNameStr = lst[2];
3200 viewIndex = viewIndexStr.toUInt(&ok);
3201 if (!ok) // bad conversion of view index to integer
3204 if ((viewIndex + 1) > aListOfMap.count()) {
3205 aListOfMap.resize(viewIndex + 1);
3208 QString val((*valuesIt).c_str());
3209 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3210 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3211 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3212 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3213 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3214 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3215 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3216 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3217 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3218 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3219 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3220 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3221 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3222 QStringList rgb = val.split(GEOM::subSectionSeparator());
3223 if (rgb.count() == 3) {
3224 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3225 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3227 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3228 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3229 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3230 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3231 } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3232 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3233 } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3234 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3235 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3236 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3237 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3238 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3239 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3240 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3241 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3242 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3243 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3244 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3245 } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3246 aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3249 } // for names/parameters iterator
3251 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3253 for (int index = 0; index < aListOfMap.count(); index++) {
3254 appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3256 //Get Visibility property of the current PropMap
3257 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3258 SUIT_ViewManager* vman = lst.at(index);
3259 SUIT_ViewModel* vmodel = vman->getViewModel();
3260 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3261 displayer()->Display(entry, true, aView);
3263 if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3264 PropMap& aProps = aListOfMap[index];
3265 if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3266 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3267 GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3272 } // for entries iterator
3274 // update all VTK and OCC views
3275 QList<SUIT_ViewManager*> lst;
3276 getApp()->viewManagers(lst);
3277 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3278 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3281 if (vmodel->getType() == SVTK_Viewer::Type()) {
3282 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3283 vtkView->getRenderer()->ResetCameraClippingRange();
3286 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3287 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3288 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3294 if ( myTextTreeWdg ) {
3295 myTextTreeWdg->updateTree();
3299 // Compute current name mode of the viewer
3300 void UpdateNameMode( SalomeApp_Application* app )
3302 bool isMode = false;
3303 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3304 SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3305 GEOM_Displayer displayer;
3306 int aMgrId = viewWindow->getViewManager()->getGlobalId();
3308 SALOME_View* window = displayer.GetActiveView();
3309 if ( !window ) return;
3311 SALOME_ListIO anIOlst;
3312 window->GetVisible( anIOlst );
3314 for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3315 Handle( SALOME_InteractiveObject ) io = It.Value();
3316 QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3317 bool isIONameMode = v.isValid() ? v.toBool() : false;
3321 viewWindow->setProperty( "NameMode", isMode );
3324 void GeometryGUI::onViewAboutToShow()
3326 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3327 QAction* a = action( GEOMOp::OpSwitchVectors );
3328 QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3329 QAction* aNameAction = action( GEOMOp::OpSwitchName );
3331 a->setEnabled(true);
3332 bool vmode = window->property("VectorsMode").toBool();
3333 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3334 aVerticesAction->setEnabled(true);
3335 vmode = window->property("VerticesMode").toBool();
3336 aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3337 UpdateNameMode( getApp() );
3338 aNameAction->setEnabled(true);
3339 vmode = window->property("NameMode").toBool();
3340 aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3342 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3343 a->setEnabled(false);
3344 aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3345 aVerticesAction->setEnabled(false);
3346 aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3347 aNameAction->setEnabled(false);
3352 \brief Return action by id
3353 \param id identifier of the action
3356 QAction* GeometryGUI::getAction(const int id) {
3361 \brief GEOM module message handler
3363 This method can be re-implemented in the subclasses.
3364 This is a GEOM module message handler.
3366 \param msg the message received.
3368 void GeometryGUI::message(const QString& msg)
3371 QStringList data = msg.split("/");
3372 const int nbStrings = data.count();
3374 if (nbStrings > 0) {
3375 if (data[0] == "modified") {
3377 QString anIOR = nbStrings > 1 ? data[1] : QString();
3379 if ( anIOR.isEmpty() ) {
3383 // Get the geom object.
3384 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3386 // Clear the shape buffer
3387 GeometryGUI::ClearShapeBuffer (anObj);
3393 \brief Clears the shape buffer.
3395 This is a static method. It clears the shape buffer.
3397 \param theObj the object
3399 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3401 if ( CORBA::is_nil( theObj ) )
3404 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3405 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3406 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3408 SalomeApp_Application* app =
3409 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3410 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3415 _PTR(Study) aStudy = appStudy->studyDS();
3420 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3424 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3425 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3426 _PTR(GenericAttribute) anAttr;
3427 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3428 _PTR(AttributeIOR) anIOR ( anAttr );
3429 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3430 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3436 \brief Returns the object from IOR.
3438 This is a static method. It returns the object from its IOR.
3440 \param IOR object IOR
3441 \return GEOM object.
3443 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3445 GEOM::GEOM_Object_var geomObj;
3446 if ( !IOR.isEmpty() ) {
3447 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3448 ( IOR.toLatin1().constData() );
3449 if ( !CORBA::is_nil( corbaObj ) )
3450 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3452 return geomObj._retn();
3456 \brief Returns IOR of the object.
3458 This is a static method. It returns the object's IOR.
3460 \param object the GEOM object.
3461 \return object's IOR.
3463 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3466 if ( !CORBA::is_nil( object ) ) {
3467 CORBA::String_var anIOR =
3468 SalomeApp_Application::orb()->object_to_string( object );
3475 \brief Check if this object is can't be renamed in place
3477 This method can be re-implemented in the subclasses.
3478 Return true in case if object isn't reference or component (module root).
3480 \param entry column id
3481 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3483 bool GeometryGUI::renameAllowed( const QString& entry) const {
3485 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3486 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3487 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3489 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3493 Rename object by entry.
3494 \param entry entry of the object
3495 \param name new name of the object
3496 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3498 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3500 bool result = false;
3502 SalomeApp_Application* app =
3503 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3504 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3509 _PTR(Study) aStudy = appStudy->studyDS();
3514 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3516 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3520 _PTR(SObject) obj ( aStudy->FindObjectID(qUtf8Printable(entry)) );
3521 _PTR(GenericAttribute) anAttr;
3523 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3524 _PTR(AttributeName) aName (anAttr);
3526 aName->SetValue( name.toUtf8().data() ); // rename the SObject
3527 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3528 if (!CORBA::is_nil(anObj)) {
3529 anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
3530 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3531 emit SignalTextTreeRenameObject( entry );
3539 void GeometryGUI::updateMaterials()
3541 LightApp_Preferences* pref = preferences();
3543 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3544 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3545 if ( !materials.contains( currentMaterial ) )
3546 // user material set as default in the preferences, might be removed
3547 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3549 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3551 setPreferenceProperty( prefItem->id(),
3552 "strings", materials );
3553 prefItem->retrieve();
3559 \brief Check if the module allows "drag" operation of its objects.
3561 Overloaded from LightApp_Module class.
3563 This function is a part of the general drag-n-drop mechanism.
3564 The goal of this function is to check data object passed as a parameter
3565 and decide if it can be dragged or no.
3567 \param what data object being tested for drag operation
3568 \return \c true if module allows dragging of the specified object
3569 \sa isDropAccepted(), dropObjects()
3571 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3573 // we allow dragging object under root and object from folder
3574 int aLevel = what->level();
3575 bool anObjectInFolder = false;
3577 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3579 _PTR(SObject) aSO = dataObj->object();
3581 _PTR(GenericAttribute) anAttr;
3582 _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3583 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3584 _PTR(AttributeLocalID) aLocalID( anAttr );
3585 anObjectInFolder = aLocalID->Value() == 999;
3590 return aLevel == 2 || anObjectInFolder;
3594 \brief Check if the module allows "drop" operation on the given object.
3596 Overloaded from LightApp_Module class.
3598 This function is a part of the general drag-n-drop mechanism.
3599 The goal of this function is to check data object passed as a parameter
3600 and decide if it can be used as a target for the "drop" operation.
3601 The processing of the drop operation itself is done in the dropObjects() function.
3603 \param where target data object
3604 \return \c true if module supports dropping on the \a where data object
3605 \sa isDraggable(), dropObjects()
3607 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3609 // we allow dropping into folder and top-level GEOM object
3610 int aLevel = where->level();
3611 bool isFolder = false;
3613 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3615 _PTR(SObject) aSO = dataObj->object();
3617 _PTR(GenericAttribute) anAttr;
3618 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3619 _PTR(AttributeLocalID) aLocalID( anAttr );
3620 isFolder = aLocalID->Value() == 999;
3625 return aLevel == 1 || isFolder;
3629 \brief Complete drag-n-drop operation.
3631 Overloaded from LightApp_Module class.
3633 This function is a part of the general drag-n-drop mechanism.
3634 Its goal is to handle dropping of the objects being dragged according
3635 to the chosen operation (move). The dropping is performed in the
3636 context of the parent data object \a where and the \a row (position in the
3637 children index) at which the data should be dropped. If \a row is equal to -1,
3638 this means that objects are added to the end of the children list.
3640 \param what objects being dropped
3641 \param where target data object
3642 \param row child index at which the drop operation is performed
3643 \param action drag-n-drop operation (Qt::DropAction) - move
3645 \sa isDraggable(), isDropAccepted()
3647 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3648 const int row, Qt::DropAction action )
3650 if (action != Qt::CopyAction && action != Qt::MoveAction)
3651 return; // unsupported action
3653 // get parent object
3654 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3655 if ( !dataObj ) return; // wrong parent
3656 _PTR(SObject) parentObj = dataObj->object();
3658 // Find the current Study and StudyBuilder
3659 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3660 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3661 // collect all parents of the target node
3662 QStringList parentIDs;
3663 _PTR(SObject) parent = parentObj;
3664 while( !parent->IsNull() ) {
3665 parentIDs << parent->GetID().c_str();
3666 parent = aUseCaseBuilder->GetFather(parent);
3669 // collect objects being dropped
3670 GEOM::object_list_var objects = new GEOM::object_list();
3671 objects->length( what.count() );
3673 for ( int i = 0; i < what.count(); i++ ) {
3674 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3675 if ( !dataObj ) continue; // skip wrong objects
3676 _PTR(SObject) sobj = dataObj->object();
3677 // check that dropped object is not a parent of target object
3678 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3679 return; // it's not allowed to move node into it's child
3681 objects[i] = _CAST(SObject, sobj)->GetSObject();
3684 objects->length( count );
3686 // call engine function
3687 GetGeomGen()->Move( objects.in(), // what
3688 _CAST(SObject, parentObj)->GetSObject(), // where
3691 // update Object browser
3692 getApp()->updateObjectBrowser( false );
3695 void GeometryGUI::emitDimensionsUpdated( QString entry )
3697 emit DimensionsUpdated( entry );
3700 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3702 emit SignalAnnotationsUpdated( entry );