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::OpMaterialMenu: // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
539 case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
540 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
541 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
542 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
543 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
544 case GEOMOp::OpClsBringToFront: //
545 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
546 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
547 #ifndef DISABLE_GRAPHICSVIEW
548 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
550 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
551 libName = "GEOMToolsGUI";
553 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
554 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
555 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
556 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
557 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
558 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
559 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
560 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
561 case GEOMOp::OpHide: // MENU VIEW - ERASE
562 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
563 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
564 case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
565 case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
566 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
567 case GEOMOp::OpShading: // POPUP MENU - SHADING
568 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
569 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
570 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
571 case GEOMOp::OpVertices: // POPUP MENU - VERTICES
572 case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
573 libName = "DisplayGUI";
575 case GEOMOp::OpPoint: // MENU BASIC - POINT
576 case GEOMOp::OpLine: // MENU BASIC - LINE
577 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
578 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
579 case GEOMOp::OpArc: // MENU BASIC - ARC
580 case GEOMOp::OpVector: // MENU BASIC - VECTOR
581 case GEOMOp::OpPlane: // MENU BASIC - PLANE
582 case GEOMOp::OpCurve: // MENU BASIC - CURVE
583 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
584 libName = "BasicGUI";
586 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
587 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
588 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
589 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
590 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
591 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
592 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
593 libName = "PrimitiveGUI";
595 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
596 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
597 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
598 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
599 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
600 case GEOMOp::OpThickness: // MENU GENERATION - THICKNESS
601 libName = "GenerationGUI";
603 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
604 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
605 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
606 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
607 case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
609 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
611 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
612 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
613 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
614 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
615 case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
616 libName = "EntityGUI";
618 case GEOMOp::OpEdge: // MENU BUILD - EDGE
619 case GEOMOp::OpWire: // MENU BUILD - WIRE
620 case GEOMOp::OpFace: // MENU BUILD - FACE
621 case GEOMOp::OpShell: // MENU BUILD - SHELL
622 case GEOMOp::OpSolid: // MENU BUILD - SOLID
623 case GEOMOp::OpCompound: // MENU BUILD - COMPOUND
624 libName = "BuildGUI";
626 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
627 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
628 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
629 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
630 libName = "BooleanGUI";
632 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
633 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
634 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
635 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
636 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
637 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
638 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
639 case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
640 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
641 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
642 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
643 case GEOMOp::OpExtension: // MENU TRANSFORMATION - EXTENSION
644 libName = "TransformationGUI";
646 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
647 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
648 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
649 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
650 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
651 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
652 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
653 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
654 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
655 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
656 case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
657 case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
658 libName = "OperationGUI";
660 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
661 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
662 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
663 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
664 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
665 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
666 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
667 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
668 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
669 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
670 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
671 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
672 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
673 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
674 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
675 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
676 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
677 case GEOMOp::OpInspectObj: // MENU REPAIR - INSPECT OBJECT
678 libName = "RepairGUI";
680 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
681 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
682 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
683 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
684 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
685 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
686 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
687 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
688 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
689 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
690 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
691 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
692 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
693 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
694 case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
695 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
696 case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
697 case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
698 case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
699 #ifndef DISABLE_PLOT2DVIEWER
700 case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
702 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
703 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
704 case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
705 case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
706 libName = "MeasureGUI";
708 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
709 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
710 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
711 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
712 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
713 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
714 libName = "GroupGUI";
716 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
717 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
718 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
719 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
720 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
721 libName = "BlocksGUI";
723 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
724 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
725 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
726 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
727 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
728 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
729 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
730 //libName = "AdvancedGUI";
733 if (myPluginActions.contains(id)) {
734 libName = myPluginActions[id].first;
736 GEOMPluginGUI* library = 0;
737 if ( !libName.isEmpty() ) {
739 libName = libName + ".dll";
740 #elif defined(__APPLE__)
741 libName = QString( "lib" ) + libName + ".dylib";
743 libName = QString( "lib" ) + libName + ".so";
745 library = getPluginLibrary( libName );
748 // call method of corresponding GUI library
750 //QString action ("%1");
751 //action = action.arg(id);
753 //if( !theParam.isValid() )
754 library->OnGUIEvent( myPluginActions[id].second, desk );
756 // library->OnGUIEvent( id, desk, theParam);
759 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
761 updateCreationInfo();
767 GEOMGUI* library = 0;
768 if ( !libName.isEmpty() ) {
770 libName = libName + ".dll";
771 #elif defined(__APPLE__)
772 libName = QString( "lib" ) + libName + ".dylib";
774 libName = QString( "lib" ) + libName + ".so";
776 library = getLibrary( libName );
779 // call method of corresponding GUI library
781 if( !theParam.isValid() )
782 library->OnGUIEvent( id, desk );
784 library->OnGUIEvent( id, desk, theParam);
787 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
789 updateCreationInfo();
792 //=================================================================================
793 // function : GeometryGUI::activateOperation()
795 //=================================================================================
796 bool GeometryGUI::activateOperation( int actionId )
798 OnGUIEvent(actionId);
802 //=================================================================================
803 // function : GeometryGUI::activateOperation()
805 //=================================================================================
806 bool GeometryGUI::activateOperation( const QString& actionId )
810 int id = actionId.toInt(&isOk);
817 //=================================================================================
818 // function : GeometryGUI::activateOperation()
820 //=================================================================================
821 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
825 QString pluginLib = plugin;
826 // TODO: if <plugin> is a plugin name, find plugin library name
827 if (myPluginLibs.contains(plugin))
828 pluginLib = myPluginLibs[plugin];
830 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
831 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
832 const PluginAction& anAction = actionsIter.value();
833 if (anAction.first == pluginLib && anAction.second == actionId) {
834 // activate operation
835 OnGUIEvent(actionsIter.key());
843 //=================================================================================
844 // function : GeometryGUI::OnKeyPress()
845 // purpose : Called when any key is pressed by user [static]
846 //=================================================================================
847 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
849 if ( !application() )
851 foreach ( GEOMGUI* lib, myGUIMap )
852 lib->OnKeyPress( e, application()->desktop(), w );
855 //=================================================================================
856 // function : GeometryGUI::OnMouseMove()
857 // purpose : Manages mouse move events [static]
858 //=================================================================================
859 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
861 if ( !application() )
863 foreach ( GEOMGUI* lib, myGUIMap )
864 lib->OnMouseMove( e, application()->desktop(), w );
867 //=================================================================================
868 // function : GeometryGUI::OnMouseRelease()
869 // purpose : Manages mouse release events [static]
870 //=================================================================================
871 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
873 if ( !application() )
875 foreach ( GEOMGUI* lib, myGUIMap )
876 lib->OnMouseRelease( e, application()->desktop(), w );
879 //=================================================================================
880 // function : GeometryGUI::OnMousePress()
881 // purpose : Manage mouse press events [static]
882 //=================================================================================
883 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
885 if ( !application() )
887 foreach ( GEOMGUI* lib, myGUIMap )
888 lib->OnMousePress( e, application()->desktop(), w );
891 //=======================================================================
892 // function : createGeomAction
894 //=======================================================================
895 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
896 const int accel, const bool toggle, const QString& shortcutAction )
898 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
899 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
900 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
902 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
904 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
905 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
907 application()->desktop(),
909 this, SLOT( OnGUIEvent() ),
913 //=======================================================================
914 // function : createOriginAndBaseVectors
916 //=======================================================================
917 void GeometryGUI::createOriginAndBaseVectors()
919 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
920 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
922 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
926 if ( !CORBA::is_nil( GetGeomGen() ) ) {
927 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
928 if ( !aBasicOperations->_is_nil() ) {
929 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
930 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
931 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
932 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
933 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
934 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
936 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
937 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
938 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
939 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
940 anOrigin->UnRegister();
944 aBasicOperations->UnRegister();
946 getApp()->updateObjectBrowser( true );
952 //=======================================================================
953 // function : GeometryGUI::initialize()
954 // purpose : Called when GEOM module is created
955 //=======================================================================
956 void GeometryGUI::initialize( CAM_Application* app )
958 SalomeApp_Module::initialize( app );
960 // ----- create actions --------------
962 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
964 createGeomAction( GEOMOp::OpPoint, "POINT" );
965 createGeomAction( GEOMOp::OpLine, "LINE" );
966 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
967 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
968 createGeomAction( GEOMOp::OpArc, "ARC" );
969 createGeomAction( GEOMOp::OpCurve, "CURVE" );
970 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
971 createGeomAction( GEOMOp::OpVector, "VECTOR" );
972 createGeomAction( GEOMOp::OpPlane, "PLANE" );
973 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
974 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
975 createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
977 createGeomAction( GEOMOp::OpBox, "BOX" );
978 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
979 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
980 createGeomAction( GEOMOp::OpTorus, "TORUS" );
981 createGeomAction( GEOMOp::OpCone, "CONE" );
982 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
983 createGeomAction( GEOMOp::OpDisk, "DISK" );
985 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
986 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
987 createGeomAction( GEOMOp::OpFilling, "FILLING" );
988 createGeomAction( GEOMOp::OpPipe, "PIPE" );
989 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
990 createGeomAction( GEOMOp::OpThickness, "THICKNESS" );
992 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
993 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
994 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
995 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
996 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
998 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
999 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
1001 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
1003 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
1004 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
1006 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
1007 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
1008 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
1010 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1012 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1013 createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1015 createGeomAction( GEOMOp::OpEdge, "EDGE" );
1016 createGeomAction( GEOMOp::OpWire, "WIRE" );
1017 createGeomAction( GEOMOp::OpFace, "FACE" );
1018 createGeomAction( GEOMOp::OpShell, "SHELL" );
1019 createGeomAction( GEOMOp::OpSolid, "SOLID" );
1020 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
1022 createGeomAction( GEOMOp::OpFuse, "FUSE" );
1023 createGeomAction( GEOMOp::OpCommon, "COMMON" );
1024 createGeomAction( GEOMOp::OpCut, "CUT" );
1025 createGeomAction( GEOMOp::OpSection, "SECTION" );
1027 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
1028 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
1029 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
1030 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
1031 createGeomAction( GEOMOp::OpScale, "SCALE" );
1032 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
1033 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
1034 createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
1035 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1036 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
1037 createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
1039 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
1040 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
1041 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
1042 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
1043 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
1044 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
1045 createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
1046 createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
1047 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
1048 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
1049 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
1050 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
1052 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1053 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
1054 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
1056 createGeomAction( GEOMOp::OpSewing, "SEWING" );
1057 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
1058 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
1059 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
1060 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
1061 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1062 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1063 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1064 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1065 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1066 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1067 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1068 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1069 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1070 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1071 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1072 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1073 createGeomAction( GEOMOp::OpInspectObj, "INSPECT_OBJECT" );
1075 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1076 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1077 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1078 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1079 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1080 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1081 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1082 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1083 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1084 createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
1085 createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
1086 createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1088 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1089 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1090 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1091 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1092 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1093 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1094 createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
1095 #ifndef DISABLE_PLOT2DVIEWER
1096 createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
1099 #ifndef DISABLE_PYCONSOLE
1100 #ifdef _DEBUG_ // PAL16821
1101 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1105 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1106 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1107 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1108 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1109 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1110 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1111 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1112 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1113 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1114 createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
1115 createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
1116 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1117 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1118 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1119 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1120 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1121 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1122 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1123 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1124 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1125 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1126 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1127 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1128 createGeomAction( GEOMOp::OpHide, "ERASE" );
1130 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1131 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1132 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1133 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1134 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1135 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1136 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1137 createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
1138 createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
1139 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1140 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1141 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1142 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1143 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1144 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1145 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1146 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1147 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1148 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1149 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1150 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1151 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1152 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1153 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1154 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1155 createGeomAction( GEOMOp::OpMaterialMenu, "POP_MATERIAL_PROPERTIES");
1156 action(GEOMOp::OpMaterialMenu)->setMenu( new QMenu() );
1157 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1158 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1159 #ifndef DISABLE_GRAPHICSVIEW
1160 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1162 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1163 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1164 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1165 createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1166 createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1168 // Create actions for increase/decrease transparency shortcuts
1169 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1170 "Geometry:Increase transparency");
1171 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1172 "Geometry:Decrease transparency");
1174 // Create actions for increase/decrease number of isolines
1175 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1176 "Geometry:Increase number of isolines");
1177 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1178 "Geometry:Decrease number of isolines");
1180 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1181 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1182 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1183 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1184 //@@ 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 @@//
1186 // ---- create menus --------------------------
1188 /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1190 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1191 createMenu( GEOMOp::OpDelete, editId, -1 );
1193 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1195 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1196 createMenu( GEOMOp::OpPoint, basicId, -1 );
1197 createMenu( GEOMOp::OpLine, basicId, -1 );
1198 createMenu( GEOMOp::OpCircle, basicId, -1 );
1199 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1200 createMenu( GEOMOp::OpArc, basicId, -1 );
1201 createMenu( GEOMOp::OpCurve, basicId, -1 );
1202 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1203 createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1204 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1205 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1206 createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1207 createMenu( separator(), basicId, -1 );
1208 createMenu( GEOMOp::OpVector, basicId, -1 );
1209 createMenu( GEOMOp::OpPlane, basicId, -1 );
1210 createMenu( GEOMOp::OpLCS, basicId, -1 );
1211 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1213 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1214 createMenu( GEOMOp::OpBox, primId, -1 );
1215 createMenu( GEOMOp::OpCylinder, primId, -1 );
1216 createMenu( GEOMOp::OpSphere, primId, -1 );
1217 createMenu( GEOMOp::OpTorus, primId, -1 );
1218 createMenu( GEOMOp::OpCone, primId, -1 );
1219 createMenu( GEOMOp::OpRectangle, primId, -1 );
1220 createMenu( GEOMOp::OpDisk, primId, -1 );
1221 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1223 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1224 createMenu( GEOMOp::OpPrism, genId, -1 );
1225 createMenu( GEOMOp::OpRevolution, genId, -1 );
1226 createMenu( GEOMOp::OpFilling, genId, -1 );
1227 createMenu( GEOMOp::OpPipe, genId, -1 );
1228 createMenu( GEOMOp::OpPipePath, genId, -1 );
1229 createMenu( GEOMOp::OpThickness, genId, -1 );
1231 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1232 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1233 //@@ 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 @@//
1235 createMenu( separator(), newEntId, -1 );
1237 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1238 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1239 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1240 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1241 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1242 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1244 createMenu( separator(), newEntId, -1 );
1246 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1247 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1248 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1250 createMenu( separator(), newEntId, -1 );
1252 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1253 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1254 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1255 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1256 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1258 createMenu( separator(), newEntId, -1 );
1260 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1262 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1263 createMenu( GEOMOp::OpEdge, buildId, -1 );
1264 createMenu( GEOMOp::OpWire, buildId, -1 );
1265 createMenu( GEOMOp::OpFace, buildId, -1 );
1266 createMenu( GEOMOp::OpShell, buildId, -1 );
1267 createMenu( GEOMOp::OpSolid, buildId, -1 );
1268 createMenu( GEOMOp::OpCompound, buildId, -1 );
1270 createMenu( separator(), newEntId, -1 );
1272 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1274 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1277 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1279 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1280 createMenu( GEOMOp::OpFuse, boolId, -1 );
1281 createMenu( GEOMOp::OpCommon, boolId, -1 );
1282 createMenu( GEOMOp::OpCut, boolId, -1 );
1283 createMenu( GEOMOp::OpSection, boolId, -1 );
1285 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1286 createMenu( GEOMOp::OpTranslate, transId, -1 );
1287 createMenu( GEOMOp::OpRotate, transId, -1 );
1288 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1289 createMenu( GEOMOp::OpMirror, transId, -1 );
1290 createMenu( GEOMOp::OpScale, transId, -1 );
1291 createMenu( GEOMOp::OpOffset, transId, -1 );
1292 createMenu( GEOMOp::OpProjection, transId, -1 );
1293 createMenu( GEOMOp::OpExtension, transId, -1 );
1294 createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
1295 createMenu( separator(), transId, -1 );
1296 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1297 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1299 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1300 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1301 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1302 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1304 createMenu( separator(), operId, -1 );
1306 createMenu( GEOMOp::OpPartition, operId, -1 );
1307 createMenu( GEOMOp::OpArchimede, operId, -1 );
1308 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1309 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1310 createMenu( GEOMOp::OpTransferData, operId, -1 );
1311 createMenu( GEOMOp::OpExtraction, operId, -1 );
1313 createMenu( separator(), operId, -1 );
1315 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1316 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1317 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1318 createMenu( GEOMOp::OpChamfer, operId, -1 );
1319 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1320 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1322 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1323 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1324 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1325 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1326 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1327 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1328 createMenu( GEOMOp::OpSewing, repairId, -1 );
1329 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1330 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1331 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1332 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1333 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1334 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1335 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1336 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1337 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1338 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1339 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1341 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1342 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1343 createMenu( GEOMOp::OpProperties, measurId, -1 );
1344 createMenu( separator(), measurId, -1 );
1345 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1346 createMenu( GEOMOp::OpInertia, measurId, -1 );
1347 createMenu( GEOMOp::OpNormale, measurId, -1 );
1348 createMenu( separator(), measurId, -1 );
1349 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1350 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1351 createMenu( separator(), measurId, -1 );
1353 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1354 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1355 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1356 createMenu( GEOMOp::OpAngle, dimId, -1 );
1357 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1359 createMenu( GEOMOp::OpAnnotation, measurId, -1 );
1361 createMenu( separator(), measurId, -1 );
1362 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1363 createMenu( separator(), measurId, -1 );
1364 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1365 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1366 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1367 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1368 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1369 createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1370 createMenu( GEOMOp::OpInspectObj, measurId, -1 );
1371 #ifndef DISABLE_PLOT2DVIEWER
1372 createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1375 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1376 #ifndef DISABLE_PYCONSOLE
1377 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1378 createMenu( separator(), toolsId, -1 );
1379 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1383 createMenu( separator(), toolsId, -1 );
1384 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1385 createMenu( separator(), toolsId, -1 );
1387 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1388 createMenu( separator(), viewId, -1 );
1390 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1391 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1392 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1393 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1394 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1395 createMenu( separator(), dispmodeId, -1 );
1396 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1397 createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
1398 createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
1400 createMenu( separator(), viewId, -1 );
1401 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1402 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1403 createMenu( separator(), viewId, -1 );
1404 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1405 createMenu( separator(), viewId, -1 );
1409 because of these items are accessible through object browser and viewers
1410 we have removed they from main menu
1412 createMenu( GEOMOp::OpShow, viewId, -1 );
1413 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1414 createMenu( GEOMOp::OpHide, viewId, -1 );
1417 // ---- create toolbars --------------------------
1419 int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1420 createTool( GEOMOp::OpPoint, basicTbId );
1421 createTool( GEOMOp::OpLine, basicTbId );
1422 createTool( GEOMOp::OpCircle, basicTbId );
1423 createTool( GEOMOp::OpEllipse, basicTbId );
1424 createTool( GEOMOp::OpArc, basicTbId );
1425 createTool( GEOMOp::OpCurve, basicTbId );
1426 createTool( GEOMOp::OpVector, basicTbId );
1427 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1428 createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
1429 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1430 createTool( GEOMOp::OpIsoline, basicTbId );
1431 createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
1432 createTool( GEOMOp::OpPlane, basicTbId );
1433 createTool( GEOMOp::OpLCS, basicTbId );
1434 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1436 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1437 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1438 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1440 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1441 createTool( GEOMOp::OpBox, primTbId );
1442 createTool( GEOMOp::OpCylinder, primTbId );
1443 createTool( GEOMOp::OpSphere, primTbId );
1444 createTool( GEOMOp::OpTorus, primTbId );
1445 createTool( GEOMOp::OpCone, primTbId );
1446 createTool( GEOMOp::OpRectangle, primTbId );
1447 createTool( GEOMOp::OpDisk, primTbId );
1448 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1450 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1451 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1452 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1454 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1455 createTool( GEOMOp::OpFuse, boolTbId );
1456 createTool( GEOMOp::OpCommon, boolTbId );
1457 createTool( GEOMOp::OpCut, boolTbId );
1458 createTool( GEOMOp::OpSection, boolTbId );
1460 int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1461 createTool( GEOMOp::OpPrism, genTbId );
1462 createTool( GEOMOp::OpRevolution, genTbId );
1463 createTool( GEOMOp::OpFilling, genTbId );
1464 createTool( GEOMOp::OpPipe, genTbId );
1465 createTool( GEOMOp::OpPipePath, genTbId );
1466 createTool( GEOMOp::OpThickness, genTbId );
1468 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1469 createTool( GEOMOp::OpTranslate, transTbId );
1470 createTool( GEOMOp::OpRotate, transTbId );
1471 createTool( GEOMOp::OpChangeLoc, transTbId );
1472 createTool( GEOMOp::OpMirror, transTbId );
1473 createTool( GEOMOp::OpScale, transTbId );
1474 createTool( GEOMOp::OpOffset, transTbId );
1475 createTool( GEOMOp::OpProjection, transTbId );
1476 createTool( GEOMOp::OpExtension, transTbId );
1477 createTool( GEOMOp::OpProjOnCyl, transTbId );
1478 createTool( separator(), transTbId );
1479 createTool( GEOMOp::OpMultiTranslate, transTbId );
1480 createTool( GEOMOp::OpMultiRotate, transTbId );
1482 int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1483 createTool( GEOMOp::OpExplode, operTbId );
1484 createTool( GEOMOp::OpPartition, operTbId );
1485 createTool( GEOMOp::OpArchimede, operTbId );
1486 createTool( GEOMOp::OpShapesOnShape, operTbId );
1487 createTool( GEOMOp::OpSharedShapes, operTbId );
1488 createTool( GEOMOp::OpTransferData, operTbId );
1489 createTool( GEOMOp::OpExtraction, operTbId );
1491 int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1492 createTool( GEOMOp::OpFillet1d, featTbId );
1493 createTool( GEOMOp::OpFillet2d, featTbId );
1494 createTool( GEOMOp::OpFillet3d, featTbId );
1495 createTool( GEOMOp::OpChamfer, featTbId );
1496 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1497 createTool( GEOMOp::OpExtrudedCut, featTbId );
1499 int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1500 createTool( GEOMOp::OpEdge, buildTbId );
1501 createTool( GEOMOp::OpWire, buildTbId );
1502 createTool( GEOMOp::OpFace, buildTbId );
1503 createTool( GEOMOp::OpShell, buildTbId );
1504 createTool( GEOMOp::OpSolid, buildTbId );
1505 createTool( GEOMOp::OpCompound, buildTbId );
1507 int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1508 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1509 createTool( GEOMOp::OpProperties, measureTbId );
1510 createTool( GEOMOp::OpCenterMass, measureTbId );
1511 createTool( GEOMOp::OpInertia, measureTbId );
1512 createTool( GEOMOp::OpNormale, measureTbId );
1513 createTool( separator(), measureTbId );
1514 createTool( GEOMOp::OpBoundingBox, measureTbId );
1515 createTool( GEOMOp::OpMinDistance, measureTbId );
1516 createTool( GEOMOp::OpAngle, measureTbId );
1517 createTool( GEOMOp::OpAnnotation, measureTbId );
1518 createTool( GEOMOp::OpTolerance , measureTbId );
1519 createTool( separator(), measureTbId );
1520 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1521 createTool( GEOMOp::OpFreeFaces, measureTbId );
1522 createTool( separator(), measureTbId );
1523 createTool( GEOMOp::OpWhatIs, measureTbId );
1524 createTool( GEOMOp::OpCheckShape, measureTbId );
1525 createTool( GEOMOp::OpCheckCompound, measureTbId );
1526 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1527 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1528 createTool( GEOMOp::OpFastCheckInters, measureTbId );
1530 int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1531 createTool( GEOMOp::OpPictureImport, picturesTbId );
1533 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1536 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1537 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1538 //@@ 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 @@//
1540 // ---- create popup menus --------------------------
1542 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1543 QString clientOCC = "(client='OCCViewer')";
1544 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1545 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1547 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1548 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1549 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1550 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1552 QString autoColorPrefix =
1553 "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1555 QtxPopupMgr* mgr = popupMgr();
1557 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1558 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1559 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1560 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1561 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1562 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1563 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1564 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1566 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1567 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1568 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1569 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1570 mgr->insert( separator(), -1, -1 ); // -----------
1572 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1573 QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1574 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1575 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1576 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1577 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1578 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1579 mgr->insert( separator(), -1, -1 ); // -----------
1580 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1581 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1582 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1583 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1584 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1585 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1586 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1587 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1588 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1589 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1590 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1591 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1592 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1593 mgr->insert( separator(), dispmodeId, -1 );
1594 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1595 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1596 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1597 mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1598 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1599 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1600 mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1601 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1602 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1603 mgr->insert( separator(), -1, -1 ); // -----------
1605 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1606 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1607 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1608 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1609 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1610 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1611 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1612 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1613 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1614 mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1616 // material properties
1617 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1618 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and matMenu=false", QtxPopupMgr::VisibleRule );
1619 mgr->insert( action( GEOMOp::OpMaterialMenu ), -1, -1 );
1620 mgr->setRule( action( GEOMOp::OpMaterialMenu ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and matMenu=true", QtxPopupMgr::VisibleRule );
1623 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1624 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1626 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1627 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1628 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1630 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1631 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1633 mgr->insert( separator(), -1, -1 ); // -----------
1634 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1635 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1636 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1637 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1638 mgr->insert( separator(), -1, -1 ); // -----------
1640 mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
1641 mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1642 mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
1643 mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1644 mgr->insert( separator(), -1, -1 ); // -----------
1646 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1647 onlyComponent = "((type='Component') and selcount=1)",
1648 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1649 types = "'Shape' 'Group' 'FieldStep'";
1651 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1652 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1654 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1655 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1657 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1658 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1660 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1662 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1663 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1664 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1665 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1666 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1667 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1668 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1669 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1670 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1671 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1672 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1673 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1674 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1675 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1676 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1677 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1678 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1679 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1680 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1681 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1682 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1683 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1684 mgr->insert( separator(), selectonlyId, -1);
1685 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1686 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1687 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1688 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1689 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1690 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1691 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1693 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1695 mgr->insert( separator(), -1, -1 ); // -----------
1696 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1697 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1698 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1699 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1700 mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1701 mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1702 mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1703 mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1705 mgr->insert( separator(), -1, -1 ); // -----------
1706 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1707 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1709 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1710 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1712 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1713 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1715 mgr->insert( separator(), -1, -1 ); // -----------
1716 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1717 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1719 mgr->insert( separator(), -1, -1 ); // -----------
1720 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1721 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1723 #ifndef DISABLE_GRAPHICSVIEW
1724 mgr->insert( separator(), -1, -1 ); // -----------
1725 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1726 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1729 mgr->insert( separator(), -1, -1 ); // -----------
1730 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1731 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1733 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1735 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1737 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1738 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1739 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1742 // create plugin actions and menus
1746 //=======================================================================
1747 // function : GeometryGUI::addPluginActions()
1749 //=======================================================================
1750 void GeometryGUI::addPluginActions()
1753 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1754 if (!resMgr) return;
1756 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1757 if (!appStudy) return;
1759 // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1761 GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1763 int id = GEOMOp::OpLastOperationID; // TODO?
1766 GEOMUtils::PluginInfo::const_iterator it;
1767 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1768 // bind action lib and label to its ID for activateOperation() method proper work
1769 GEOMUtils::PluginData pdata = (*it);
1770 myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1771 std::list<GEOMUtils::ActionData> actions = (*it).actions;
1772 std::list<GEOMUtils::ActionData>::const_iterator ait;
1773 for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1774 GEOMUtils::ActionData adata = (*ait);
1777 if ( !adata.icon.empty() )
1778 icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1780 QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1781 QString actionName = smenus.last();
1782 actionName = actionName.toUpper().prepend( "MEN_" );
1783 smenus.removeLast();
1785 // path to action in toolbar
1786 QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1787 QString actionTool = stools.last();
1788 actionTool = actionTool.toUpper().prepend( "TOP_" );
1789 stools.removeLast();
1791 QString actionStat = adata.statusText.c_str();
1792 actionStat = actionStat.toUpper().prepend( "STB_" );
1794 createAction( id, // ~ adata.label
1795 tr( actionTool.toLatin1().constData() ),
1797 tr( actionName.toLatin1().constData() ),
1798 tr( actionStat.toLatin1().constData() ),
1799 QKeySequence( tr( adata.accel.c_str() ) ),
1800 application()->desktop(),
1802 this, SLOT( OnGUIEvent() ),
1803 QString() /*shortcutAction*/ );
1806 foreach ( QString subMenu, smenus ) {
1807 QStringList subMenuList = subMenu.split( ":" );
1808 QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1809 int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1810 menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1812 createMenu( id, menuId, -1 );
1814 if ( !stools.isEmpty() ) {
1815 QString subTool = stools[0];
1816 subTool = subTool.toUpper().prepend( "TOOL_" );
1817 int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1818 createTool(id, toolId);
1821 // add action id to map
1822 PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1823 myPluginActions[id] = anAction;
1830 //=======================================================================
1831 // function : GeometryGUI::activateModule()
1832 // purpose : Called when GEOM module is activated
1833 //=======================================================================
1834 bool GeometryGUI::activateModule( SUIT_Study* study )
1836 if ( CORBA::is_nil( myComponentGeom ) )
1839 bool res = SalomeApp_Module::activateModule( study );
1843 setMenuShown( true );
1844 setToolShown( true );
1846 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1847 PyGILState_STATE gstate = PyGILState_Ensure();
1848 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1849 if ( !pluginsmanager ) {
1854 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1855 tr("MEN_NEW_ENTITY").toUtf8().data(),
1856 tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1861 PyGILState_Release(gstate);
1862 // end of GEOM plugins loading
1864 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1865 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
1867 // Reset actions accelerator keys
1868 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1870 GUIMap::Iterator it;
1871 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1872 it.value()->activate( application()->desktop() );
1874 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1876 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ), Qt::UniqueConnection );
1877 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ), Qt::UniqueConnection );
1878 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ), Qt::UniqueConnection );
1880 if ( !myCreationInfoWdg )
1881 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1882 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1883 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1885 if ( !myTextTreeWdg ) {
1886 myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1887 new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1890 getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1891 getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1894 SALOME_ListIO selected;
1895 sm->selectedObjects( selected );
1896 sm->clearSelected();
1898 SUIT_ViewManager* vm;
1899 ViewManagerList OCCViewManagers, VTKViewManagers;
1901 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1902 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1903 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1904 onViewManagerAdded(vm);
1906 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1907 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1908 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1909 onViewManagerAdded(vm);
1911 sm->setSelectedObjects( selected, true ); //NPAL 19674
1913 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1915 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ), Qt::UniqueConnection );
1917 // 0020836 (Basic vectors and origin)
1918 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1919 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1920 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1922 _PTR(Study) studyDS = appStudy->studyDS();
1924 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1925 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1926 createOriginAndBaseVectors();
1931 Py_XDECREF(pluginsmanager);
1935 //=======================================================================
1936 // function : GeometryGUI::deactivateModule()
1937 // purpose : Called when GEOM module is deactivated
1938 //=======================================================================
1939 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1941 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1943 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1945 setMenuShown( false );
1946 setToolShown( false );
1948 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1949 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1951 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1953 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1954 //disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1955 if ( myCreationInfoWdg ) {
1956 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1957 myCreationInfoWdg = 0;
1959 if ( myTextTreeWdg ) {
1960 getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
1961 disconnect( application(), 0, myTextTreeWdg, 0 );
1965 EmitSignalCloseAllDialogs();
1967 GUIMap::Iterator it;
1968 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1969 it.value()->deactivate();
1971 // Unset actions accelerator keys
1972 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1974 qDeleteAll(myOCCSelectors);
1975 myOCCSelectors.clear();
1976 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1978 qDeleteAll(myVTKSelectors);
1979 myVTKSelectors.clear();
1980 selMrg->setEnabled( true, SVTK_Viewer::Type() );
1982 return SalomeApp_Module::deactivateModule( study );
1985 //=======================================================================
1986 // function : onWindowActivated()
1987 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1988 //=======================================================================
1989 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1994 const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
1995 //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
1997 // disable non-OCC viewframe menu commands
1998 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1999 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
2000 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
2001 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
2002 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
2003 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
2004 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2006 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2007 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2008 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2009 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2011 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2014 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2016 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2017 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2018 #ifndef DISABLE_PYCONSOLE
2019 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2021 if ( myCreationInfoWdg )
2022 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2023 if ( myTextTreeWdg )
2024 mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2027 void GeometryGUI::viewManagers( QStringList& lst ) const
2029 lst.append( OCCViewer_Viewer::Type() );
2032 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2034 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2036 qDebug( "connect" );
2037 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
2038 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2039 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2040 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2041 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2042 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2043 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2044 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2046 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2047 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2049 // disable OCC selectors
2050 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2051 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2052 while ( itOCCSel.hasNext() )
2053 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2054 sr->setEnabled(true);
2056 else if ( vm->getType() == SVTK_Viewer::Type() )
2058 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2059 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2061 // disable VTK selectors
2062 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2063 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2064 while ( itVTKSel.hasNext() )
2065 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2066 sr->setEnabled(true);
2070 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2072 SUIT_ViewModel* viewer = vm->getViewModel();
2073 if ( vm->getType() == OCCViewer_Viewer::Type() )
2075 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2076 while ( itOCCSel.hasNext() )
2077 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2078 if ( sr->viewer() == viewer )
2080 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2084 if ( vm->getType() == SVTK_Viewer::Type() )
2086 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2087 while ( itVTKSel.hasNext() )
2088 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2089 if ( sr->viewer() == viewer )
2091 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2095 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2097 GetAnnotationMgr()->RemoveView( aSOCCView );
2101 //================================================================================
2103 * \brief Slot called when selection changed. Shows creation info of a selected object
2105 //================================================================================
2107 void GeometryGUI::updateCreationInfo()
2109 if ( myCreationInfoWdg )
2110 myCreationInfoWdg->clear();
2112 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2113 // if ( !myCreationInfoWdg->isVisible() )
2116 // look for a sole selected GEOM_Object
2117 GEOM::GEOM_BaseObject_var geomObj;
2119 SALOME_ListIO selected;
2120 getApp()->selectionMgr()->selectedObjects( selected );
2122 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2123 SALOME_ListIteratorOfListIO selIt( selected );
2124 for ( ; selIt.More(); selIt.Next() )
2126 Handle(SALOME_InteractiveObject) io = selIt.Value();
2127 if ( !io->hasEntry() ) continue;
2128 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2129 if ( !sobj ) continue;
2130 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2131 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2132 if ( !gobj->_is_nil() )
2134 if ( !geomObj->_is_nil() )
2135 return; // several GEOM objects selected
2139 if ( geomObj->_is_nil() ) return;
2141 // pass creation info of geomObj to myCreationInfoWdg
2143 if ( myCreationInfoWdg ) {
2145 GEOM::CreationInformationSeq_var info;
2148 info = geomObj->GetCreationInformation();
2152 myCreationInfoWdg->setInfo( info );
2156 void GeometryGUI::onAutoBringToFront()
2158 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2159 if( !isAutoBringToFront )
2162 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2163 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2166 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2167 if (!appStudy) return;
2169 GEOM_Displayer displayer;
2171 SALOME_View* window = displayer.GetActiveView();
2172 if ( !window ) return;
2174 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2176 SALOME_ListIO selected;
2177 getApp()->selectionMgr()->selectedObjects( selected );
2178 if (!myTopLevelIOList.IsEmpty())
2180 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2182 Handle( SALOME_InteractiveObject ) io = It.Value();
2183 bool isSelected = false;
2184 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2186 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2187 if( io->isSame( sel_io ) )
2190 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2192 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2193 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2198 myTopLevelIOList.Assign(selected);
2199 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2201 Handle( SALOME_InteractiveObject ) io = It.Value();
2202 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2203 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2206 displayer.UpdateViewer();
2207 GeometryGUI::Modified();
2210 void GeometryGUI::updateFieldColorScale()
2212 GEOM_Displayer aDisplayer;
2213 aDisplayer.UpdateColorScale();
2216 QString GeometryGUI::engineIOR() const
2218 if ( !CORBA::is_nil( GetGeomGen() ) )
2219 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2223 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2225 theWidth = theHeight = 0;
2226 Handle(TColStd_HArray1OfByte) aTexture;
2228 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2229 if ( !aInsOp->_is_nil() ) {
2230 CORBA::Long aWidth, aHeight;
2231 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2232 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2234 theHeight = aHeight;
2236 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2238 for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2239 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2245 LightApp_Selection* GeometryGUI::createSelection() const
2247 return new GEOMGUI_Selection();
2250 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2252 SalomeApp_Module::contextMenuPopup( client, menu, title );
2254 getApp()->selectionMgr()->selectedObjects( lst );
2256 // Update submenu for predefined materials
2257 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2258 QMenu* matMenu = action( GEOMOp::OpMaterialMenu )->menu();
2260 QSignalMapper* signalMapper = new QSignalMapper( menu );
2263 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2264 if ( anApp && anApp->activeViewManager() ) {
2265 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2267 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2270 QString curModel = "";
2271 if ( v.canConvert<QString>() ) curModel = v.toString();
2273 // get list of all predefined materials
2274 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2276 foreach ( QString material, materials )
2278 QAction* a = matMenu->addAction( material );
2279 connect( a, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2280 signalMapper->setMapping( a, material );
2281 a->setCheckable( true );
2283 Material_Model aModel;
2284 aModel.fromResources( material );
2285 if ( !found && aModel.toProperties() == curModel ) {
2286 a->setChecked( true );
2290 matMenu->addSeparator();
2291 matMenu->addAction( action( GEOMOp::OpPredefMaterCustom ) );
2292 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2293 this, SLOT( OnSetMaterial( const QString & ) ) );
2296 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2297 Handle(SALOME_InteractiveObject) io = lst.First();
2298 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2299 _PTR(Study) study = appStudy->studyDS();
2300 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2302 QString aName = QString( obj->GetName().c_str() );
2303 aName.remove( QRegExp("\\s+$") );
2309 void GeometryGUI::OnSetMaterial(const QString& theName)
2311 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2315 void GeometryGUI::createPreferences()
2317 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2319 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2321 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2322 setPreferenceProperty( genGroup, "columns", 2 );
2324 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2325 LightApp_Preferences::Selector,
2326 "Geometry", "display_mode" );
2328 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2329 LightApp_Preferences::Color, "Geometry", "shading_color" );
2331 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2332 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2334 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2335 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2337 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2338 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2340 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2341 LightApp_Preferences::Color, "Geometry", "line_color" );
2343 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2344 LightApp_Preferences::Color, "Geometry", "point_color" );
2346 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2347 LightApp_Preferences::Color, "Geometry", "isos_color" );
2349 addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2350 LightApp_Preferences::Color, "Geometry", "label_color" );
2352 addPreference( "", genGroup, LightApp_Preferences::Space );
2354 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2355 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2357 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2358 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2360 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2361 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2363 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2364 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2366 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2367 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2369 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2370 LightApp_Preferences::Selector,
2371 "Geometry", "material" );
2373 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2374 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2380 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2381 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2383 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2384 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2386 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2387 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2389 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2390 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2392 for (int i = 0; i < nb; i++) {
2393 setPreferenceProperty( wd[i], "min", 1 );
2394 setPreferenceProperty( wd[i], "max", 5 );
2397 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2398 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2400 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2401 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2403 // --------------------------------------------------------------------------
2404 // Dimensions (Measurements) preferences
2405 // --------------------------------------------------------------------------
2407 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2408 setPreferenceProperty( aDimGroupId, "columns", 2 );
2410 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2411 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2413 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2414 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2416 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2417 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2419 int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2421 int f = QtxFontEdit::Family | QtxFontEdit::Size;
2422 setPreferenceProperty( aDimFontId, "features", f );
2423 setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2425 Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2426 QString aFontFile = "";
2427 resMgr->value("resources", "GEOM", aFontFile);
2428 aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2429 // add enginier font into combobox
2430 /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2431 Handle(Font_SystemFont) sf = new Font_SystemFont(
2432 new TCollection_HAsciiString("Y14.5M-2009"),
2434 new TCollection_HAsciiString(aFontFile.toLatin1().data()) );
2435 // register font in OCC font manager
2436 fmgr->RegisterFont( sf, Standard_False );
2438 // get list of supported fonts by OCC
2439 QStringList anOCCFonts;
2440 TColStd_SequenceOfHAsciiString theFontsNames;
2441 fmgr->GetAvailableFontsNames( theFontsNames );
2442 for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2443 Handle(TCollection_HAsciiString) str = theFontsNames(i);
2444 anOCCFonts << str->ToCString();
2446 anOCCFonts.removeDuplicates();
2447 // set the supported fonts into combobox to use its only
2448 setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2450 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2451 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2453 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2454 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2455 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2457 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2458 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2460 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2461 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2463 QStringList aListOfLengthUnits;
2464 aListOfLengthUnits << "m";
2465 aListOfLengthUnits << "cm";
2466 aListOfLengthUnits << "mm";
2467 aListOfLengthUnits << "in.";
2468 aListOfLengthUnits << "ft.";
2470 QStringList aListOfAngUnits;
2471 aListOfAngUnits << "rad";
2472 aListOfAngUnits << "deg";
2474 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2475 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2477 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2478 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2480 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2481 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2483 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2484 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2485 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2487 addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2488 LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2490 // --------------------------------------------------------------------------
2491 // Shape annotation preferences
2492 // --------------------------------------------------------------------------
2494 const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2495 setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2497 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2498 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2499 const int aShapeAnnFont =
2500 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2502 int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2503 setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2504 setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2505 setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2507 const int aShapeAnnLineWidth =
2508 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2510 setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2511 setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2513 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2515 const int aShapeAnnLineStyle =
2516 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2518 QStringList aLineStyleList;
2519 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2520 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2521 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2522 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2524 QList<QVariant> aLineStyleIds;
2525 aLineStyleIds.append(0);
2526 aLineStyleIds.append(1);
2527 aLineStyleIds.append(2);
2528 aLineStyleIds.append(3);
2530 setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2531 setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2533 // --------------------------------------------------------------------------
2534 // Isoline drawing preferences
2535 // --------------------------------------------------------------------------
2537 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2538 setPreferenceProperty( isoGroup, "columns", 2 );
2539 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2540 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2541 setPreferenceProperty( isoU, "min", 0 );
2542 setPreferenceProperty( isoU, "max", 100000 );
2543 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2544 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2545 setPreferenceProperty( isoV, "min", 0 );
2546 setPreferenceProperty( isoV, "max", 100000 );
2548 // Quantities with individual precision settings
2549 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2550 setPreferenceProperty( precGroup, "columns", 2 );
2552 const int nbQuantities = 8;
2553 int prec[nbQuantities], ii = 0;
2554 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2555 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2556 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2557 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2558 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2559 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2560 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2561 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2562 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2563 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2564 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2565 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2566 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2567 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2568 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2569 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2571 // Set property for precision value for spinboxes
2572 for ( ii = 0; ii < nbQuantities; ii++ ){
2573 setPreferenceProperty( prec[ii], "min", -14 );
2574 setPreferenceProperty( prec[ii], "max", 14 );
2575 setPreferenceProperty( prec[ii], "precision", 2 );
2578 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2579 setPreferenceProperty( VertexGroup, "columns", 2 );
2581 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2582 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2584 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2585 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2587 // Set property for default display mode
2588 QStringList aModesList;
2589 aModesList.append( tr("MEN_WIREFRAME") );
2590 aModesList.append( tr("MEN_SHADING") );
2591 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2592 aModesList.append( tr("MEN_TEXTURE") );
2594 QList<QVariant> anIndexesList;
2595 anIndexesList.append(0);
2596 anIndexesList.append(1);
2597 anIndexesList.append(2);
2598 anIndexesList.append(3);
2600 setPreferenceProperty( dispmode, "strings", aModesList );
2601 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2603 // Set property for top level display mode
2604 QStringList aTopModesList;
2605 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2606 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2607 aTopModesList.append( tr("MEN_WIREFRAME") );
2608 aTopModesList.append( tr("MEN_SHADING") );
2609 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2611 QList<QVariant> aTopIndexesList;
2612 aTopIndexesList.append(0);
2613 aTopIndexesList.append(1);
2614 aTopIndexesList.append(2);
2615 aTopIndexesList.append(3);
2616 aTopIndexesList.append(4);
2618 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2619 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2621 // Set property for step value for spinboxes
2622 setPreferenceProperty( step, "min", 1 );
2623 setPreferenceProperty( step, "max", 10000 );
2624 setPreferenceProperty( step, "precision", 3 );
2626 // Set property for trandparency value for spinboxes
2627 setPreferenceProperty( transparency, "min", 0 );
2628 setPreferenceProperty( transparency, "max", 100 );
2630 // Set property for deflection value for spinboxes
2631 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2632 setPreferenceProperty( defl, "max", 1.0 );
2633 setPreferenceProperty( defl, "step", 1.0e-04 );
2634 setPreferenceProperty( defl, "precision", 6 );
2636 // Set property for default material
2637 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2639 // Set property vertex marker type
2640 QList<QVariant> aMarkerTypeIndicesList;
2641 QList<QVariant> aMarkerTypeIconsList;
2643 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2644 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2645 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2646 aMarkerTypeIndicesList << (i-1);
2647 aMarkerTypeIconsList << pixmap;
2650 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2651 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2653 // Set property for vertex marker scale
2654 QList<QVariant> aMarkerScaleIndicesList;
2655 QStringList aMarkerScaleValuesList;
2657 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2658 aMarkerScaleIndicesList << iii;
2659 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2662 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2663 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2665 // Scalar bar for field step presentation
2666 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2667 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2669 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2670 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2671 setPreferenceProperty( sbXPosition, "min", 0 );
2672 setPreferenceProperty( sbXPosition, "max", 1 );
2673 setPreferenceProperty( sbXPosition, "step", 0.05 );
2675 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2676 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2677 setPreferenceProperty( sbYPosition, "min", 0 );
2678 setPreferenceProperty( sbYPosition, "max", 1 );
2679 setPreferenceProperty( sbYPosition, "step", 0.05 );
2681 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2682 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2683 setPreferenceProperty( sbWidth, "min", 0 );
2684 setPreferenceProperty( sbWidth, "max", 1 );
2685 setPreferenceProperty( sbWidth, "step", 0.05 );
2687 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2688 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2689 setPreferenceProperty( sbHeight, "min", 0 );
2690 setPreferenceProperty( sbHeight, "max", 1 );
2691 setPreferenceProperty( sbHeight, "step", 0.05 );
2693 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2694 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2695 setPreferenceProperty( sbTextHeight, "min", 6 );
2696 setPreferenceProperty( sbTextHeight, "max", 24 );
2697 setPreferenceProperty( sbTextHeight, "step", 1 );
2699 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2700 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2701 setPreferenceProperty( sbNbIntervals, "min", 2 );
2702 setPreferenceProperty( sbNbIntervals, "max", 64 );
2703 setPreferenceProperty( sbNbIntervals, "step", 1 );
2705 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2706 setPreferenceProperty( originGroup, "columns", 2 );
2708 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2709 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2710 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2711 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2713 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2714 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2716 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2717 setPreferenceProperty( operationsGroup, "columns", 2 );
2719 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2720 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2722 addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2723 LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2725 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2727 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2729 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2730 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2732 QStringList aHierarchyTypeList;
2733 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2734 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2735 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2737 QList<QVariant> aHierarchyTypeIndexesList;
2738 aHierarchyTypeIndexesList.append(0);
2739 aHierarchyTypeIndexesList.append(1);
2740 aHierarchyTypeIndexesList.append(2);
2742 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2743 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2745 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2746 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2748 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2750 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2751 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2753 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2754 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2755 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2756 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2757 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2758 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2759 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2760 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2762 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2763 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2764 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2765 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2766 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2767 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2774 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2776 if (section == "Geometry") {
2777 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2778 if (param == QString("SettingsGeomStep")) {
2779 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2780 EmitSignalDefaultStepValueChanged(spin_step);
2782 else if (param == QString("toplevel_color")) {
2783 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2784 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2786 else if (param == QString("toplevel_dm")) {
2787 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2789 else if (param == QString("scalar_bar_x_position") ||
2790 param == QString("scalar_bar_y_position") ||
2791 param == QString("scalar_bar_width") ||
2792 param == QString("scalar_bar_height") ||
2793 param == QString("scalar_bar_text_height") ||
2794 param == QString("scalar_bar_nb_intervals")) {
2795 updateFieldColorScale();
2797 else if ( param == QString("dimensions_color") ||
2798 param == QString("dimensions_line_width") ||
2799 param == QString("dimensions_font") ||
2800 param == QString("dimensions_arrow_length") ||
2801 param == QString("dimensions_show_units") ||
2802 param == QString("dimensions_length_units") ||
2803 param == QString("dimensions_angle_units") ||
2804 param == QString("dimensions_use_text3d") ||
2805 param == QString("shape_annotation_font_color") ||
2806 param == QString("shape_annotation_line_color") ||
2807 param == QString("shape_annotation_font") ||
2808 param == QString("shape_annotation_line_width") ||
2809 param == QString("shape_annotation_autohide") ||
2810 param == QString("shape_annotation_line_style") ||
2811 param == QString("shape_annotation_line_style") ||
2812 param == QString("label_color") )
2814 SalomeApp_Application* anApp = getApp();
2820 GEOM_Displayer aDisplayer;
2822 ViewManagerList aVMs;
2823 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2824 ViewManagerList::Iterator anIt = aVMs.begin();
2825 for ( ; anIt != aVMs.end(); ++anIt )
2827 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2833 SALOME_ListIO aVisible;
2834 aViewer->GetVisible( aVisible );
2836 GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2837 if ( anAnnotationMgr ) {
2838 SALOME_ListIteratorOfListIO anIter( aVisible );
2839 while ( anIter.More() ) {
2840 if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2841 aVisible.Remove( anIter );
2849 aDisplayer.Redisplay( aVisible, false, aViewer );
2851 if ( param == QString( "label_color" ) ) {
2852 ViewManagerList aVMsVTK;
2853 anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2854 ViewManagerList::Iterator anIt = aVMsVTK.begin();
2855 for ( ; anIt != aVMsVTK.end(); ++anIt )
2857 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2862 SALOME_ListIO aVisible;
2863 aViewer->GetVisible( aVisible );
2864 aDisplayer.Redisplay( aVisible, false, aViewer );
2867 aDisplayer.UpdateViewer();
2869 else if ( param.startsWith( "dependency_tree") )
2870 emit SignalDependencyTreeParamChanged( section, param );
2874 LightApp_Displayer* GeometryGUI::displayer()
2877 myDisplayer = new GEOM_Displayer();
2881 void GeometryGUI::setLocalSelectionMode(const int mode)
2883 myLocalSelectionMode = mode;
2886 int GeometryGUI::getLocalSelectionMode() const
2888 return myLocalSelectionMode;
2891 const char gSeparator = '_'; // character used to separate parameter names
2892 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2895 * \brief Store visual parameters
2897 * This method is called just before the study document is saved.
2898 * Store visual parameters in AttributeParameter attribute(s)
2900 void GeometryGUI::storeVisualParameters (int savePoint)
2902 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2903 if ( !appStudy || !appStudy->studyDS() )
2906 _PTR(Study) studyDS = appStudy->studyDS();
2908 // componentName is used for encoding of entries when storing them in IParameters
2909 std::string componentName = myComponentGeom->ComponentDataType();
2910 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2911 //if (!aSComponent) return;
2914 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2915 componentName.c_str(),
2917 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2919 QSet<QString> anEntriesToStoreShared;
2920 QList<SUIT_ViewManager*> lst;
2921 QList<SUIT_ViewManager*>::Iterator it;
2923 GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
2925 // main cycle to store parameters of displayed objects
2927 getApp()->viewManagers(lst);
2928 for (it = lst.begin(); it != lst.end(); it++) {
2929 SUIT_ViewManager* vman = *it;
2930 QString vType = vman->getType();
2931 SUIT_ViewModel* vmodel = vman->getViewModel();
2932 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
2934 int aMgrId = vman->getGlobalId();
2935 // saving VTK actors properties
2936 QVector<SUIT_ViewWindow*> views = vman->getViews();
2937 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2938 const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
2939 ObjMap::ConstIterator o_it = anObjects.begin();
2940 for (; o_it != anObjects.end(); o_it++) {
2941 const PropMap& aProps = o_it.value();
2943 //Check that object exists in the study
2944 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toUtf8().data() ) );
2945 if ( !obj || !(aProps.count() > 0))
2947 // entry is "encoded" = it does NOT contain component address, since it is a
2948 // subject to change on next component loading
2950 std::string entry = ip->encodeEntry(o_it.key().toUtf8().data(), componentName);
2952 _PTR(GenericAttribute) anAttr;
2953 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2956 // remember entry of object to store shared GEOM properties
2957 // (e.g. dimension properties).
2958 if ( vType == OCCViewer_Viewer::Type() )
2960 anEntriesToStoreShared.insert( o_it.key() );
2963 QString param, occParam = vType;
2964 occParam += GEOM::sectionSeparator();
2965 occParam += QString::number(aMgrId);
2966 occParam += GEOM::sectionSeparator();
2968 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2969 param = occParam + GEOM::propertyName( GEOM::Visibility );
2970 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2973 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2974 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2975 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2978 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2979 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2981 val << QString::number(c.redF());
2982 val << QString::number(c.greenF());
2983 val << QString::number(c.blueF());
2984 param = occParam + GEOM::propertyName( GEOM::Color );
2985 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2988 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
2989 param = occParam + GEOM::propertyName( GEOM::Texture );
2990 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
2993 if (vType == SVTK_Viewer::Type()) {
2994 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2995 param = occParam + GEOM::propertyName( GEOM::Opacity );
2996 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2998 } else if (vType == SOCC_Viewer::Type()) {
2999 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3000 param = occParam + GEOM::propertyName( GEOM::Transparency );
3001 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3004 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3005 param = occParam + GEOM::propertyName( GEOM::TopLevel );
3006 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3010 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3011 param = occParam + GEOM::propertyName( GEOM::NbIsos );
3012 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3015 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3016 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3017 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3020 if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3021 param = occParam + GEOM::propertyName( GEOM::Vertices );
3022 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3025 if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3026 param = occParam + GEOM::propertyName( GEOM::ShowName );
3027 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3030 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3031 param = occParam + GEOM::propertyName( GEOM::Deflection );
3032 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3035 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3036 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3037 param = occParam + GEOM::propertyName( GEOM::PointMarker );
3038 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3041 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3042 param = occParam + GEOM::propertyName( GEOM::Material );
3043 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3046 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3047 param = occParam + GEOM::propertyName( GEOM::LineWidth );
3048 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3051 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3052 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3053 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3056 if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3057 std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3058 o_it.key().toUtf8().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3059 if (!anAnnotationInfo.empty()) {
3060 param = occParam + "ShapeAnnotationVisibleItems";
3061 ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3064 } // object iterator
3066 } // for (viewManagers)
3068 // store shape annotation and dimension attributes of objects:
3069 // since the displayed object always persists in property map, we remember the object entries
3070 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3071 const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3072 const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3073 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3074 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3076 std::string aStudyEntry = (*aEntryIt).toUtf8().data();
3077 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3079 // store dimension parameters
3080 GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3081 if ( aDimensions.GetNumber() != 0 ) {
3082 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toUtf8().data() );
3085 _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3086 const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3087 if ( !aShapeAnnAttr.IsNull() ) {
3088 ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toUtf8().data() );
3094 * \brief Restore visual parameters
3096 * This method is called after the study document is opened.
3097 * Restore visual parameters from AttributeParameter attribute(s)
3099 void GeometryGUI::restoreVisualParameters (int savePoint)
3101 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3102 if (!appStudy || !appStudy->studyDS())
3104 _PTR(Study) studyDS = appStudy->studyDS();
3106 // componentName is used for encoding of entries when storing them in IParameters
3107 std::string componentName = myComponentGeom->ComponentDataType();
3108 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3109 //if (!aSComponent) return;
3112 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3113 componentName.c_str(),
3115 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3117 std::vector<std::string> entries = ip->getEntries();
3119 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3121 // entry is a normal entry - it should be "decoded" (setting base address of component)
3122 QString entry (ip->decodeEntry(*entIt).c_str());
3124 // Check that the entry corresponds to a real object in the Study
3125 // as the object may be deleted or modified after the visual state is saved.
3126 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
3127 if (!so) continue; //Skip the not existent entry
3129 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3130 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3132 std::vector<std::string>::iterator namesIt = paramNames.begin();
3133 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3135 // actors are stored in a map after displaying of them for
3136 // quicker access in the future: map < viewID to actor >
3137 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
3138 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3140 QString viewerTypStr;
3141 QString viewIndexStr;
3143 QVector<PropMap> aListOfMap;
3145 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3147 // visual parameters are stored in strings as follows:
3148 // 1) ViewerType_ViewIndex_ParamName
3149 // 2) ViewerType_ParamName (shared for GEOM module)
3150 // '_' is used as separator and should not be used in viewer type or parameter names.
3151 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3153 bool isShared = lst.size() == 2;
3154 bool isViewer = lst.size() == 3;
3155 if ( !isShared && !isViewer )
3160 // shared visual parameters
3163 QString aParamNameStr( lst[1] );
3164 QString aValuesStr( (*valuesIt).c_str() );
3166 // shared dimension properties are stored as attribute
3167 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3169 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3170 aDimensionProp.SaveToAttribute( entry.toUtf8().data() );
3172 else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3174 Handle(GEOMGUI_AnnotationAttrs) anAttr =
3175 GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3177 anAttr->ImportFromPropertyString( aValuesStr );
3183 // per view visual parameters
3184 viewerTypStr = lst[0];
3185 viewIndexStr = lst[1];
3186 QString paramNameStr = lst[2];
3189 viewIndex = viewIndexStr.toUInt(&ok);
3190 if (!ok) // bad conversion of view index to integer
3193 if ((viewIndex + 1) > aListOfMap.count()) {
3194 aListOfMap.resize(viewIndex + 1);
3197 QString val((*valuesIt).c_str());
3198 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3199 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3200 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3201 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3202 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3203 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3204 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3205 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3206 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3207 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3208 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3209 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3210 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3211 QStringList rgb = val.split(GEOM::subSectionSeparator());
3212 if (rgb.count() == 3) {
3213 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3214 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3216 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3217 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3218 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3219 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3220 } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3221 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3222 } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3223 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3224 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3225 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3226 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3227 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3228 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3229 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3230 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3231 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3232 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3233 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3234 } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3235 aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3238 } // for names/parameters iterator
3240 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3242 for (int index = 0; index < aListOfMap.count(); index++) {
3243 appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3245 //Get Visibility property of the current PropMap
3246 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3247 SUIT_ViewManager* vman = lst.at(index);
3248 SUIT_ViewModel* vmodel = vman->getViewModel();
3249 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3250 displayer()->Display(entry, true, aView);
3252 if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3253 PropMap& aProps = aListOfMap[index];
3254 if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3255 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3256 GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3261 } // for entries iterator
3263 // update all VTK and OCC views
3264 QList<SUIT_ViewManager*> lst;
3265 getApp()->viewManagers(lst);
3266 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3267 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3270 if (vmodel->getType() == SVTK_Viewer::Type()) {
3271 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3272 vtkView->getRenderer()->ResetCameraClippingRange();
3275 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3276 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3277 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3283 if ( myTextTreeWdg ) {
3284 myTextTreeWdg->updateTree();
3288 // Compute current name mode of the viewer
3289 void UpdateNameMode( SalomeApp_Application* app )
3291 bool isMode = false;
3292 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3293 SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3294 GEOM_Displayer displayer;
3295 int aMgrId = viewWindow->getViewManager()->getGlobalId();
3297 SALOME_View* window = displayer.GetActiveView();
3298 if ( !window ) return;
3300 SALOME_ListIO anIOlst;
3301 window->GetVisible( anIOlst );
3303 for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3304 Handle( SALOME_InteractiveObject ) io = It.Value();
3305 QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3306 bool isIONameMode = v.isValid() ? v.toBool() : false;
3310 viewWindow->setProperty( "NameMode", isMode );
3313 void GeometryGUI::onViewAboutToShow()
3315 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3316 QAction* a = action( GEOMOp::OpSwitchVectors );
3317 QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3318 QAction* aNameAction = action( GEOMOp::OpSwitchName );
3320 a->setEnabled(true);
3321 bool vmode = window->property("VectorsMode").toBool();
3322 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3323 aVerticesAction->setEnabled(true);
3324 vmode = window->property("VerticesMode").toBool();
3325 aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3326 UpdateNameMode( getApp() );
3327 aNameAction->setEnabled(true);
3328 vmode = window->property("NameMode").toBool();
3329 aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3331 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3332 a->setEnabled(false);
3333 aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3334 aVerticesAction->setEnabled(false);
3335 aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3336 aNameAction->setEnabled(false);
3341 \brief Return action by id
3342 \param id identifier of the action
3345 QAction* GeometryGUI::getAction(const int id) {
3350 \brief GEOM module message handler
3352 This method can be re-implemented in the subclasses.
3353 This is a GEOM module message handler.
3355 \param msg the message received.
3357 void GeometryGUI::message(const QString& msg)
3360 QStringList data = msg.split("/");
3361 const int nbStrings = data.count();
3363 if (nbStrings > 0) {
3364 if (data[0] == "modified") {
3366 QString anIOR = nbStrings > 1 ? data[1] : QString();
3368 if ( anIOR.isEmpty() ) {
3372 // Get the geom object.
3373 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3375 // Clear the shape buffer
3376 GeometryGUI::ClearShapeBuffer (anObj);
3382 \brief Clears the shape buffer.
3384 This is a static method. It clears the shape buffer.
3386 \param theObj the object
3388 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3390 if ( CORBA::is_nil( theObj ) )
3393 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3394 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3395 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3397 SalomeApp_Application* app =
3398 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3399 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3404 _PTR(Study) aStudy = appStudy->studyDS();
3409 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3413 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3414 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3415 _PTR(GenericAttribute) anAttr;
3416 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3417 _PTR(AttributeIOR) anIOR ( anAttr );
3418 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3419 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3425 \brief Returns the object from IOR.
3427 This is a static method. It returns the object from its IOR.
3429 \param IOR object IOR
3430 \return GEOM object.
3432 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3434 GEOM::GEOM_Object_var geomObj;
3435 if ( !IOR.isEmpty() ) {
3436 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3437 ( IOR.toLatin1().constData() );
3438 if ( !CORBA::is_nil( corbaObj ) )
3439 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3441 return geomObj._retn();
3445 \brief Returns IOR of the object.
3447 This is a static method. It returns the object's IOR.
3449 \param object the GEOM object.
3450 \return object's IOR.
3452 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3455 if ( !CORBA::is_nil( object ) ) {
3456 CORBA::String_var anIOR =
3457 SalomeApp_Application::orb()->object_to_string( object );
3464 \brief Check if this object is can't be renamed in place
3466 This method can be re-implemented in the subclasses.
3467 Return true in case if object isn't reference or component (module root).
3469 \param entry column id
3470 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3472 bool GeometryGUI::renameAllowed( const QString& entry) const {
3474 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3475 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3476 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3478 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3482 Rename object by entry.
3483 \param entry entry of the object
3484 \param name new name of the object
3485 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3487 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3489 bool result = false;
3491 SalomeApp_Application* app =
3492 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3493 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3498 _PTR(Study) aStudy = appStudy->studyDS();
3503 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3505 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3509 _PTR(SObject) obj ( aStudy->FindObjectID(qUtf8Printable(entry)) );
3510 _PTR(GenericAttribute) anAttr;
3512 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3513 _PTR(AttributeName) aName (anAttr);
3515 aName->SetValue( name.toUtf8().data() ); // rename the SObject
3516 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3517 if (!CORBA::is_nil(anObj)) {
3518 anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
3519 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3520 emit SignalTextTreeRenameObject( entry );
3528 void GeometryGUI::updateMaterials()
3530 LightApp_Preferences* pref = preferences();
3532 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3533 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3534 if ( !materials.contains( currentMaterial ) )
3535 // user material set as default in the preferences, might be removed
3536 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3538 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3540 setPreferenceProperty( prefItem->id(),
3541 "strings", materials );
3542 prefItem->retrieve();
3548 \brief Check if the module allows "drag" operation of its objects.
3550 Overloaded from LightApp_Module class.
3552 This function is a part of the general drag-n-drop mechanism.
3553 The goal of this function is to check data object passed as a parameter
3554 and decide if it can be dragged or no.
3556 \param what data object being tested for drag operation
3557 \return \c true if module allows dragging of the specified object
3558 \sa isDropAccepted(), dropObjects()
3560 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3562 // we allow dragging object under root and object from folder
3563 int aLevel = what->level();
3564 bool anObjectInFolder = false;
3566 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3568 _PTR(SObject) aSO = dataObj->object();
3570 _PTR(GenericAttribute) anAttr;
3571 _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3572 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3573 _PTR(AttributeLocalID) aLocalID( anAttr );
3574 anObjectInFolder = aLocalID->Value() == 999;
3579 return aLevel == 2 || anObjectInFolder;
3583 \brief Check if the module allows "drop" operation on the given object.
3585 Overloaded from LightApp_Module class.
3587 This function is a part of the general drag-n-drop mechanism.
3588 The goal of this function is to check data object passed as a parameter
3589 and decide if it can be used as a target for the "drop" operation.
3590 The processing of the drop operation itself is done in the dropObjects() function.
3592 \param where target data object
3593 \return \c true if module supports dropping on the \a where data object
3594 \sa isDraggable(), dropObjects()
3596 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3598 // we allow dropping into folder and top-level GEOM object
3599 int aLevel = where->level();
3600 bool isFolder = false;
3602 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3604 _PTR(SObject) aSO = dataObj->object();
3606 _PTR(GenericAttribute) anAttr;
3607 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3608 _PTR(AttributeLocalID) aLocalID( anAttr );
3609 isFolder = aLocalID->Value() == 999;
3614 return aLevel == 1 || isFolder;
3618 \brief Complete drag-n-drop operation.
3620 Overloaded from LightApp_Module class.
3622 This function is a part of the general drag-n-drop mechanism.
3623 Its goal is to handle dropping of the objects being dragged according
3624 to the chosen operation (move). The dropping is performed in the
3625 context of the parent data object \a where and the \a row (position in the
3626 children index) at which the data should be dropped. If \a row is equal to -1,
3627 this means that objects are added to the end of the children list.
3629 \param what objects being dropped
3630 \param where target data object
3631 \param row child index at which the drop operation is performed
3632 \param action drag-n-drop operation (Qt::DropAction) - move
3634 \sa isDraggable(), isDropAccepted()
3636 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3637 const int row, Qt::DropAction action )
3639 if (action != Qt::CopyAction && action != Qt::MoveAction)
3640 return; // unsupported action
3642 // get parent object
3643 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3644 if ( !dataObj ) return; // wrong parent
3645 _PTR(SObject) parentObj = dataObj->object();
3647 // Find the current Study and StudyBuilder
3648 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3649 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3650 // collect all parents of the target node
3651 QStringList parentIDs;
3652 _PTR(SObject) parent = parentObj;
3653 while( !parent->IsNull() ) {
3654 parentIDs << parent->GetID().c_str();
3655 parent = aUseCaseBuilder->GetFather(parent);
3658 // collect objects being dropped
3659 GEOM::object_list_var objects = new GEOM::object_list();
3660 objects->length( what.count() );
3662 for ( int i = 0; i < what.count(); i++ ) {
3663 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3664 if ( !dataObj ) continue; // skip wrong objects
3665 _PTR(SObject) sobj = dataObj->object();
3666 // check that dropped object is not a parent of target object
3667 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3668 return; // it's not allowed to move node into it's child
3670 objects[i] = _CAST(SObject, sobj)->GetSObject();
3673 objects->length( count );
3675 // call engine function
3676 GetGeomGen()->Move( objects.in(), // what
3677 _CAST(SObject, parentObj)->GetSObject(), // where
3680 // update Object browser
3681 getApp()->updateObjectBrowser( false );
3684 void GeometryGUI::emitDimensionsUpdated( QString entry )
3686 emit DimensionsUpdated( entry );
3689 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3691 emit SignalAnnotationsUpdated( entry );