1 // Copyright (C) 2007-2024 CEA, EDF, 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 <Basics_OCCTVersion.hxx>
52 #include <SUIT_Desktop.h>
53 #include <SUIT_MessageBox.h>
54 #include <SUIT_ResourceMgr.h>
55 #include <SUIT_Session.h>
56 #include <SUIT_ViewManager.h>
58 #include <OCCViewer_ViewWindow.h>
59 #include <OCCViewer_ViewPort3d.h>
60 #include <OCCViewer_ViewModel.h>
61 #include <OCCViewer_ViewManager.h>
63 #include <PV3DViewer_ViewWindow.h>
64 #include <PV3DViewer_ViewModel.h>
65 #include <PV3DViewer_ViewManager.h>
67 #include <SOCC_ViewModel.h>
68 #include <SOCC_ViewWindow.h>
70 #include <SVTK_ViewWindow.h>
71 #include <SVTK_RenderWindowInteractor.h>
72 #include <SVTK_InteractorStyle.h>
73 #include <SVTK_ViewModel.h>
75 #ifndef DISABLE_GRAPHICSVIEW
76 #include <GraphicsView_Viewer.h>
79 #include <SalomeApp_Application.h>
80 #include <SalomeApp_DataObject.h>
81 #include <SalomeApp_Study.h>
82 #include <SalomeApp_Tools.h>
84 #include <LightApp_SelectionMgr.h>
85 #include <LightApp_VTKSelector.h>
86 #include <LightApp_DataObject.h>
87 #include <LightApp_Preferences.h>
89 #include <SALOME_LifeCycleCORBA.hxx>
90 #include <SALOME_ListIO.hxx>
92 #include <SALOMEDSClient_ClientFactory.hxx>
93 #include <SALOMEDSClient_IParameters.hxx>
94 #include "SALOME_KernelServices.hxx"
96 #include <SALOMEDS_SObject.hxx>
98 #include <QtxFontEdit.h>
99 #include <QtxInfoPanel.h>
110 #include <QSignalMapper>
111 #include <QFontDatabase>
113 #include <AIS_ListOfInteractive.hxx>
114 #include <AIS_ListIteratorOfListOfInteractive.hxx>
115 #include <Prs3d_Drawer.hxx>
116 #include <Prs3d_IsoAspect.hxx>
117 #include <Aspect_TypeOfMarker.hxx>
118 #include <OSD_SharedLibrary.hxx>
119 #include <NCollection_DataMap.hxx>
121 #include <TColStd_HArray1OfByte.hxx>
122 #include <TColStd_SequenceOfHAsciiString.hxx>
124 #include <utilities.h>
126 #include <vtkCamera.h>
127 #include <vtkRenderer.h>
129 #include <Standard_Failure.hxx>
130 #include <Standard_ErrorHandler.hxx>
132 #include <Font_SystemFont.hxx>
133 #include <Font_FontMgr.hxx>
134 #include <TCollection_HAsciiString.hxx>
136 #include "GEOM_version.h"
137 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
140 Standard_EXPORT CAM_Module* createModule() {
141 return new GeometryGUI();
144 Standard_EXPORT char* getModuleVersion() {
145 return (char*)GEOM_VERSION_STR;
149 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
151 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
153 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
154 if (CORBA::is_nil(myComponentGeom))
156 return GeometryGUI::myComponentGeom;
159 bool GeometryGUI::InitGeomGen()
162 if ( CORBA::is_nil( myComponentGeom ) ) return false;
166 //=======================================================================
167 // function : ClientSObjectToObject
169 //=======================================================================
170 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
172 _PTR(GenericAttribute) anAttr;
173 CORBA::Object_var anObj;
175 std::string aValue = theSObject->GetIOR();
176 if (strcmp(aValue.c_str(), "") != 0) {
177 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
178 anObj = anORB->string_to_object(aValue.c_str());
181 INFOS("ClientSObjectToObject - Unknown exception has occurred!!!");
183 return anObj._retn();
185 //=================================================================================
186 // function : IsInGeomComponent
187 // purpose : Check if an SObject is under GEOM component
188 //=================================================================================
189 bool GeometryGUI::IsInGeomComponent( _PTR(SObject) sobject )
192 if ( _PTR(SComponent) aComp = sobject->GetFatherComponent() )
193 return aComp->ComponentDataType() == "GEOM";
197 //=======================================================================
198 // function : GetStudy
200 //=======================================================================
201 SALOMEDS::Study_var GeometryGUI::getStudyServant()
203 SALOME_NamingService_Abstract *aNamingService = SalomeApp_Application::namingService();
204 CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
205 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
206 return aStudy._retn();
209 void GeometryGUI::Modified (bool theIsUpdateActions)
211 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
212 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
213 appStudy->Modified();
214 if ( theIsUpdateActions )
215 app->updateActions();
220 //=======================================================================
221 // function : GeometryGUI::GeometryGUI()
222 // purpose : Constructor
223 //=======================================================================
224 GeometryGUI::GeometryGUI() : SalomeApp_Module( "GEOM" )
226 if ( CORBA::is_nil( myComponentGeom ) )
228 SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
229 Engines::EngineComponent_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
230 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
233 myActiveDialogBox = 0;
235 gp_Pnt origin = gp_Pnt(0., 0., 0.);
236 gp_Dir direction = gp_Dir(0., 0., 1.);
237 myWorkingPlane = gp_Ax3(origin, direction);
240 myLocalSelectionMode = GEOM_ALLOBJECTS;
242 myCreationInfoWdg = 0;
246 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ), Qt::UniqueConnection );
248 Q_INIT_RESOURCE( GEOMGUI );
251 //=======================================================================
252 // function : GeometryGUI::~GeometryGUI()
253 // purpose : Destructor
254 //=======================================================================
255 GeometryGUI::~GeometryGUI()
257 while (!myOCCSelectors.isEmpty())
258 delete myOCCSelectors.takeFirst();
260 while (!myVTKSelectors.isEmpty())
261 delete myVTKSelectors.takeFirst();
263 qDeleteAll(myGUIMap);
266 //=======================================================================
267 // function : GeometryGUI::getLibrary()
268 // purpose : get or load GUI library by name [ internal ]
269 //=======================================================================
270 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
271 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
273 if ( !myGUIMap.contains( libraryName ) ) {
274 // try to load library if it is not loaded yet
276 QString dirs = Qtx::getenv( "PATH" );
277 #elif defined(__APPLE__)
278 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
280 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
288 if ( !dirs.isEmpty() ) {
289 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
290 QListIterator<QString> it( dirList ); it.toBack();
291 while ( it.hasPrevious() ) {
292 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
294 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
295 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
297 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
298 continue; // continue search further
300 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
301 if ( osdF != NULL ) {
302 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
303 GEOMGUI* libGUI = (*func)( this );
305 myGUIMap[ libraryName ] = libGUI;
306 break; // found and loaded!
313 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
316 //=======================================================================
317 // function : GeometryGUI::getPluginLibrary()
318 // purpose : get or load GUI Plugin library by name [ internal ]
319 //=======================================================================
320 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
321 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
323 if ( !myGUIMap.contains( libraryName ) ) {
324 // try to load library if it is not loaded yet
327 QString dirs = Qtx::getenv( "PATH" );
328 #elif defined(__APPLE__)
329 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
331 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
339 if ( !dirs.isEmpty() ) {
340 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
341 QListIterator<QString> it( dirList ); it.toBack();
342 while ( it.hasPrevious() ) {
343 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
345 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
346 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
348 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
349 continue; // continue search further
351 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
352 if ( osdF != NULL ) {
353 PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
354 GEOMPluginGUI* libGUI = (*func)( this );
356 myGUIMap[ libraryName ] = libGUI;
357 break; // found and loaded!
364 return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
367 //=======================================================================
368 // function : GeometryGUI::ActiveWorkingPlane()
369 // purpose : Activate Working Plane View
370 //=======================================================================
371 void GeometryGUI::ActiveWorkingPlane()
373 gp_Dir DZ = myWorkingPlane.Direction();
374 gp_Dir DY = myWorkingPlane.YDirection();
376 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
377 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
378 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
379 bool ViewPV3D = ( window && window->getViewManager()->getType() == PV3DViewer_ViewModel::Type() );
382 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
384 Handle(V3d_View) view3d = vw->getViewPort()->getView();
386 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
387 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
391 else if ( ViewVTK ) {
392 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
394 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
396 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
397 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
398 camera->SetFocalPoint(0,0,0);
403 else if ( ViewPV3D ) {
404 PV3DViewer_ViewWindow* vw = dynamic_cast<PV3DViewer_ViewWindow*>( window );
410 //=======================================================================
411 // function : GeometryGUI::SetActiveDialogBox()
412 // purpose : Set active dialog box
413 //=======================================================================
414 GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
416 if ( !myAnnotationMgr )
417 myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
418 return myAnnotationMgr;
421 //=======================================================================
422 // function : GeometryGUI::SetActiveDialogBox()
423 // purpose : Set active dialog box
424 //=======================================================================
425 GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
427 return myTextTreeWdg;
430 //=======================================================================
431 // function : GeometryGUI::SetActiveDialogBox()
432 // purpose : Set active dialog box
433 //=======================================================================
434 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
436 myActiveDialogBox = (QDialog*)aDlg;
439 //=======================================================================
440 // function : GeometryGUI::EmitSignalDeactivateDialog()
441 // purpose : Emit a signal to deactivate the active dialog Box
442 //=======================================================================
443 void GeometryGUI::EmitSignalDeactivateDialog()
445 emit SignalDeactivateActiveDialog();
448 //=======================================================================
449 // function : GeometryGUI::EmitSignalCloseAllDialogs()
450 // purpose : Emit a signal to close all non modal dialogs box
451 //=======================================================================
452 void GeometryGUI::EmitSignalCloseAllDialogs()
454 emit SignalCloseAllDialogs();
457 //=======================================================================
458 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
459 // purpose : Emit a signal to inform that default real spin box step has
461 //=======================================================================
462 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
464 emit SignalDefaultStepValueChanged(newVal);
467 //=======================================================================
468 // function : GeometryGUI::OnGUIEvent()
469 // purpose : common slot for all menu/toolbar actions
470 //=======================================================================
471 void GeometryGUI::OnGUIEvent()
473 const QObject* obj = sender();
474 if ( !obj || !obj->inherits( "QAction" ) )
476 int id = actionId((QAction*)obj);
481 //=======================================================================
482 // function : GeometryGUI::OnGUIEvent()
483 // purpose : manage all events on GUI [static]
484 //=======================================================================
485 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
487 SUIT_Application* anApp = application();
489 SUIT_Desktop* desk = anApp->desktop();
491 // check type of the active viewframe
492 SUIT_ViewWindow* window = desk->activeWindow();
493 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
494 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
495 #ifndef DISABLE_GRAPHICSVIEW
496 bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
500 // if current viewframe is not of OCC and not of VTK type - return immediately
501 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
502 QList<int> NotViewerDependentCommands;
503 NotViewerDependentCommands << GEOMOp::OpDelete
505 << GEOMOp::OpShowOnly
506 << GEOMOp::OpShowOnlyChildren
507 << GEOMOp::OpDiscloseChildren
508 << GEOMOp::OpConcealChildren
509 << GEOMOp::OpUnpublishObject
510 << GEOMOp::OpPublishObject
511 << GEOMOp::OpPointMarker
512 << GEOMOp::OpCreateFolder
513 << GEOMOp::OpSortChildren;
514 if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
515 // activate OCC viewer
516 getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
519 // fix for IPAL9103, point 2
520 if ( CORBA::is_nil( GetGeomGen() ) ) {
521 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
526 // find corresponding GUI library
528 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
529 createOriginAndBaseVectors(); // internal operation
531 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
532 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
533 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
534 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
535 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
536 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
537 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
538 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
539 case GEOMOp::OpDelete: // MENU EDIT - DELETE
540 #ifndef DISABLE_PYCONSOLE
541 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
543 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
544 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
545 case GEOMOp::OpColor: // POPUP MENU - COLOR
546 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
547 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
548 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
549 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
550 case GEOMOp::OpIsos: // POPUP MENU - ISOS
551 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
552 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
553 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
554 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
555 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
556 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
557 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
558 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
559 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
560 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
561 case GEOMOp::OpMaterialMenu: // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
562 case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
563 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
564 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
565 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
566 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
567 case GEOMOp::OpClsBringToFront: //
568 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
569 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
570 #ifndef DISABLE_GRAPHICSVIEW
571 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
573 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
574 libName = "GEOMToolsGUI";
576 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
577 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
578 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
579 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
580 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
581 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
582 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
583 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
584 case GEOMOp::OpHide: // MENU VIEW - ERASE
585 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
586 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
587 case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
588 case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
589 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
590 case GEOMOp::OpShading: // POPUP MENU - SHADING
591 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
592 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
593 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
594 case GEOMOp::OpVertices: // POPUP MENU - VERTICES
595 case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
596 libName = "DisplayGUI";
598 case GEOMOp::OpPoint: // MENU BASIC - POINT
599 case GEOMOp::OpLine: // MENU BASIC - LINE
600 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
601 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
602 case GEOMOp::OpArc: // MENU BASIC - ARC
603 case GEOMOp::OpVector: // MENU BASIC - VECTOR
604 case GEOMOp::OpPlane: // MENU BASIC - PLANE
605 case GEOMOp::OpCurve: // MENU BASIC - CURVE
606 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
607 libName = "BasicGUI";
609 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
610 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
611 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
612 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
613 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
614 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
615 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
616 libName = "PrimitiveGUI";
618 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
619 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
620 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
621 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
622 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
623 case GEOMOp::OpThickness: // MENU GENERATION - THICKNESS
624 libName = "GenerationGUI";
626 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
627 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
628 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
629 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
630 case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
632 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
634 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
635 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
636 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
637 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
638 case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
639 libName = "EntityGUI";
641 case GEOMOp::OpEdge: // MENU BUILD - EDGE
642 case GEOMOp::OpWire: // MENU BUILD - WIRE
643 case GEOMOp::OpFace: // MENU BUILD - FACE
644 case GEOMOp::OpShell: // MENU BUILD - SHELL
645 case GEOMOp::OpSolid: // MENU BUILD - SOLID
646 case GEOMOp::OpCompound: // MENU BUILD - COMPOUND
647 libName = "BuildGUI";
649 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
650 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
651 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
652 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
653 libName = "BooleanGUI";
655 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
656 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
657 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
658 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
659 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
660 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
661 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
662 case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
663 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
664 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
665 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
666 case GEOMOp::OpExtension: // MENU TRANSFORMATION - EXTENSION
667 libName = "TransformationGUI";
669 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
670 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
671 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
672 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
673 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
674 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
675 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
676 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
677 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
678 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
679 case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
680 case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
681 libName = "OperationGUI";
683 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
684 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
685 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
686 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
687 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
688 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
689 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
690 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
691 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
692 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
693 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
694 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
695 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
696 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
697 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
698 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
699 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
700 case GEOMOp::OpInspectObj: // MENU REPAIR - INSPECT OBJECT
701 libName = "RepairGUI";
703 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
704 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
705 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
706 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
707 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
708 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
709 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
710 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
711 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
712 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
713 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
714 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
715 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
716 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
717 case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
718 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
719 case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
720 case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
721 case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
722 #ifndef DISABLE_PLOT2DVIEWER
723 case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
725 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
726 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
727 case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
728 case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
729 libName = "MeasureGUI";
731 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
732 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
733 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
734 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
735 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
736 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
737 libName = "GroupGUI";
739 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
740 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
741 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
742 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
743 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
744 libName = "BlocksGUI";
746 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
747 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
748 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
749 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
750 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
751 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
752 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
753 //libName = "AdvancedGUI";
756 if (myPluginActions.contains(id)) {
757 libName = myPluginActions[id].first;
759 GEOMPluginGUI* library = 0;
760 if ( !libName.isEmpty() ) {
762 libName = libName + ".dll";
763 #elif defined(__APPLE__)
764 libName = QString( "lib" ) + libName + ".dylib";
766 libName = QString( "lib" ) + libName + ".so";
768 library = getPluginLibrary( libName );
771 // call method of corresponding GUI library
773 //QString action ("%1");
774 //action = action.arg(id);
776 //if( !theParam.isValid() )
777 library->OnGUIEvent( myPluginActions[id].second, desk );
779 // library->OnGUIEvent( id, desk, theParam);
782 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
784 updateCreationInfo();
790 GEOMGUI* library = 0;
791 if ( !libName.isEmpty() ) {
793 libName = libName + ".dll";
794 #elif defined(__APPLE__)
795 libName = QString( "lib" ) + libName + ".dylib";
797 libName = QString( "lib" ) + libName + ".so";
799 library = getLibrary( libName );
802 // call method of corresponding GUI library
804 if( !theParam.isValid() )
805 library->OnGUIEvent( id, desk );
807 library->OnGUIEvent( id, desk, theParam);
810 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
812 updateCreationInfo();
815 //=================================================================================
816 // function : GeometryGUI::activateOperation()
818 //=================================================================================
819 bool GeometryGUI::activateOperation( int actionId )
821 OnGUIEvent(actionId);
825 //=================================================================================
826 // function : GeometryGUI::activateOperation()
828 //=================================================================================
829 bool GeometryGUI::activateOperation( const QString& actionId )
833 int id = actionId.toInt(&isOk);
840 //=================================================================================
841 // function : GeometryGUI::activateOperation()
843 //=================================================================================
844 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
848 QString pluginLib = plugin;
849 // TODO: if <plugin> is a plugin name, find plugin library name
850 if (myPluginLibs.contains(plugin))
851 pluginLib = myPluginLibs[plugin];
853 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
854 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
855 const PluginAction& anAction = actionsIter.value();
856 if (anAction.first == pluginLib && anAction.second == actionId) {
857 // activate operation
858 OnGUIEvent(actionsIter.key());
866 //=================================================================================
867 // function : GeometryGUI::OnKeyPress()
868 // purpose : Called when any key is pressed by user [static]
869 //=================================================================================
870 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
872 if ( !application() )
874 foreach ( GEOMGUI* lib, myGUIMap )
875 lib->OnKeyPress( e, application()->desktop(), w );
878 //=================================================================================
879 // function : GeometryGUI::OnMouseMove()
880 // purpose : Manages mouse move events [static]
881 //=================================================================================
882 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
884 if ( !application() )
886 foreach ( GEOMGUI* lib, myGUIMap )
887 lib->OnMouseMove( e, application()->desktop(), w );
890 //=================================================================================
891 // function : GeometryGUI::OnMouseRelease()
892 // purpose : Manages mouse release events [static]
893 //=================================================================================
894 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
896 if ( !application() )
898 foreach ( GEOMGUI* lib, myGUIMap )
899 lib->OnMouseRelease( e, application()->desktop(), w );
902 //=================================================================================
903 // function : GeometryGUI::OnMousePress()
904 // purpose : Manage mouse press events [static]
905 //=================================================================================
906 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
908 if ( !application() )
910 foreach ( GEOMGUI* lib, myGUIMap )
911 lib->OnMousePress( e, application()->desktop(), w );
914 //=======================================================================
915 // function : createGeomAction
917 //=======================================================================
918 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
919 const int accel, const bool toggle, const QString& shortcutAction )
921 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
922 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
923 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
925 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
927 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
928 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
930 application()->desktop(),
932 this, SLOT( OnGUIEvent() ),
936 //=======================================================================
937 // function : createOriginAndBaseVectors
939 //=======================================================================
940 void GeometryGUI::createOriginAndBaseVectors()
942 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
943 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
945 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
949 if ( !CORBA::is_nil( GetGeomGen() ) ) {
950 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
951 if ( !aBasicOperations->_is_nil() ) {
952 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
953 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
954 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
955 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
956 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
957 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
959 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
960 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
961 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
962 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
963 anOrigin->UnRegister();
967 aBasicOperations->UnRegister();
969 getApp()->updateObjectBrowser( true );
975 //=======================================================================
976 // function : GeometryGUI::initialize()
977 // purpose : Called when GEOM module is created
978 //=======================================================================
979 void GeometryGUI::initialize( CAM_Application* app )
981 SalomeApp_Module::initialize( app );
983 setActionLoggingEnabled( true ); // enable action logging
985 // ----- create actions --------------
987 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
989 createGeomAction( GEOMOp::OpPoint, "POINT" );
990 createGeomAction( GEOMOp::OpLine, "LINE" );
991 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
992 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
993 createGeomAction( GEOMOp::OpArc, "ARC" );
994 createGeomAction( GEOMOp::OpCurve, "CURVE" );
995 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
996 createGeomAction( GEOMOp::OpVector, "VECTOR" );
997 createGeomAction( GEOMOp::OpPlane, "PLANE" );
998 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
999 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
1000 createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
1002 createGeomAction( GEOMOp::OpBox, "BOX" );
1003 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
1004 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
1005 createGeomAction( GEOMOp::OpTorus, "TORUS" );
1006 createGeomAction( GEOMOp::OpCone, "CONE" );
1007 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
1008 createGeomAction( GEOMOp::OpDisk, "DISK" );
1010 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
1011 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
1012 createGeomAction( GEOMOp::OpFilling, "FILLING" );
1013 createGeomAction( GEOMOp::OpPipe, "PIPE" );
1014 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
1015 createGeomAction( GEOMOp::OpThickness, "THICKNESS" );
1017 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
1018 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
1019 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
1020 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
1021 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
1023 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
1024 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
1026 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
1028 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
1029 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
1031 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
1032 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
1033 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
1035 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1037 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1038 createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1040 createGeomAction( GEOMOp::OpEdge, "EDGE" );
1041 createGeomAction( GEOMOp::OpWire, "WIRE" );
1042 createGeomAction( GEOMOp::OpFace, "FACE" );
1043 createGeomAction( GEOMOp::OpShell, "SHELL" );
1044 createGeomAction( GEOMOp::OpSolid, "SOLID" );
1045 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
1047 createGeomAction( GEOMOp::OpFuse, "FUSE" );
1048 createGeomAction( GEOMOp::OpCommon, "COMMON" );
1049 createGeomAction( GEOMOp::OpCut, "CUT" );
1050 createGeomAction( GEOMOp::OpSection, "SECTION" );
1052 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
1053 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
1054 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
1055 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
1056 createGeomAction( GEOMOp::OpScale, "SCALE" );
1057 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
1058 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
1059 createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
1060 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1061 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
1062 createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
1064 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
1065 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
1066 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
1067 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
1068 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
1069 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
1070 createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
1071 createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
1072 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
1073 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
1074 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
1075 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
1077 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1078 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
1079 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
1081 createGeomAction( GEOMOp::OpSewing, "SEWING" );
1082 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
1083 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
1084 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
1085 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
1086 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1087 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1088 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1089 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1090 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1091 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1092 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1093 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1094 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1095 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1096 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1097 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1098 createGeomAction( GEOMOp::OpInspectObj, "INSPECT_OBJECT" );
1100 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1101 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1102 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1103 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1104 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1105 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1106 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1107 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1108 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1109 createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
1110 createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
1111 createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1113 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1114 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1115 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1116 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1117 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1118 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1119 createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
1120 #ifndef DISABLE_PLOT2DVIEWER
1121 createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
1124 #ifndef DISABLE_PYCONSOLE
1125 #ifdef _DEBUG_ // PAL16821
1126 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1130 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1131 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1132 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1133 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1134 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1135 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1136 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1137 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1138 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1139 createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
1140 createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
1141 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1142 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1143 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1144 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1145 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1146 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1147 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1148 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1149 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1150 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1151 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1152 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1153 createGeomAction( GEOMOp::OpHide, "ERASE" );
1155 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1156 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1157 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1158 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1159 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1160 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1161 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1162 createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
1163 createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
1164 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1165 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1166 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1167 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1168 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1169 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1170 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1171 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1172 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1173 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1174 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1175 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1176 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1177 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1178 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1179 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1180 createGeomAction( GEOMOp::OpMaterialMenu, "POP_MATERIAL_PROPERTIES");
1181 action(GEOMOp::OpMaterialMenu)->setMenu( new QMenu() );
1182 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1183 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1184 #ifndef DISABLE_GRAPHICSVIEW
1185 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1187 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1188 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1189 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1190 createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1191 createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1193 // Create actions for increase/decrease transparency shortcuts
1194 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1195 "Geometry:Increase transparency");
1196 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1197 "Geometry:Decrease transparency");
1199 // Create actions for increase/decrease number of isolines
1200 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1201 "Geometry:Increase number of isolines");
1202 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1203 "Geometry:Decrease number of isolines");
1205 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1206 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1207 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1208 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1209 //@@ 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 @@//
1211 // ---- create menus --------------------------
1213 /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1215 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1216 createMenu( GEOMOp::OpDelete, editId, -1 );
1218 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1220 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1221 createMenu( GEOMOp::OpPoint, basicId, -1 );
1222 createMenu( GEOMOp::OpLine, basicId, -1 );
1223 createMenu( GEOMOp::OpCircle, basicId, -1 );
1224 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1225 createMenu( GEOMOp::OpArc, basicId, -1 );
1226 createMenu( GEOMOp::OpCurve, basicId, -1 );
1227 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1228 createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1229 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1230 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1231 createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1232 createMenu( separator(), basicId, -1 );
1233 createMenu( GEOMOp::OpVector, basicId, -1 );
1234 createMenu( GEOMOp::OpPlane, basicId, -1 );
1235 createMenu( GEOMOp::OpLCS, basicId, -1 );
1236 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1238 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1239 createMenu( GEOMOp::OpBox, primId, -1 );
1240 createMenu( GEOMOp::OpCylinder, primId, -1 );
1241 createMenu( GEOMOp::OpSphere, primId, -1 );
1242 createMenu( GEOMOp::OpTorus, primId, -1 );
1243 createMenu( GEOMOp::OpCone, primId, -1 );
1244 createMenu( GEOMOp::OpRectangle, primId, -1 );
1245 createMenu( GEOMOp::OpDisk, primId, -1 );
1246 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1248 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1249 createMenu( GEOMOp::OpPrism, genId, -1 );
1250 createMenu( GEOMOp::OpRevolution, genId, -1 );
1251 createMenu( GEOMOp::OpFilling, genId, -1 );
1252 createMenu( GEOMOp::OpPipe, genId, -1 );
1253 createMenu( GEOMOp::OpPipePath, genId, -1 );
1254 createMenu( GEOMOp::OpThickness, genId, -1 );
1256 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1257 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1258 //@@ 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 @@//
1260 createMenu( separator(), newEntId, -1 );
1262 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1263 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1264 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1265 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1266 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1267 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1269 createMenu( separator(), newEntId, -1 );
1271 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1272 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1273 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1275 createMenu( separator(), newEntId, -1 );
1277 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1278 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1279 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1280 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1281 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1283 createMenu( separator(), newEntId, -1 );
1285 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1287 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1288 createMenu( GEOMOp::OpEdge, buildId, -1 );
1289 createMenu( GEOMOp::OpWire, buildId, -1 );
1290 createMenu( GEOMOp::OpFace, buildId, -1 );
1291 createMenu( GEOMOp::OpShell, buildId, -1 );
1292 createMenu( GEOMOp::OpSolid, buildId, -1 );
1293 createMenu( GEOMOp::OpCompound, buildId, -1 );
1295 createMenu( separator(), newEntId, -1 );
1297 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1299 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1302 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1304 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1305 createMenu( GEOMOp::OpFuse, boolId, -1 );
1306 createMenu( GEOMOp::OpCommon, boolId, -1 );
1307 createMenu( GEOMOp::OpCut, boolId, -1 );
1308 createMenu( GEOMOp::OpSection, boolId, -1 );
1310 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1311 createMenu( GEOMOp::OpTranslate, transId, -1 );
1312 createMenu( GEOMOp::OpRotate, transId, -1 );
1313 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1314 createMenu( GEOMOp::OpMirror, transId, -1 );
1315 createMenu( GEOMOp::OpScale, transId, -1 );
1316 createMenu( GEOMOp::OpOffset, transId, -1 );
1317 createMenu( GEOMOp::OpProjection, transId, -1 );
1318 createMenu( GEOMOp::OpExtension, transId, -1 );
1319 createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
1320 createMenu( separator(), transId, -1 );
1321 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1322 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1324 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1325 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1326 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1327 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1329 createMenu( separator(), operId, -1 );
1331 createMenu( GEOMOp::OpPartition, operId, -1 );
1332 createMenu( GEOMOp::OpArchimede, operId, -1 );
1333 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1334 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1335 createMenu( GEOMOp::OpTransferData, operId, -1 );
1336 createMenu( GEOMOp::OpExtraction, operId, -1 );
1338 createMenu( separator(), operId, -1 );
1340 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1341 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1342 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1343 createMenu( GEOMOp::OpChamfer, operId, -1 );
1344 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1345 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1347 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1348 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1349 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1350 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1351 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1352 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1353 createMenu( GEOMOp::OpSewing, repairId, -1 );
1354 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1355 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1356 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1357 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1358 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1359 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1360 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1361 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1362 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1363 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1364 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1366 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1367 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1368 createMenu( GEOMOp::OpProperties, measurId, -1 );
1369 createMenu( separator(), measurId, -1 );
1370 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1371 createMenu( GEOMOp::OpInertia, measurId, -1 );
1372 createMenu( GEOMOp::OpNormale, measurId, -1 );
1373 createMenu( separator(), measurId, -1 );
1374 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1375 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1376 createMenu( separator(), measurId, -1 );
1378 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1379 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1380 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1381 createMenu( GEOMOp::OpAngle, dimId, -1 );
1382 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1384 createMenu( GEOMOp::OpAnnotation, measurId, -1 );
1386 createMenu( separator(), measurId, -1 );
1387 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1388 createMenu( separator(), measurId, -1 );
1389 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1390 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1391 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1392 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1393 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1394 createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1395 createMenu( GEOMOp::OpInspectObj, measurId, -1 );
1396 #ifndef DISABLE_PLOT2DVIEWER
1397 createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1400 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1401 #ifndef DISABLE_PYCONSOLE
1402 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1403 createMenu( separator(), toolsId, -1 );
1404 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1408 createMenu( separator(), toolsId, -1 );
1409 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1410 createMenu( separator(), toolsId, -1 );
1412 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1413 createMenu( separator(), viewId, -1 );
1415 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1416 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1417 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1418 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1419 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1420 createMenu( separator(), dispmodeId, -1 );
1421 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1422 createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
1423 createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
1425 createMenu( separator(), viewId, -1 );
1426 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1427 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1428 createMenu( separator(), viewId, -1 );
1429 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1430 createMenu( separator(), viewId, -1 );
1434 because of these items are accessible through object browser and viewers
1435 we have removed they from main menu
1437 createMenu( GEOMOp::OpShow, viewId, -1 );
1438 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1439 createMenu( GEOMOp::OpHide, viewId, -1 );
1442 // ---- create toolbars --------------------------
1444 int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1445 createTool( GEOMOp::OpPoint, basicTbId );
1446 createTool( GEOMOp::OpLine, basicTbId );
1447 createTool( GEOMOp::OpCircle, basicTbId );
1448 createTool( GEOMOp::OpEllipse, basicTbId );
1449 createTool( GEOMOp::OpArc, basicTbId );
1450 createTool( GEOMOp::OpCurve, basicTbId );
1451 createTool( GEOMOp::OpVector, basicTbId );
1452 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1453 createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
1454 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1455 createTool( GEOMOp::OpIsoline, basicTbId );
1456 createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
1457 createTool( GEOMOp::OpPlane, basicTbId );
1458 createTool( GEOMOp::OpLCS, basicTbId );
1459 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1461 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1462 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1463 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1465 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1466 createTool( GEOMOp::OpBox, primTbId );
1467 createTool( GEOMOp::OpCylinder, primTbId );
1468 createTool( GEOMOp::OpSphere, primTbId );
1469 createTool( GEOMOp::OpTorus, primTbId );
1470 createTool( GEOMOp::OpCone, primTbId );
1471 createTool( GEOMOp::OpRectangle, primTbId );
1472 createTool( GEOMOp::OpDisk, primTbId );
1473 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1475 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1476 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1477 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1479 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1480 createTool( GEOMOp::OpFuse, boolTbId );
1481 createTool( GEOMOp::OpCommon, boolTbId );
1482 createTool( GEOMOp::OpCut, boolTbId );
1483 createTool( GEOMOp::OpSection, boolTbId );
1485 int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1486 createTool( GEOMOp::OpPrism, genTbId );
1487 createTool( GEOMOp::OpRevolution, genTbId );
1488 createTool( GEOMOp::OpFilling, genTbId );
1489 createTool( GEOMOp::OpPipe, genTbId );
1490 createTool( GEOMOp::OpPipePath, genTbId );
1491 createTool( GEOMOp::OpThickness, genTbId );
1493 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1494 createTool( GEOMOp::OpTranslate, transTbId );
1495 createTool( GEOMOp::OpRotate, transTbId );
1496 createTool( GEOMOp::OpChangeLoc, transTbId );
1497 createTool( GEOMOp::OpMirror, transTbId );
1498 createTool( GEOMOp::OpScale, transTbId );
1499 createTool( GEOMOp::OpOffset, transTbId );
1500 createTool( GEOMOp::OpProjection, transTbId );
1501 createTool( GEOMOp::OpExtension, transTbId );
1502 createTool( GEOMOp::OpProjOnCyl, transTbId );
1503 createTool( separator(), transTbId );
1504 createTool( GEOMOp::OpMultiTranslate, transTbId );
1505 createTool( GEOMOp::OpMultiRotate, transTbId );
1507 int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1508 createTool( GEOMOp::OpExplode, operTbId );
1509 createTool( GEOMOp::OpPartition, operTbId );
1510 createTool( GEOMOp::OpArchimede, operTbId );
1511 createTool( GEOMOp::OpShapesOnShape, operTbId );
1512 createTool( GEOMOp::OpSharedShapes, operTbId );
1513 createTool( GEOMOp::OpTransferData, operTbId );
1514 createTool( GEOMOp::OpExtraction, operTbId );
1516 int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1517 createTool( GEOMOp::OpFillet1d, featTbId );
1518 createTool( GEOMOp::OpFillet2d, featTbId );
1519 createTool( GEOMOp::OpFillet3d, featTbId );
1520 createTool( GEOMOp::OpChamfer, featTbId );
1521 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1522 createTool( GEOMOp::OpExtrudedCut, featTbId );
1524 int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1525 createTool( GEOMOp::OpEdge, buildTbId );
1526 createTool( GEOMOp::OpWire, buildTbId );
1527 createTool( GEOMOp::OpFace, buildTbId );
1528 createTool( GEOMOp::OpShell, buildTbId );
1529 createTool( GEOMOp::OpSolid, buildTbId );
1530 createTool( GEOMOp::OpCompound, buildTbId );
1532 int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1533 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1534 createTool( GEOMOp::OpProperties, measureTbId );
1535 createTool( GEOMOp::OpCenterMass, measureTbId );
1536 createTool( GEOMOp::OpInertia, measureTbId );
1537 createTool( GEOMOp::OpNormale, measureTbId );
1538 createTool( separator(), measureTbId );
1539 createTool( GEOMOp::OpBoundingBox, measureTbId );
1540 createTool( GEOMOp::OpMinDistance, measureTbId );
1541 createTool( GEOMOp::OpAngle, measureTbId );
1542 createTool( GEOMOp::OpAnnotation, measureTbId );
1543 createTool( GEOMOp::OpTolerance , measureTbId );
1544 createTool( separator(), measureTbId );
1545 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1546 createTool( GEOMOp::OpFreeFaces, measureTbId );
1547 createTool( separator(), measureTbId );
1548 createTool( GEOMOp::OpWhatIs, measureTbId );
1549 createTool( GEOMOp::OpCheckShape, measureTbId );
1550 createTool( GEOMOp::OpCheckCompound, measureTbId );
1551 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1552 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1553 createTool( GEOMOp::OpFastCheckInters, measureTbId );
1555 int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1556 createTool( GEOMOp::OpPictureImport, picturesTbId );
1558 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1561 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1562 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1563 //@@ 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 @@//
1565 // ---- create popup menus --------------------------
1567 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1568 QString clientOCC = "(client='OCCViewer')";
1569 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1570 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1572 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1573 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1574 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1575 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1577 QString notGEOMShape = "(not ($component={'GEOM'}) and ($displayer={'Geometry'}))";
1579 QString autoColorPrefix =
1580 "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1582 QtxPopupMgr* mgr = popupMgr();
1584 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1585 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1586 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1587 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1588 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1589 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1590 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1591 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1593 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1594 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1595 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1596 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1597 mgr->insert( separator(), -1, -1 ); // -----------
1599 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1600 QString bringRule = clientOCCorOB + " and ($displayer={'Geometry'}) and isFolder=false and (selcount>0) and isOCC=true";
1601 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1602 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1603 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1604 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1605 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1606 mgr->insert( separator(), -1, -1 ); // -----------
1607 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1608 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1609 //mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1610 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1611 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1612 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1613 // mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1614 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1615 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1616 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1617 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1618 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1619 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1620 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1621 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1622 mgr->insert( separator(), dispmodeId, -1 );
1623 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1624 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1625 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1626 mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1627 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1628 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1629 mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1630 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1631 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1632 mgr->insert( separator(), -1, -1 ); // -----------
1634 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1635 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($displayer={'Geometry'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1636 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1637 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1638 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1639 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1640 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1641 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1642 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1643 mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and ($type in {'Shape' 'Group' 'Field' 'FieldStep'} or " + notGEOMShape + ") and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1645 // material properties
1646 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1647 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=false", QtxPopupMgr::VisibleRule );
1648 mgr->insert( action( GEOMOp::OpMaterialMenu ), -1, -1 );
1649 mgr->setRule( action( GEOMOp::OpMaterialMenu ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=true", QtxPopupMgr::VisibleRule );
1652 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1653 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1655 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1656 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1657 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1659 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1660 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1662 mgr->insert( separator(), -1, -1 ); // -----------
1663 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1664 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1665 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1666 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1667 mgr->insert( separator(), -1, -1 ); // -----------
1669 mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
1670 mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1671 mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
1672 mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1673 mgr->insert( separator(), -1, -1 ); // -----------
1675 //QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1676 // onlyComponent = "((type='Component') and selcount=1)",
1677 // rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1678 // types = "'Shape' 'Group' 'FieldStep'";
1680 QString canDisplay = "($displayer={'Geometry'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1681 onlyComponent = "((type='Component') and ($component={'GEOM'}) and selcount=1)",
1682 rule = canDisplay + "and ((($type in {%1} or " + notGEOMShape + ") and( %2 )) or " + onlyComponent + ")",
1683 types = "'Shape' 'Group' 'FieldStep'";
1685 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1686 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1688 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1689 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1691 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1692 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1694 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1696 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1697 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1698 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1699 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1700 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1701 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1702 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1703 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1704 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1705 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1706 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1707 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1708 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1709 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1710 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1711 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1712 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1713 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1714 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1715 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1716 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1717 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1718 mgr->insert( separator(), selectonlyId, -1);
1719 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1720 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1721 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1722 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1723 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1724 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1725 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1727 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1729 mgr->insert( separator(), -1, -1 ); // -----------
1730 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1731 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1732 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1733 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1734 mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1735 mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1736 mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1737 mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1739 mgr->insert( separator(), -1, -1 ); // -----------
1740 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1741 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1743 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1744 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1746 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1747 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1749 mgr->insert( separator(), -1, -1 ); // -----------
1750 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1751 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1753 mgr->insert( separator(), -1, -1 ); // -----------
1754 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1755 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1757 #ifndef DISABLE_GRAPHICSVIEW
1758 mgr->insert( separator(), -1, -1 ); // -----------
1759 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1760 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1763 mgr->insert( separator(), -1, -1 ); // -----------
1764 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1765 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1767 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1769 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1771 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1772 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1773 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1776 // create plugin actions and menus
1780 //=======================================================================
1781 // function : GeometryGUI::addPluginActions()
1783 //=======================================================================
1784 void GeometryGUI::addPluginActions()
1787 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1788 if (!resMgr) return;
1790 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1791 if (!appStudy) return;
1793 // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1795 GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1797 int id = GEOMOp::OpLastOperationID; // TODO?
1800 GEOMUtils::PluginInfo::const_iterator it;
1801 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1802 // bind action lib and label to its ID for activateOperation() method proper work
1803 GEOMUtils::PluginData pdata = (*it);
1804 myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1805 std::list<GEOMUtils::ActionData> actions = (*it).actions;
1806 std::list<GEOMUtils::ActionData>::const_iterator ait;
1807 for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1808 GEOMUtils::ActionData adata = (*ait);
1811 if ( !adata.icon.empty() )
1812 icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1814 QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1815 QString actionName = smenus.last();
1816 actionName = actionName.toUpper().prepend( "MEN_" );
1817 smenus.removeLast();
1819 // path to action in toolbar
1820 QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1821 QString actionTool = stools.last();
1822 actionTool = actionTool.toUpper().prepend( "TOP_" );
1823 stools.removeLast();
1825 QString actionStat = adata.statusText.c_str();
1826 actionStat = actionStat.toUpper().prepend( "STB_" );
1828 createAction( id, // ~ adata.label
1829 tr( actionTool.toLatin1().constData() ),
1831 tr( actionName.toLatin1().constData() ),
1832 tr( actionStat.toLatin1().constData() ),
1833 QKeySequence( tr( adata.accel.c_str() ) ),
1834 application()->desktop(),
1836 this, SLOT( OnGUIEvent() ),
1837 QString() /*shortcutAction*/ );
1840 foreach ( QString subMenu, smenus ) {
1841 QStringList subMenuList = subMenu.split( ":" );
1842 QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1843 int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1844 menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1846 createMenu( id, menuId, -1 );
1848 if ( !stools.isEmpty() ) {
1849 QString subTool = stools[0];
1850 subTool = subTool.toUpper().prepend( "TOOL_" );
1851 int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1852 createTool(id, toolId);
1855 // add action id to map
1856 PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1857 myPluginActions[id] = anAction;
1866 QString wrap(const QString& text, const QString& tag)
1867 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
1870 //=======================================================================
1871 // function : GeometryGUI::activateModule()
1872 // purpose : Called when GEOM module is activated
1873 //=======================================================================
1874 bool GeometryGUI::activateModule( SUIT_Study* study )
1876 // Fill in: Help Panel
1877 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
1878 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_GEOM"));
1880 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MODEL"));
1883 items << wrap(tr("INFO_VERTICES"), "li")
1884 << wrap(tr("INFO_EDGES"), "li")
1885 << wrap(tr("INFO_WIRES"), "li")
1886 << wrap(tr("INFO_FACES"), "li")
1887 << wrap(tr("INFO_SHELLS"), "li")
1888 << wrap(tr("INFO_SOLIDS"), "li");
1889 lab = tr("INFO_BOTTOM_UP_CONSTRUCTION") + ":" + wrap(items.join(""), "ul");
1892 items << wrap(tr("INFO_BOX"), "li")
1893 << wrap(tr("INFO_CYLINDER"), "li")
1894 << wrap(tr("INFO_CONE"), "li")
1895 << wrap("...", "li");
1896 lab = lab + tr("INFO_PRIMITIVES") + ":" + wrap(items.join(""), "ul");
1899 lab = lab + tr("INFO_BOOLEANS") + "<br/>";
1900 lab = lab + tr("INFO_TRANSFORMATIONS");
1902 app->infoPanel()->addLabel(lab, gb);
1904 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MODEL"));
1905 items << wrap("BREP", "li")
1906 << wrap("STEP", "li")
1907 << wrap("IGES", "li")
1908 << wrap("STL", "li")
1909 << wrap("XAO", "li");
1910 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
1913 app->infoPanel()->addLabel(lab, gb);
1916 if ( CORBA::is_nil( myComponentGeom ) )
1919 bool res = SalomeApp_Module::activateModule( study );
1923 setMenuShown( true );
1924 setToolShown( true );
1926 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1927 PyGILState_STATE gstate = PyGILState_Ensure();
1928 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1929 if ( !pluginsmanager ) {
1933 auto addPluginsManager = [&](const char* managerName, const char* menuName, const char* submenuName) -> void
1935 PyObject* result = PyObject_CallMethod(
1936 pluginsmanager, (char*)"initialize", (char*)"isss", 1, managerName, menuName, submenuName);
1944 addPluginsManager("geom", tr("MEN_NEW_ENTITY").toUtf8().data(), tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1945 addPluginsManager("geomrepairadv", tr("MEN_REPAIR").toUtf8().data(), tr("MEN_ADVANCED").toUtf8().data());
1947 PyGILState_Release(gstate);
1948 // end of GEOM plugins loading
1950 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1951 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
1953 // Reset actions accelerator keys
1954 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1956 GUIMap::Iterator it;
1957 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1958 it.value()->activate( application()->desktop() );
1960 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1962 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ), Qt::UniqueConnection );
1963 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ), Qt::UniqueConnection );
1964 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ), Qt::UniqueConnection );
1966 if ( !myCreationInfoWdg )
1967 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1968 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1969 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1971 if ( !myTextTreeWdg ) {
1972 myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1973 new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1976 getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1977 getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1980 SALOME_ListIO selected;
1981 sm->selectedObjects( selected );
1982 sm->clearSelected();
1984 SUIT_ViewManager* vm;
1985 ViewManagerList OCCViewManagers, VTKViewManagers;
1987 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1988 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1989 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1990 onViewManagerAdded(vm);
1992 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1993 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1994 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1995 onViewManagerAdded(vm);
1997 sm->setSelectedObjects( selected, true ); //NPAL 19674
1999 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
2001 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ), Qt::UniqueConnection );
2003 // 0020836 (Basic vectors and origin)
2004 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2005 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
2006 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2008 _PTR(Study) studyDS = appStudy->studyDS();
2010 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2011 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
2012 createOriginAndBaseVectors();
2017 Py_XDECREF(pluginsmanager);
2022 //=======================================================================
2023 // function : GeometryGUI::deactivateModule()
2024 // purpose : Called when GEOM module is deactivated
2025 //=======================================================================
2026 bool GeometryGUI::deactivateModule( SUIT_Study* study )
2028 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
2030 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
2032 setMenuShown( false );
2033 setToolShown( false );
2035 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
2036 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
2038 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
2040 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
2041 //disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
2042 if ( myCreationInfoWdg ) {
2043 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
2044 myCreationInfoWdg = 0;
2046 if ( myTextTreeWdg ) {
2047 getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
2048 disconnect( application(), 0, myTextTreeWdg, 0 );
2052 EmitSignalCloseAllDialogs();
2054 GUIMap::Iterator it;
2055 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
2056 it.value()->deactivate();
2058 // Unset actions accelerator keys
2059 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
2061 qDeleteAll(myOCCSelectors);
2062 myOCCSelectors.clear();
2063 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
2065 qDeleteAll(myVTKSelectors);
2066 myVTKSelectors.clear();
2067 selMrg->setEnabled( true, SVTK_Viewer::Type() );
2069 return SalomeApp_Module::deactivateModule( study );
2072 //=======================================================================
2073 // function : onWindowActivated()
2074 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
2075 //=======================================================================
2076 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
2081 const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
2082 //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
2084 // disable non-OCC viewframe menu commands
2085 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
2086 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
2087 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
2088 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
2089 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
2090 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
2091 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2093 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2094 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2095 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2096 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2098 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2101 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2103 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2104 mappa.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea );
2105 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2106 #ifndef DISABLE_PYCONSOLE
2107 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2109 if ( myCreationInfoWdg )
2110 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2111 if ( myTextTreeWdg )
2112 mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2115 void GeometryGUI::viewManagers( QStringList& lst ) const
2117 lst.append( OCCViewer_Viewer::Type() );
2118 //lst.append( PV3DViewer_ViewModel::Type() );
2121 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2123 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2125 qDebug( "connect" );
2126 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
2127 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2128 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2129 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2130 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2131 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2132 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2133 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2135 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2136 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2138 // disable OCC selectors
2139 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2140 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2141 while ( itOCCSel.hasNext() )
2142 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2143 sr->setEnabled(true);
2145 else if ( vm->getType() == SVTK_Viewer::Type() )
2147 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2148 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2150 // disable VTK selectors
2151 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2152 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2153 while ( itVTKSel.hasNext() )
2154 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2155 sr->setEnabled(true);
2159 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2161 SUIT_ViewModel* viewer = vm->getViewModel();
2162 if ( vm->getType() == OCCViewer_Viewer::Type() )
2164 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2165 while ( itOCCSel.hasNext() )
2166 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2167 if ( sr->viewer() == viewer )
2169 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2173 if ( vm->getType() == SVTK_Viewer::Type() )
2175 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2176 while ( itVTKSel.hasNext() )
2177 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2178 if ( sr->viewer() == viewer )
2180 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2184 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2186 GetAnnotationMgr()->RemoveView( aSOCCView );
2190 //================================================================================
2192 * \brief Slot called when selection changed. Shows creation info of a selected object
2194 //================================================================================
2196 void GeometryGUI::updateCreationInfo()
2198 if ( myCreationInfoWdg )
2199 myCreationInfoWdg->clear();
2201 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2202 // if ( !myCreationInfoWdg->isVisible() )
2205 // look for a sole selected GEOM_Object
2206 GEOM::GEOM_BaseObject_var geomObj;
2208 SALOME_ListIO selected;
2209 getApp()->selectionMgr()->selectedObjects( selected );
2211 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2212 SALOME_ListIteratorOfListIO selIt( selected );
2213 for ( ; selIt.More(); selIt.Next() )
2215 Handle(SALOME_InteractiveObject) io = selIt.Value();
2216 if ( !io->hasEntry() ) continue;
2217 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2218 if ( !GeometryGUI::IsInGeomComponent( sobj )) continue;
2219 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2220 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2221 if ( !gobj->_is_nil() )
2223 if ( !geomObj->_is_nil() )
2224 return; // several GEOM objects selected
2228 if ( geomObj->_is_nil() ) return;
2230 // pass creation info of geomObj to myCreationInfoWdg
2232 if ( myCreationInfoWdg ) {
2234 GEOM::CreationInformationSeq_var info;
2237 info = geomObj->GetCreationInformation();
2241 myCreationInfoWdg->setInfo( info );
2245 void GeometryGUI::onAutoBringToFront()
2247 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2248 if( !isAutoBringToFront )
2251 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2252 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2255 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2256 if (!appStudy) return;
2258 GEOM_Displayer displayer;
2260 SALOME_View* window = displayer.GetActiveView();
2261 if ( !window ) return;
2263 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2265 SALOME_ListIO selected;
2266 getApp()->selectionMgr()->selectedObjects( selected );
2267 if (!myTopLevelIOList.IsEmpty())
2269 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2271 Handle( SALOME_InteractiveObject ) io = It.Value();
2272 bool isSelected = false;
2273 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2275 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2276 if( io->isSame( sel_io ) )
2279 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2281 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2282 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2287 myTopLevelIOList.Assign(selected);
2288 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2290 Handle( SALOME_InteractiveObject ) io = It.Value();
2291 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2292 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2295 displayer.UpdateViewer();
2296 GeometryGUI::Modified();
2299 void GeometryGUI::updateFieldColorScale()
2301 GEOM_Displayer aDisplayer;
2302 aDisplayer.UpdateColorScale();
2305 QString GeometryGUI::engineIOR() const
2307 if ( !CORBA::is_nil( GetGeomGen() ) )
2308 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2312 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2314 theWidth = theHeight = 0;
2315 Handle(TColStd_HArray1OfByte) aTexture;
2317 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2318 if ( !aInsOp->_is_nil() ) {
2319 CORBA::Long aWidth, aHeight;
2320 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2321 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2323 theHeight = aHeight;
2325 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2327 for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2328 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2334 LightApp_Selection* GeometryGUI::createSelection() const
2336 return new GEOMGUI_Selection();
2339 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2341 SalomeApp_Module::contextMenuPopup( client, menu, title );
2343 getApp()->selectionMgr()->selectedObjects( lst );
2345 // Update submenu for predefined materials
2346 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2347 QMenu* matMenu = action( GEOMOp::OpMaterialMenu )->menu();
2349 QSignalMapper* signalMapper = new QSignalMapper( menu );
2352 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2353 if ( anApp && anApp->activeViewManager() ) {
2354 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2356 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2359 QString curModel = "";
2360 if ( v.canConvert<QString>() ) curModel = v.toString();
2362 // get list of all predefined materials
2363 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2365 foreach ( QString material, materials )
2367 QAction* a = matMenu->addAction( material );
2368 connect( a, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2369 signalMapper->setMapping( a, material );
2370 a->setCheckable( true );
2372 Material_Model aModel;
2373 aModel.fromResources( material );
2374 if ( !found && aModel.toProperties() == curModel ) {
2375 a->setChecked( true );
2379 matMenu->addSeparator();
2380 matMenu->addAction( action( GEOMOp::OpPredefMaterCustom ) );
2381 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2382 this, SLOT( OnSetMaterial( const QString & ) ) );
2385 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2386 Handle(SALOME_InteractiveObject) io = lst.First();
2387 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2388 _PTR(Study) study = appStudy->studyDS();
2389 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2391 QString aName = QString( obj->GetName().c_str() );
2392 aName.remove( QRegExp("\\s+$") );
2398 void GeometryGUI::OnSetMaterial(const QString& theName)
2400 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2404 void GeometryGUI::createPreferences()
2406 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2408 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2410 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2411 setPreferenceProperty( genGroup, "columns", 2 );
2413 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2414 LightApp_Preferences::Selector,
2415 "Geometry", "display_mode" );
2417 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2418 LightApp_Preferences::Color, "Geometry", "shading_color" );
2420 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2421 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2423 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2424 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2426 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2427 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2429 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2430 LightApp_Preferences::Color, "Geometry", "line_color" );
2432 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2433 LightApp_Preferences::Color, "Geometry", "point_color" );
2435 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2436 LightApp_Preferences::Color, "Geometry", "isos_color" );
2438 addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2439 LightApp_Preferences::Color, "Geometry", "label_color" );
2441 addPreference( "", genGroup, LightApp_Preferences::Space );
2443 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2444 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2446 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2447 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2449 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2450 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2452 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2453 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2455 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2456 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2458 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2459 LightApp_Preferences::Selector,
2460 "Geometry", "material" );
2462 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2463 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2469 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2470 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2472 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2473 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2475 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2476 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2478 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2479 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2481 for (int i = 0; i < nb; i++) {
2482 setPreferenceProperty( wd[i], "min", 1 );
2483 setPreferenceProperty( wd[i], "max", 5 );
2486 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2487 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2489 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2490 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2492 // --------------------------------------------------------------------------
2493 // Dimensions (Measurements) preferences
2494 // --------------------------------------------------------------------------
2496 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2497 setPreferenceProperty( aDimGroupId, "columns", 2 );
2499 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2500 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2502 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2503 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2505 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2506 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2508 int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2510 int f = QtxFontEdit::Family | QtxFontEdit::Size;
2511 setPreferenceProperty( aDimFontId, "features", f );
2512 setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2514 Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2515 QString aFontFile = "";
2516 resMgr->value("resources", "GEOM", aFontFile);
2517 aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2518 // add enginier font into combobox
2519 /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2520 Handle(Font_SystemFont) sf = new Font_SystemFont( TCollection_AsciiString("Y14.5M-2009") );
2521 sf->SetFontPath( Font_FA_Regular,
2522 TCollection_AsciiString( aFontFile.toLatin1().data() ) );
2523 // register font in OCC font manager
2524 fmgr->RegisterFont( sf, Standard_False );
2526 // get list of supported fonts by OCC
2527 QStringList anOCCFonts;
2528 TColStd_SequenceOfHAsciiString theFontsNames;
2529 fmgr->GetAvailableFontsNames( theFontsNames );
2530 for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2531 Handle(TCollection_HAsciiString) str = theFontsNames(i);
2532 anOCCFonts << str->ToCString();
2534 anOCCFonts.removeDuplicates();
2535 // set the supported fonts into combobox to use its only
2536 setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2538 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2539 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2541 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2542 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2543 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2545 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2546 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2548 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2549 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2551 QStringList aListOfLengthUnits;
2552 aListOfLengthUnits << "m";
2553 aListOfLengthUnits << "cm";
2554 aListOfLengthUnits << "mm";
2555 aListOfLengthUnits << "in.";
2556 aListOfLengthUnits << "ft.";
2558 QStringList aListOfAngUnits;
2559 aListOfAngUnits << "rad";
2560 aListOfAngUnits << "deg";
2562 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2563 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2565 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2566 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2568 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2569 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2571 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2572 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2573 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2575 addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2576 LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2578 // --------------------------------------------------------------------------
2579 // Shape annotation preferences
2580 // --------------------------------------------------------------------------
2582 const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2583 setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2585 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2586 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2587 const int aShapeAnnFont =
2588 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2590 int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2591 setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2592 setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2593 setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2595 const int aShapeAnnLineWidth =
2596 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2598 setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2599 setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2601 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2603 const int aShapeAnnLineStyle =
2604 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2606 QStringList aLineStyleList;
2607 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2608 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2609 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2610 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2612 QList<QVariant> aLineStyleIds;
2613 aLineStyleIds.append(0);
2614 aLineStyleIds.append(1);
2615 aLineStyleIds.append(2);
2616 aLineStyleIds.append(3);
2618 setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2619 setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2621 // --------------------------------------------------------------------------
2622 // Isoline drawing preferences
2623 // --------------------------------------------------------------------------
2625 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2626 setPreferenceProperty( isoGroup, "columns", 2 );
2627 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2628 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2629 setPreferenceProperty( isoU, "min", 0 );
2630 setPreferenceProperty( isoU, "max", 100000 );
2631 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2632 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2633 setPreferenceProperty( isoV, "min", 0 );
2634 setPreferenceProperty( isoV, "max", 100000 );
2636 // Quantities with individual precision settings
2637 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2638 setPreferenceProperty( precGroup, "columns", 2 );
2640 const int nbQuantities = 8;
2641 int prec[nbQuantities], ii = 0;
2642 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2643 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2644 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2645 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2646 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2647 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2648 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2649 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2650 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2651 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2652 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2653 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2654 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2655 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2656 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2657 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2659 // Set property for precision value for spinboxes
2660 for ( ii = 0; ii < nbQuantities; ii++ ){
2661 setPreferenceProperty( prec[ii], "min", -14 );
2662 setPreferenceProperty( prec[ii], "max", 14 );
2663 setPreferenceProperty( prec[ii], "precision", 2 );
2666 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2667 setPreferenceProperty( VertexGroup, "columns", 2 );
2669 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2670 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2672 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2673 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2675 // Set property for default display mode
2676 QStringList aModesList;
2677 aModesList.append( tr("MEN_WIREFRAME") );
2678 aModesList.append( tr("MEN_SHADING") );
2679 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2680 aModesList.append( tr("MEN_TEXTURE") );
2682 QList<QVariant> anIndexesList;
2683 anIndexesList.append(0);
2684 anIndexesList.append(1);
2685 anIndexesList.append(2);
2686 anIndexesList.append(3);
2688 setPreferenceProperty( dispmode, "strings", aModesList );
2689 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2691 // Set property for top level display mode
2692 QStringList aTopModesList;
2693 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2694 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2695 aTopModesList.append( tr("MEN_WIREFRAME") );
2696 aTopModesList.append( tr("MEN_SHADING") );
2697 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2699 QList<QVariant> aTopIndexesList;
2700 aTopIndexesList.append(0);
2701 aTopIndexesList.append(1);
2702 aTopIndexesList.append(2);
2703 aTopIndexesList.append(3);
2704 aTopIndexesList.append(4);
2706 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2707 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2709 // Set property for step value for spinboxes
2710 setPreferenceProperty( step, "min", 1 );
2711 setPreferenceProperty( step, "max", 10000 );
2712 setPreferenceProperty( step, "precision", 3 );
2714 // Set property for trandparency value for spinboxes
2715 setPreferenceProperty( transparency, "min", 0 );
2716 setPreferenceProperty( transparency, "max", 100 );
2718 // Set property for deflection value for spinboxes
2719 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2720 setPreferenceProperty( defl, "max", 1.0 );
2721 setPreferenceProperty( defl, "step", 1.0e-04 );
2722 setPreferenceProperty( defl, "precision", 6 );
2724 // Set property for default material
2725 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2727 // Set property vertex marker type
2728 QList<QVariant> aMarkerTypeIndicesList;
2729 QList<QVariant> aMarkerTypeIconsList;
2731 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2732 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2733 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2734 aMarkerTypeIndicesList << (i-1);
2735 aMarkerTypeIconsList << pixmap;
2738 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2739 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2741 // Set property for vertex marker scale
2742 QList<QVariant> aMarkerScaleIndicesList;
2743 QStringList aMarkerScaleValuesList;
2745 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2746 aMarkerScaleIndicesList << iii;
2747 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2750 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2751 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2753 // Scalar bar for field step presentation
2754 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2755 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2757 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2758 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2759 setPreferenceProperty( sbXPosition, "min", 0 );
2760 setPreferenceProperty( sbXPosition, "max", 1 );
2761 setPreferenceProperty( sbXPosition, "step", 0.05 );
2763 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2764 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2765 setPreferenceProperty( sbYPosition, "min", 0 );
2766 setPreferenceProperty( sbYPosition, "max", 1 );
2767 setPreferenceProperty( sbYPosition, "step", 0.05 );
2769 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2770 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2771 setPreferenceProperty( sbWidth, "min", 0 );
2772 setPreferenceProperty( sbWidth, "max", 1 );
2773 setPreferenceProperty( sbWidth, "step", 0.05 );
2775 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2776 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2777 setPreferenceProperty( sbHeight, "min", 0 );
2778 setPreferenceProperty( sbHeight, "max", 1 );
2779 setPreferenceProperty( sbHeight, "step", 0.05 );
2781 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2782 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2783 setPreferenceProperty( sbTextHeight, "min", 6 );
2784 setPreferenceProperty( sbTextHeight, "max", 24 );
2785 setPreferenceProperty( sbTextHeight, "step", 1 );
2787 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2788 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2789 setPreferenceProperty( sbNbIntervals, "min", 2 );
2790 setPreferenceProperty( sbNbIntervals, "max", 64 );
2791 setPreferenceProperty( sbNbIntervals, "step", 1 );
2793 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2794 setPreferenceProperty( originGroup, "columns", 2 );
2796 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2797 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2798 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2799 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2801 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2802 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2804 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2805 setPreferenceProperty( operationsGroup, "columns", 2 );
2807 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2808 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2810 addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2811 LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2813 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2815 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2817 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2818 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2820 QStringList aHierarchyTypeList;
2821 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2822 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2823 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2825 QList<QVariant> aHierarchyTypeIndexesList;
2826 aHierarchyTypeIndexesList.append(0);
2827 aHierarchyTypeIndexesList.append(1);
2828 aHierarchyTypeIndexesList.append(2);
2830 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2831 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2833 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2834 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2836 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2838 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2839 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2841 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2842 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2843 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2844 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2845 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2846 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2847 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2848 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2850 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2851 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2852 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2853 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2854 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2855 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2862 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2864 if (section == "Geometry") {
2865 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2866 if (param == QString("SettingsGeomStep")) {
2867 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2868 EmitSignalDefaultStepValueChanged(spin_step);
2870 else if (param == QString("toplevel_color")) {
2871 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2872 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2874 else if (param == QString("toplevel_dm")) {
2875 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2877 else if (param == QString("scalar_bar_x_position") ||
2878 param == QString("scalar_bar_y_position") ||
2879 param == QString("scalar_bar_width") ||
2880 param == QString("scalar_bar_height") ||
2881 param == QString("scalar_bar_text_height") ||
2882 param == QString("scalar_bar_nb_intervals")) {
2883 updateFieldColorScale();
2885 else if ( param == QString("dimensions_color") ||
2886 param == QString("dimensions_line_width") ||
2887 param == QString("dimensions_font") ||
2888 param == QString("dimensions_arrow_length") ||
2889 param == QString("dimensions_show_units") ||
2890 param == QString("dimensions_length_units") ||
2891 param == QString("dimensions_angle_units") ||
2892 param == QString("dimensions_use_text3d") ||
2893 param == QString("shape_annotation_font_color") ||
2894 param == QString("shape_annotation_line_color") ||
2895 param == QString("shape_annotation_font") ||
2896 param == QString("shape_annotation_line_width") ||
2897 param == QString("shape_annotation_autohide") ||
2898 param == QString("shape_annotation_line_style") ||
2899 param == QString("shape_annotation_line_style") ||
2900 param == QString("label_color") )
2902 SalomeApp_Application* anApp = getApp();
2908 GEOM_Displayer aDisplayer;
2910 ViewManagerList aVMs;
2911 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2912 ViewManagerList::Iterator anIt = aVMs.begin();
2913 for ( ; anIt != aVMs.end(); ++anIt )
2915 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2921 SALOME_ListIO aVisible;
2922 aViewer->GetVisible( aVisible );
2924 GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2925 if ( anAnnotationMgr ) {
2926 SALOME_ListIteratorOfListIO anIter( aVisible );
2927 while ( anIter.More() ) {
2928 if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2929 aVisible.Remove( anIter );
2937 aDisplayer.Redisplay( aVisible, false, aViewer );
2939 if ( param == QString( "label_color" ) ) {
2940 ViewManagerList aVMsVTK;
2941 anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2942 ViewManagerList::Iterator anIt = aVMsVTK.begin();
2943 for ( ; anIt != aVMsVTK.end(); ++anIt )
2945 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2950 SALOME_ListIO aVisible;
2951 aViewer->GetVisible( aVisible );
2952 aDisplayer.Redisplay( aVisible, false, aViewer );
2955 aDisplayer.UpdateViewer();
2957 else if ( param.startsWith( "dependency_tree") )
2958 emit SignalDependencyTreeParamChanged( section, param );
2962 LightApp_Displayer* GeometryGUI::displayer()
2965 myDisplayer = new GEOM_Displayer();
2969 void GeometryGUI::setLocalSelectionMode(const int mode)
2971 myLocalSelectionMode = mode;
2974 int GeometryGUI::getLocalSelectionMode() const
2976 return myLocalSelectionMode;
2979 const char gSeparator = '_'; // character used to separate parameter names
2980 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2983 * \brief Store visual parameters
2985 * This method is called just before the study document is saved.
2986 * Store visual parameters in AttributeParameter attribute(s)
2988 void GeometryGUI::storeVisualParameters (int savePoint)
2990 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2991 if ( !appStudy || !appStudy->studyDS() )
2994 _PTR(Study) studyDS = appStudy->studyDS();
2996 // componentName is used for encoding of entries when storing them in IParameters
2997 std::string componentName = myComponentGeom->ComponentDataType();
2998 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2999 //if (!aSComponent) return;
3002 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3003 componentName.c_str(),
3005 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3007 QSet<QString> anEntriesToStoreShared;
3008 QList<SUIT_ViewManager*> lst;
3009 QList<SUIT_ViewManager*>::Iterator it;
3011 GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
3013 // main cycle to store parameters of displayed objects
3015 getApp()->viewManagers(lst);
3016 for (it = lst.begin(); it != lst.end(); it++) {
3017 SUIT_ViewManager* vman = *it;
3018 QString vType = vman->getType();
3019 SUIT_ViewModel* vmodel = vman->getViewModel();
3020 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3022 int aMgrId = vman->getGlobalId();
3023 // saving VTK actors properties
3024 QVector<SUIT_ViewWindow*> views = vman->getViews();
3025 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
3026 const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
3027 ObjMap::ConstIterator o_it = anObjects.begin();
3028 for (; o_it != anObjects.end(); o_it++) {
3029 const PropMap& aProps = o_it.value();
3031 //Check that object exists in the study
3032 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toUtf8().data() ) );
3033 if ( !obj || !(aProps.count() > 0))
3035 // entry is "encoded" = it does NOT contain component address, since it is a
3036 // subject to change on next component loading
3038 std::string entry = ip->encodeEntry(o_it.key().toUtf8().data(), componentName);
3040 _PTR(GenericAttribute) anAttr;
3041 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
3044 // remember entry of object to store shared GEOM properties
3045 // (e.g. dimension properties).
3046 if ( vType == OCCViewer_Viewer::Type() )
3048 anEntriesToStoreShared.insert( o_it.key() );
3051 QString param, occParam = vType;
3052 occParam += GEOM::sectionSeparator();
3053 occParam += QString::number(aMgrId);
3054 occParam += GEOM::sectionSeparator();
3056 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
3057 param = occParam + GEOM::propertyName( GEOM::Visibility );
3058 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
3061 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
3062 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
3063 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
3066 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
3067 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
3069 val << QString::number(c.redF());
3070 val << QString::number(c.greenF());
3071 val << QString::number(c.blueF());
3072 param = occParam + GEOM::propertyName( GEOM::Color );
3073 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
3076 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
3077 param = occParam + GEOM::propertyName( GEOM::Texture );
3078 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
3081 if (vType == SVTK_Viewer::Type()) {
3082 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
3083 param = occParam + GEOM::propertyName( GEOM::Opacity );
3084 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
3086 } else if (vType == SOCC_Viewer::Type()) {
3087 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3088 param = occParam + GEOM::propertyName( GEOM::Transparency );
3089 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3092 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3093 param = occParam + GEOM::propertyName( GEOM::TopLevel );
3094 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3098 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3099 param = occParam + GEOM::propertyName( GEOM::NbIsos );
3100 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3103 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3104 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3105 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3108 if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3109 param = occParam + GEOM::propertyName( GEOM::Vertices );
3110 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3113 if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3114 param = occParam + GEOM::propertyName( GEOM::ShowName );
3115 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3118 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3119 param = occParam + GEOM::propertyName( GEOM::Deflection );
3120 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3123 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3124 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3125 param = occParam + GEOM::propertyName( GEOM::PointMarker );
3126 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3129 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3130 param = occParam + GEOM::propertyName( GEOM::Material );
3131 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3134 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3135 param = occParam + GEOM::propertyName( GEOM::LineWidth );
3136 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3139 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3140 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3141 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3144 if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3145 std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3146 o_it.key().toUtf8().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3147 if (!anAnnotationInfo.empty()) {
3148 param = occParam + "ShapeAnnotationVisibleItems";
3149 ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3152 } // object iterator
3154 } // for (viewManagers)
3156 // store shape annotation and dimension attributes of objects:
3157 // since the displayed object always persists in property map, we remember the object entries
3158 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3159 const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3160 const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3161 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3162 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3164 std::string aStudyEntry = (*aEntryIt).toUtf8().data();
3165 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3167 // store dimension parameters
3168 GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3169 if ( aDimensions.GetNumber() != 0 ) {
3170 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toUtf8().data() );
3173 _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3174 const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3175 if ( !aShapeAnnAttr.IsNull() ) {
3176 ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toUtf8().data() );
3182 * \brief Restore visual parameters
3184 * This method is called after the study document is opened.
3185 * Restore visual parameters from AttributeParameter attribute(s)
3187 void GeometryGUI::restoreVisualParameters (int savePoint)
3189 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3190 if (!appStudy || !appStudy->studyDS())
3192 _PTR(Study) studyDS = appStudy->studyDS();
3194 // componentName is used for encoding of entries when storing them in IParameters
3195 std::string componentName = myComponentGeom->ComponentDataType();
3196 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3197 //if (!aSComponent) return;
3200 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3201 componentName.c_str(),
3203 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3205 std::vector<std::string> entries = ip->getEntries();
3207 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3209 // entry is a normal entry - it should be "decoded" (setting base address of component)
3210 QString entry (ip->decodeEntry(*entIt).c_str());
3212 // Check that the entry corresponds to a real object in the Study
3213 // as the object may be deleted or modified after the visual state is saved.
3214 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
3215 if (!so) continue; //Skip the not existent entry
3217 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3218 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3220 std::vector<std::string>::iterator namesIt = paramNames.begin();
3221 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3223 // actors are stored in a map after displaying of them for
3224 // quicker access in the future: map < viewID to actor >
3225 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
3226 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3228 QString viewerTypStr;
3229 QString viewIndexStr;
3231 QVector<PropMap> aListOfMap;
3233 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3235 // visual parameters are stored in strings as follows:
3236 // 1) ViewerType_ViewIndex_ParamName
3237 // 2) ViewerType_ParamName (shared for GEOM module)
3238 // '_' is used as separator and should not be used in viewer type or parameter names.
3239 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3241 bool isShared = lst.size() == 2;
3242 bool isViewer = lst.size() == 3;
3243 if ( !isShared && !isViewer )
3248 // shared visual parameters
3251 QString aParamNameStr( lst[1] );
3252 QString aValuesStr( (*valuesIt).c_str() );
3254 // shared dimension properties are stored as attribute
3255 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3257 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3258 aDimensionProp.SaveToAttribute( entry.toUtf8().data() );
3260 else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3262 Handle(GEOMGUI_AnnotationAttrs) anAttr =
3263 GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3265 anAttr->ImportFromPropertyString( aValuesStr );
3271 // per view visual parameters
3272 viewerTypStr = lst[0];
3273 viewIndexStr = lst[1];
3274 QString paramNameStr = lst[2];
3277 viewIndex = viewIndexStr.toUInt(&ok);
3278 if (!ok) // bad conversion of view index to integer
3281 if ((viewIndex + 1) > aListOfMap.count()) {
3282 aListOfMap.resize(viewIndex + 1);
3285 QString val((*valuesIt).c_str());
3286 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3287 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3288 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3289 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3290 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3291 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3292 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3293 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3294 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3295 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3296 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3297 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3298 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3299 QStringList rgb = val.split(GEOM::subSectionSeparator());
3300 if (rgb.count() == 3) {
3301 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3302 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3304 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3305 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3306 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3307 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3308 } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3309 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3310 } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3311 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3312 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3313 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3314 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3315 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3316 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3317 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3318 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3319 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3320 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3321 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3322 } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3323 aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3326 } // for names/parameters iterator
3328 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3330 for (int index = 0; index < aListOfMap.count(); index++) {
3331 appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3333 //Get Visibility property of the current PropMap
3334 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3335 SUIT_ViewManager* vman = lst.at(index);
3336 SUIT_ViewModel* vmodel = vman->getViewModel();
3337 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3338 displayer()->Display(entry, true, aView);
3340 if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3341 PropMap& aProps = aListOfMap[index];
3342 if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3343 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3344 GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3349 } // for entries iterator
3351 // update all VTK and OCC views
3352 QList<SUIT_ViewManager*> lst;
3353 getApp()->viewManagers(lst);
3354 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3355 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3358 if (vmodel->getType() == SVTK_Viewer::Type()) {
3359 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3360 vtkView->getRenderer()->ResetCameraClippingRange();
3363 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3364 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3365 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3371 if ( myTextTreeWdg ) {
3372 myTextTreeWdg->updateTree();
3376 // Compute current name mode of the viewer
3377 void UpdateNameMode( SalomeApp_Application* app )
3379 bool isMode = false;
3380 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3381 SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3382 GEOM_Displayer displayer;
3383 int aMgrId = viewWindow->getViewManager()->getGlobalId();
3385 SALOME_View* window = displayer.GetActiveView();
3386 if ( !window ) return;
3388 SALOME_ListIO anIOlst;
3389 window->GetVisible( anIOlst );
3391 for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3392 Handle( SALOME_InteractiveObject ) io = It.Value();
3393 QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3394 bool isIONameMode = v.isValid() ? v.toBool() : false;
3398 viewWindow->setProperty( "NameMode", isMode );
3401 void GeometryGUI::onViewAboutToShow()
3403 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3404 QAction* a = action( GEOMOp::OpSwitchVectors );
3405 QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3406 QAction* aNameAction = action( GEOMOp::OpSwitchName );
3408 a->setEnabled(true);
3409 bool vmode = window->property("VectorsMode").toBool();
3410 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3411 aVerticesAction->setEnabled(true);
3412 vmode = window->property("VerticesMode").toBool();
3413 aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3414 UpdateNameMode( getApp() );
3415 aNameAction->setEnabled(true);
3416 vmode = window->property("NameMode").toBool();
3417 aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3419 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3420 a->setEnabled(false);
3421 aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3422 aVerticesAction->setEnabled(false);
3423 aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3424 aNameAction->setEnabled(false);
3429 \brief Return action by id
3430 \param id identifier of the action
3433 QAction* GeometryGUI::getAction(const int id) {
3438 \brief GEOM module message handler
3440 This method can be re-implemented in the subclasses.
3441 This is a GEOM module message handler.
3443 \param msg the message received.
3445 void GeometryGUI::message(const QString& msg)
3448 QStringList data = msg.split("/");
3449 const int nbStrings = data.count();
3451 if (nbStrings > 0) {
3452 if (data[0] == "modified") {
3454 QString anIOR = nbStrings > 1 ? data[1] : QString();
3456 if ( anIOR.isEmpty() ) {
3460 // Get the geom object.
3461 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3463 // Clear the shape buffer
3464 GeometryGUI::ClearShapeBuffer (anObj);
3470 \brief Clears the shape buffer.
3472 This is a static method. It clears the shape buffer.
3474 \param theObj the object
3476 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3478 if ( CORBA::is_nil( theObj ) )
3481 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3482 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3483 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3485 SalomeApp_Application* app =
3486 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3487 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3492 _PTR(Study) aStudy = appStudy->studyDS();
3497 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3501 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3502 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3503 _PTR(GenericAttribute) anAttr;
3504 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3505 _PTR(AttributeIOR) anIOR ( anAttr );
3506 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3507 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3513 \brief Returns the object from IOR.
3515 This is a static method. It returns the object from its IOR.
3517 \param IOR object IOR
3518 \return GEOM object.
3520 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3522 GEOM::GEOM_Object_var geomObj;
3523 if ( !IOR.isEmpty() ) {
3524 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3525 ( IOR.toLatin1().constData() );
3526 if ( !CORBA::is_nil( corbaObj ) )
3527 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3529 return geomObj._retn();
3533 \brief Returns IOR of the object.
3535 This is a static method. It returns the object's IOR.
3537 \param object the GEOM object.
3538 \return object's IOR.
3540 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3543 if ( !CORBA::is_nil( object ) ) {
3544 CORBA::String_var anIOR =
3545 SalomeApp_Application::orb()->object_to_string( object );
3552 \brief Check if this object is can't be renamed in place
3554 This method can be re-implemented in the subclasses.
3555 Return true in case if object isn't reference or component (module root).
3557 \param entry column id
3558 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3560 bool GeometryGUI::renameAllowed( const QString& entry) const {
3562 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3563 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3564 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3566 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3570 Rename object by entry.
3571 \param entry entry of the object
3572 \param name new name of the object
3573 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3575 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3577 bool result = false;
3579 SalomeApp_Application* app =
3580 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3581 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3586 _PTR(Study) aStudy = appStudy->studyDS();
3591 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3593 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3597 _PTR(SObject) obj ( aStudy->FindObjectID(qUtf8Printable(entry)) );
3598 _PTR(GenericAttribute) anAttr;
3600 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3601 _PTR(AttributeName) aName (anAttr);
3603 aName->SetValue( name.toUtf8().data() ); // rename the SObject
3604 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3605 if (!CORBA::is_nil(anObj)) {
3606 anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
3607 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3608 emit SignalTextTreeRenameObject( entry );
3616 void GeometryGUI::updateMaterials()
3618 LightApp_Preferences* pref = preferences();
3620 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3621 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3622 if ( !materials.contains( currentMaterial ) )
3623 // user material set as default in the preferences, might be removed
3624 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3626 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3628 setPreferenceProperty( prefItem->id(),
3629 "strings", materials );
3630 prefItem->retrieve();
3636 \brief Check if the module allows "drag" operation of its objects.
3638 Overloaded from LightApp_Module class.
3640 This function is a part of the general drag-n-drop mechanism.
3641 The goal of this function is to check data object passed as a parameter
3642 and decide if it can be dragged or no.
3644 \param what data object being tested for drag operation
3645 \return \c true if module allows dragging of the specified object
3646 \sa isDropAccepted(), dropObjects()
3648 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3650 // we allow dragging object under root and object from folder
3651 int aLevel = what->level();
3652 bool anObjectInFolder = false;
3654 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3656 _PTR(SObject) aSO = dataObj->object();
3658 _PTR(GenericAttribute) anAttr;
3659 _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3660 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3661 _PTR(AttributeLocalID) aLocalID( anAttr );
3662 anObjectInFolder = aLocalID->Value() == 999;
3667 return aLevel == 2 || anObjectInFolder;
3671 \brief Check if the module allows "drop" operation on the given object.
3673 Overloaded from LightApp_Module class.
3675 This function is a part of the general drag-n-drop mechanism.
3676 The goal of this function is to check data object passed as a parameter
3677 and decide if it can be used as a target for the "drop" operation.
3678 The processing of the drop operation itself is done in the dropObjects() function.
3680 \param where target data object
3681 \return \c true if module supports dropping on the \a where data object
3682 \sa isDraggable(), dropObjects()
3684 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3686 // we allow dropping into folder and top-level GEOM object
3687 int aLevel = where->level();
3688 bool isFolder = false;
3690 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3692 _PTR(SObject) aSO = dataObj->object();
3694 _PTR(GenericAttribute) anAttr;
3695 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3696 _PTR(AttributeLocalID) aLocalID( anAttr );
3697 isFolder = aLocalID->Value() == 999;
3702 return aLevel == 1 || isFolder;
3706 \brief Complete drag-n-drop operation.
3708 Overloaded from LightApp_Module class.
3710 This function is a part of the general drag-n-drop mechanism.
3711 Its goal is to handle dropping of the objects being dragged according
3712 to the chosen operation (move). The dropping is performed in the
3713 context of the parent data object \a where and the \a row (position in the
3714 children index) at which the data should be dropped. If \a row is equal to -1,
3715 this means that objects are added to the end of the children list.
3717 \param what objects being dropped
3718 \param where target data object
3719 \param row child index at which the drop operation is performed
3720 \param action drag-n-drop operation (Qt::DropAction) - move
3722 \sa isDraggable(), isDropAccepted()
3724 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3725 const int row, Qt::DropAction action )
3727 if (action != Qt::CopyAction && action != Qt::MoveAction)
3728 return; // unsupported action
3730 // get parent object
3731 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3732 if ( !dataObj ) return; // wrong parent
3733 _PTR(SObject) parentObj = dataObj->object();
3735 // Find the current Study and StudyBuilder
3736 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3737 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3738 // collect all parents of the target node
3739 QStringList parentIDs;
3740 _PTR(SObject) parent = parentObj;
3741 while( !parent->IsNull() ) {
3742 parentIDs << parent->GetID().c_str();
3743 parent = aUseCaseBuilder->GetFather(parent);
3746 // collect objects being dropped
3747 GEOM::object_list_var objects = new GEOM::object_list();
3748 objects->length( what.count() );
3750 for ( int i = 0; i < what.count(); i++ ) {
3751 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3752 if ( !dataObj ) continue; // skip wrong objects
3753 _PTR(SObject) sobj = dataObj->object();
3754 // check that dropped object is not a parent of target object
3755 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3756 return; // it's not allowed to move node into it's child
3758 objects[i] = _CAST(SObject, sobj)->GetSObject();
3761 objects->length( count );
3763 // call engine function
3764 GetGeomGen()->Move( objects.in(), // what
3765 _CAST(SObject, parentObj)->GetSObject(), // where
3768 // update Object browser
3769 getApp()->updateObjectBrowser( false );
3772 void GeometryGUI::emitDimensionsUpdated( QString entry )
3774 emit DimensionsUpdated( entry );
3777 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3779 emit SignalAnnotationsUpdated( entry );