1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GeometryGUI.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
30 #include "GeometryGUI.h"
31 #include "GeometryGUI_Operations.h"
32 #include "GEOMPluginGUI.h"
33 #include "GEOMGUI_OCCSelector.h"
34 #include "GEOMGUI_Selection.h"
35 #include "GEOMGUI_CreationInfoWdg.h"
36 #include "GEOMGUI_TextTreeWdg.h"
37 #include "GEOMGUI_DimensionProperty.h"
38 #include "GEOM_Constants.h"
39 #include "GEOM_Displayer.h"
40 #include "GEOM_AISShape.hxx"
41 #include "GEOMUtils_XmlHandler.hxx"
42 #include "GEOMGUI_AnnotationMgr.h"
43 #include "GEOMGUI_TextTreeSelector.h"
45 #include "GEOM_Actor.h"
47 #include <Material_ResourceMgr.h>
48 #include <Material_Model.h>
50 #include <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 <SOCC_ViewModel.h>
64 #include <SOCC_ViewWindow.h>
66 #include <SVTK_ViewWindow.h>
67 #include <SVTK_RenderWindowInteractor.h>
68 #include <SVTK_InteractorStyle.h>
69 #include <SVTK_ViewModel.h>
71 #ifndef DISABLE_GRAPHICSVIEW
72 #include <GraphicsView_Viewer.h>
75 #include <SalomeApp_Application.h>
76 #include <SalomeApp_DataObject.h>
77 #include <SalomeApp_Study.h>
78 #include <SalomeApp_Tools.h>
80 #include <LightApp_SelectionMgr.h>
81 #include <LightApp_VTKSelector.h>
82 #include <LightApp_DataObject.h>
83 #include <LightApp_Preferences.h>
85 #include <SALOME_LifeCycleCORBA.hxx>
86 #include <SALOME_ListIO.hxx>
88 #include <SALOMEDSClient_ClientFactory.hxx>
89 #include <SALOMEDSClient_IParameters.hxx>
91 #include <SALOMEDS_SObject.hxx>
93 #include <QtxFontEdit.h>
94 #include <QtxInfoPanel.h>
105 #include <QSignalMapper>
106 #include <QFontDatabase>
108 #include <AIS_ListOfInteractive.hxx>
109 #include <AIS_ListIteratorOfListOfInteractive.hxx>
110 #include <Prs3d_Drawer.hxx>
111 #include <Prs3d_IsoAspect.hxx>
112 #include <Aspect_TypeOfMarker.hxx>
113 #include <OSD_SharedLibrary.hxx>
114 #include <NCollection_DataMap.hxx>
116 #include <TColStd_HArray1OfByte.hxx>
117 #include <TColStd_SequenceOfHAsciiString.hxx>
119 #include <utilities.h>
121 #include <vtkCamera.h>
122 #include <vtkRenderer.h>
124 #include <Standard_Failure.hxx>
125 #include <Standard_ErrorHandler.hxx>
127 #include <Font_SystemFont.hxx>
128 #include <Font_FontMgr.hxx>
129 #include <TCollection_HAsciiString.hxx>
131 #include "GEOM_version.h"
132 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
135 Standard_EXPORT CAM_Module* createModule() {
136 return new GeometryGUI();
139 Standard_EXPORT char* getModuleVersion() {
140 return (char*)GEOM_VERSION_STR;
144 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
146 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
148 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
149 if (CORBA::is_nil(myComponentGeom))
151 return GeometryGUI::myComponentGeom;
154 bool GeometryGUI::InitGeomGen()
157 if ( CORBA::is_nil( myComponentGeom ) ) return false;
161 //=======================================================================
162 // function : ClientSObjectToObject
164 //=======================================================================
165 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
167 _PTR(GenericAttribute) anAttr;
168 CORBA::Object_var anObj;
170 std::string aValue = theSObject->GetIOR();
171 if (strcmp(aValue.c_str(), "") != 0) {
172 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
173 anObj = anORB->string_to_object(aValue.c_str());
176 INFOS("ClientSObjectToObject - Unknown exception has occurred!!!");
178 return anObj._retn();
180 //=================================================================================
181 // function : IsInGeomComponent
182 // purpose : Check if an SObject is under GEOM component
183 //=================================================================================
184 bool GeometryGUI::IsInGeomComponent( _PTR(SObject) sobject )
187 if ( _PTR(SComponent) aComp = sobject->GetFatherComponent() )
188 return aComp->ComponentDataType() == "GEOM";
192 //=======================================================================
193 // function : GetStudy
195 //=======================================================================
196 SALOMEDS::Study_var GeometryGUI::getStudyServant()
198 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
199 CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
200 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
201 return aStudy._retn();
204 void GeometryGUI::Modified (bool theIsUpdateActions)
206 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
207 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
208 appStudy->Modified();
209 if ( theIsUpdateActions )
210 app->updateActions();
215 //=======================================================================
216 // function : GeometryGUI::GeometryGUI()
217 // purpose : Constructor
218 //=======================================================================
219 GeometryGUI::GeometryGUI() :
220 SalomeApp_Module( "GEOM" ),
223 if ( CORBA::is_nil( myComponentGeom ) )
225 Engines::EngineComponent_var comp =
226 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
227 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
230 myActiveDialogBox = 0;
232 gp_Pnt origin = gp_Pnt(0., 0., 0.);
233 gp_Dir direction = gp_Dir(0., 0., 1.);
234 myWorkingPlane = gp_Ax3(origin, direction);
237 myLocalSelectionMode = GEOM_ALLOBJECTS;
239 myCreationInfoWdg = 0;
243 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ), Qt::UniqueConnection );
245 Q_INIT_RESOURCE( GEOMGUI );
248 //=======================================================================
249 // function : GeometryGUI::~GeometryGUI()
250 // purpose : Destructor
251 //=======================================================================
252 GeometryGUI::~GeometryGUI()
254 while (!myOCCSelectors.isEmpty())
255 delete myOCCSelectors.takeFirst();
257 while (!myVTKSelectors.isEmpty())
258 delete myVTKSelectors.takeFirst();
260 qDeleteAll(myGUIMap);
263 //=======================================================================
264 // function : GeometryGUI::getLibrary()
265 // purpose : get or load GUI library by name [ internal ]
266 //=======================================================================
267 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
268 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
270 if ( !myGUIMap.contains( libraryName ) ) {
271 // try to load library if it is not loaded yet
273 QString dirs = Qtx::getenv( "PATH" );
274 #elif defined(__APPLE__)
275 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
277 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
285 if ( !dirs.isEmpty() ) {
286 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
287 QListIterator<QString> it( dirList ); it.toBack();
288 while ( it.hasPrevious() ) {
289 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
291 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
292 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
294 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
295 continue; // continue search further
297 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
298 if ( osdF != NULL ) {
299 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
300 GEOMGUI* libGUI = (*func)( this );
302 myGUIMap[ libraryName ] = libGUI;
303 break; // found and loaded!
310 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
313 //=======================================================================
314 // function : GeometryGUI::getPluginLibrary()
315 // purpose : get or load GUI Plugin library by name [ internal ]
316 //=======================================================================
317 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
318 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
320 if ( !myGUIMap.contains( libraryName ) ) {
321 // try to load library if it is not loaded yet
324 QString dirs = Qtx::getenv( "PATH" );
325 #elif defined(__APPLE__)
326 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
328 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
336 if ( !dirs.isEmpty() ) {
337 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
338 QListIterator<QString> it( dirList ); it.toBack();
339 while ( it.hasPrevious() ) {
340 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
342 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
343 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
345 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
346 continue; // continue search further
348 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
349 if ( osdF != NULL ) {
350 PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
351 GEOMPluginGUI* libGUI = (*func)( this );
353 myGUIMap[ libraryName ] = libGUI;
354 break; // found and loaded!
361 return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
364 //=======================================================================
365 // function : GeometryGUI::ActiveWorkingPlane()
366 // purpose : Activate Working Plane View
367 //=======================================================================
368 void GeometryGUI::ActiveWorkingPlane()
370 gp_Dir DZ = myWorkingPlane.Direction();
371 gp_Dir DY = myWorkingPlane.YDirection();
373 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
374 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
375 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
378 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
380 Handle(V3d_View) view3d = vw->getViewPort()->getView();
382 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
383 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
387 else if ( ViewVTK ) {
388 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
390 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
392 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
393 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
394 camera->SetFocalPoint(0,0,0);
401 //=======================================================================
402 // function : GeometryGUI::SetActiveDialogBox()
403 // purpose : Set active dialog box
404 //=======================================================================
405 GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
407 if ( !myAnnotationMgr )
408 myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
409 return myAnnotationMgr;
412 //=======================================================================
413 // function : GeometryGUI::SetActiveDialogBox()
414 // purpose : Set active dialog box
415 //=======================================================================
416 GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
418 return myTextTreeWdg;
421 //=======================================================================
422 // function : GeometryGUI::SetActiveDialogBox()
423 // purpose : Set active dialog box
424 //=======================================================================
425 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
427 myActiveDialogBox = (QDialog*)aDlg;
430 //=======================================================================
431 // function : GeometryGUI::EmitSignalDeactivateDialog()
432 // purpose : Emit a signal to deactivate the active dialog Box
433 //=======================================================================
434 void GeometryGUI::EmitSignalDeactivateDialog()
436 emit SignalDeactivateActiveDialog();
439 //=======================================================================
440 // function : GeometryGUI::EmitSignalCloseAllDialogs()
441 // purpose : Emit a signal to close all non modal dialogs box
442 //=======================================================================
443 void GeometryGUI::EmitSignalCloseAllDialogs()
445 emit SignalCloseAllDialogs();
448 //=======================================================================
449 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
450 // purpose : Emit a signal to inform that default real spin box step has
452 //=======================================================================
453 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
455 emit SignalDefaultStepValueChanged(newVal);
458 //=======================================================================
459 // function : GeometryGUI::OnGUIEvent()
460 // purpose : common slot for all menu/toolbar actions
461 //=======================================================================
462 void GeometryGUI::OnGUIEvent()
464 const QObject* obj = sender();
465 if ( !obj || !obj->inherits( "QAction" ) )
467 int id = actionId((QAction*)obj);
472 //=======================================================================
473 // function : GeometryGUI::OnGUIEvent()
474 // purpose : manage all events on GUI [static]
475 //=======================================================================
476 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
478 SUIT_Application* anApp = application();
480 SUIT_Desktop* desk = anApp->desktop();
482 // check type of the active viewframe
483 SUIT_ViewWindow* window = desk->activeWindow();
484 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
485 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
486 #ifndef DISABLE_GRAPHICSVIEW
487 bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
491 // if current viewframe is not of OCC and not of VTK type - return immediately
492 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
493 QList<int> NotViewerDependentCommands;
494 NotViewerDependentCommands << GEOMOp::OpDelete
496 << GEOMOp::OpShowOnly
497 << GEOMOp::OpShowOnlyChildren
498 << GEOMOp::OpDiscloseChildren
499 << GEOMOp::OpConcealChildren
500 << GEOMOp::OpUnpublishObject
501 << GEOMOp::OpPublishObject
502 << GEOMOp::OpPointMarker
503 << GEOMOp::OpCreateFolder
504 << GEOMOp::OpSortChildren;
505 if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
506 // activate OCC viewer
507 getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
510 // fix for IPAL9103, point 2
511 if ( CORBA::is_nil( GetGeomGen() ) ) {
512 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
517 // find corresponding GUI library
519 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
520 createOriginAndBaseVectors(); // internal operation
522 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
523 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
524 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
525 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
526 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
527 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
528 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
529 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
530 case GEOMOp::OpDelete: // MENU EDIT - DELETE
531 #ifndef DISABLE_PYCONSOLE
532 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
534 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
535 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
536 case GEOMOp::OpColor: // POPUP MENU - COLOR
537 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
538 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
539 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
540 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
541 case GEOMOp::OpIsos: // POPUP MENU - ISOS
542 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
543 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
544 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
545 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
546 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
547 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
548 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
549 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
550 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
551 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
552 case GEOMOp::OpMaterialMenu: // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
553 case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
554 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
555 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
556 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
557 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
558 case GEOMOp::OpClsBringToFront: //
559 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
560 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
561 #ifndef DISABLE_GRAPHICSVIEW
562 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
564 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
565 libName = "GEOMToolsGUI";
567 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
568 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
569 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
570 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
571 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
572 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
573 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
574 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
575 case GEOMOp::OpHide: // MENU VIEW - ERASE
576 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
577 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
578 case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
579 case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
580 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
581 case GEOMOp::OpShading: // POPUP MENU - SHADING
582 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
583 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
584 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
585 case GEOMOp::OpVertices: // POPUP MENU - VERTICES
586 case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
587 libName = "DisplayGUI";
589 case GEOMOp::OpPoint: // MENU BASIC - POINT
590 case GEOMOp::OpLine: // MENU BASIC - LINE
591 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
592 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
593 case GEOMOp::OpArc: // MENU BASIC - ARC
594 case GEOMOp::OpVector: // MENU BASIC - VECTOR
595 case GEOMOp::OpPlane: // MENU BASIC - PLANE
596 case GEOMOp::OpCurve: // MENU BASIC - CURVE
597 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
598 libName = "BasicGUI";
600 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
601 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
602 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
603 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
604 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
605 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
606 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
607 libName = "PrimitiveGUI";
609 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
610 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
611 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
612 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
613 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
614 case GEOMOp::OpThickness: // MENU GENERATION - THICKNESS
615 libName = "GenerationGUI";
617 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
618 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
619 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
620 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
621 case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
623 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
625 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
626 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
627 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
628 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
629 case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
630 libName = "EntityGUI";
632 case GEOMOp::OpEdge: // MENU BUILD - EDGE
633 case GEOMOp::OpWire: // MENU BUILD - WIRE
634 case GEOMOp::OpFace: // MENU BUILD - FACE
635 case GEOMOp::OpShell: // MENU BUILD - SHELL
636 case GEOMOp::OpSolid: // MENU BUILD - SOLID
637 case GEOMOp::OpCompound: // MENU BUILD - COMPOUND
638 libName = "BuildGUI";
640 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
641 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
642 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
643 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
644 libName = "BooleanGUI";
646 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
647 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
648 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
649 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
650 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
651 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
652 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
653 case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
654 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
655 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
656 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
657 case GEOMOp::OpExtension: // MENU TRANSFORMATION - EXTENSION
658 libName = "TransformationGUI";
660 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
661 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
662 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
663 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
664 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
665 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
666 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
667 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
668 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
669 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
670 case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
671 case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
672 libName = "OperationGUI";
674 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
675 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
676 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
677 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
678 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
679 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
680 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
681 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
682 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
683 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
684 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
685 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
686 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
687 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
688 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
689 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
690 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
691 case GEOMOp::OpInspectObj: // MENU REPAIR - INSPECT OBJECT
692 libName = "RepairGUI";
694 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
695 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
696 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
697 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
698 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
699 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
700 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
701 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
702 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
703 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
704 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
705 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
706 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
707 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
708 case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
709 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
710 case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
711 case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
712 case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
713 #ifndef DISABLE_PLOT2DVIEWER
714 case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
716 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
717 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
718 case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
719 case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
720 libName = "MeasureGUI";
722 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
723 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
724 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
725 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
726 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
727 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
728 libName = "GroupGUI";
730 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
731 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
732 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
733 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
734 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
735 libName = "BlocksGUI";
737 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
738 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
739 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
740 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
741 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
742 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
743 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
744 //libName = "AdvancedGUI";
747 if (myPluginActions.contains(id)) {
748 libName = myPluginActions[id].first;
750 GEOMPluginGUI* library = 0;
751 if ( !libName.isEmpty() ) {
753 libName = libName + ".dll";
754 #elif defined(__APPLE__)
755 libName = QString( "lib" ) + libName + ".dylib";
757 libName = QString( "lib" ) + libName + ".so";
759 library = getPluginLibrary( libName );
762 // call method of corresponding GUI library
764 //QString action ("%1");
765 //action = action.arg(id);
767 //if( !theParam.isValid() )
768 library->OnGUIEvent( myPluginActions[id].second, desk );
770 // library->OnGUIEvent( id, desk, theParam);
773 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
775 updateCreationInfo();
781 GEOMGUI* library = 0;
782 if ( !libName.isEmpty() ) {
784 libName = libName + ".dll";
785 #elif defined(__APPLE__)
786 libName = QString( "lib" ) + libName + ".dylib";
788 libName = QString( "lib" ) + libName + ".so";
790 library = getLibrary( libName );
793 // call method of corresponding GUI library
795 if( !theParam.isValid() )
796 library->OnGUIEvent( id, desk );
798 library->OnGUIEvent( id, desk, theParam);
801 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
803 updateCreationInfo();
806 //=================================================================================
807 // function : GeometryGUI::activateOperation()
809 //=================================================================================
810 bool GeometryGUI::activateOperation( int actionId )
812 OnGUIEvent(actionId);
816 //=================================================================================
817 // function : GeometryGUI::activateOperation()
819 //=================================================================================
820 bool GeometryGUI::activateOperation( const QString& actionId )
824 int id = actionId.toInt(&isOk);
831 //=================================================================================
832 // function : GeometryGUI::activateOperation()
834 //=================================================================================
835 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
839 QString pluginLib = plugin;
840 // TODO: if <plugin> is a plugin name, find plugin library name
841 if (myPluginLibs.contains(plugin))
842 pluginLib = myPluginLibs[plugin];
844 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
845 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
846 const PluginAction& anAction = actionsIter.value();
847 if (anAction.first == pluginLib && anAction.second == actionId) {
848 // activate operation
849 OnGUIEvent(actionsIter.key());
857 //=================================================================================
858 // function : GeometryGUI::OnKeyPress()
859 // purpose : Called when any key is pressed by user [static]
860 //=================================================================================
861 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
863 if ( !application() )
865 foreach ( GEOMGUI* lib, myGUIMap )
866 lib->OnKeyPress( e, application()->desktop(), w );
869 //=================================================================================
870 // function : GeometryGUI::OnMouseMove()
871 // purpose : Manages mouse move events [static]
872 //=================================================================================
873 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
875 if ( !application() )
877 foreach ( GEOMGUI* lib, myGUIMap )
878 lib->OnMouseMove( e, application()->desktop(), w );
881 //=================================================================================
882 // function : GeometryGUI::OnMouseRelease()
883 // purpose : Manages mouse release events [static]
884 //=================================================================================
885 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
887 if ( !application() )
889 foreach ( GEOMGUI* lib, myGUIMap )
890 lib->OnMouseRelease( e, application()->desktop(), w );
893 //=================================================================================
894 // function : GeometryGUI::OnMousePress()
895 // purpose : Manage mouse press events [static]
896 //=================================================================================
897 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
899 if ( !application() )
901 foreach ( GEOMGUI* lib, myGUIMap )
902 lib->OnMousePress( e, application()->desktop(), w );
905 //=======================================================================
906 // function : createGeomAction
908 //=======================================================================
909 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
910 const int accel, const bool toggle, const QString& shortcutAction )
912 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
913 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
914 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
916 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
918 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
919 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
921 application()->desktop(),
923 this, SLOT( OnGUIEvent() ),
927 //=======================================================================
928 // function : createOriginAndBaseVectors
930 //=======================================================================
931 void GeometryGUI::createOriginAndBaseVectors()
933 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
934 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
936 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
940 if ( !CORBA::is_nil( GetGeomGen() ) ) {
941 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
942 if ( !aBasicOperations->_is_nil() ) {
943 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
944 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
945 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
946 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
947 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
948 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
950 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
951 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
952 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
953 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
954 anOrigin->UnRegister();
958 aBasicOperations->UnRegister();
960 getApp()->updateObjectBrowser( true );
966 //=======================================================================
967 // function : GeometryGUI::initialize()
968 // purpose : Called when GEOM module is created
969 //=======================================================================
970 void GeometryGUI::initialize( CAM_Application* app )
972 SalomeApp_Module::initialize( app );
974 // ----- create actions --------------
976 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
978 createGeomAction( GEOMOp::OpPoint, "POINT" );
979 createGeomAction( GEOMOp::OpLine, "LINE" );
980 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
981 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
982 createGeomAction( GEOMOp::OpArc, "ARC" );
983 createGeomAction( GEOMOp::OpCurve, "CURVE" );
984 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
985 createGeomAction( GEOMOp::OpVector, "VECTOR" );
986 createGeomAction( GEOMOp::OpPlane, "PLANE" );
987 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
988 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
989 createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
991 createGeomAction( GEOMOp::OpBox, "BOX" );
992 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
993 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
994 createGeomAction( GEOMOp::OpTorus, "TORUS" );
995 createGeomAction( GEOMOp::OpCone, "CONE" );
996 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
997 createGeomAction( GEOMOp::OpDisk, "DISK" );
999 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
1000 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
1001 createGeomAction( GEOMOp::OpFilling, "FILLING" );
1002 createGeomAction( GEOMOp::OpPipe, "PIPE" );
1003 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
1004 createGeomAction( GEOMOp::OpThickness, "THICKNESS" );
1006 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
1007 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
1008 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
1009 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
1010 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
1012 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
1013 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
1015 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
1017 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
1018 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
1020 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
1021 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
1022 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
1024 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1026 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1027 createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1029 createGeomAction( GEOMOp::OpEdge, "EDGE" );
1030 createGeomAction( GEOMOp::OpWire, "WIRE" );
1031 createGeomAction( GEOMOp::OpFace, "FACE" );
1032 createGeomAction( GEOMOp::OpShell, "SHELL" );
1033 createGeomAction( GEOMOp::OpSolid, "SOLID" );
1034 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
1036 createGeomAction( GEOMOp::OpFuse, "FUSE" );
1037 createGeomAction( GEOMOp::OpCommon, "COMMON" );
1038 createGeomAction( GEOMOp::OpCut, "CUT" );
1039 createGeomAction( GEOMOp::OpSection, "SECTION" );
1041 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
1042 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
1043 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
1044 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
1045 createGeomAction( GEOMOp::OpScale, "SCALE" );
1046 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
1047 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
1048 createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
1049 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1050 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
1051 createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
1053 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
1054 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
1055 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
1056 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
1057 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
1058 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
1059 createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
1060 createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
1061 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
1062 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
1063 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
1064 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
1066 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1067 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
1068 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
1070 createGeomAction( GEOMOp::OpSewing, "SEWING" );
1071 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
1072 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
1073 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
1074 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
1075 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1076 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1077 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1078 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1079 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1080 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1081 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1082 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1083 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1084 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1085 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1086 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1087 createGeomAction( GEOMOp::OpInspectObj, "INSPECT_OBJECT" );
1089 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1090 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1091 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1092 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1093 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1094 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1095 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1096 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1097 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1098 createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
1099 createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
1100 createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1102 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1103 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1104 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1105 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1106 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1107 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1108 createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
1109 #ifndef DISABLE_PLOT2DVIEWER
1110 createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
1113 #ifndef DISABLE_PYCONSOLE
1114 #ifdef _DEBUG_ // PAL16821
1115 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1119 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1120 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1121 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1122 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1123 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1124 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1125 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1126 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1127 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1128 createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
1129 createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
1130 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1131 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1132 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1133 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1134 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1135 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1136 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1137 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1138 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1139 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1140 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1141 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1142 createGeomAction( GEOMOp::OpHide, "ERASE" );
1144 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1145 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1146 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1147 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1148 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1149 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1150 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1151 createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
1152 createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
1153 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1154 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1155 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1156 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1157 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1158 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1159 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1160 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1161 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1162 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1163 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1164 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1165 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1166 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1167 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1168 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1169 createGeomAction( GEOMOp::OpMaterialMenu, "POP_MATERIAL_PROPERTIES");
1170 action(GEOMOp::OpMaterialMenu)->setMenu( new QMenu() );
1171 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1172 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1173 #ifndef DISABLE_GRAPHICSVIEW
1174 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1176 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1177 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1178 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1179 createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1180 createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1182 // Create actions for increase/decrease transparency shortcuts
1183 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1184 "Geometry:Increase transparency");
1185 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1186 "Geometry:Decrease transparency");
1188 // Create actions for increase/decrease number of isolines
1189 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1190 "Geometry:Increase number of isolines");
1191 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1192 "Geometry:Decrease number of isolines");
1194 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1195 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1196 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1197 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1198 //@@ 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 @@//
1200 // ---- create menus --------------------------
1202 /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1204 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1205 createMenu( GEOMOp::OpDelete, editId, -1 );
1207 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1209 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1210 createMenu( GEOMOp::OpPoint, basicId, -1 );
1211 createMenu( GEOMOp::OpLine, basicId, -1 );
1212 createMenu( GEOMOp::OpCircle, basicId, -1 );
1213 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1214 createMenu( GEOMOp::OpArc, basicId, -1 );
1215 createMenu( GEOMOp::OpCurve, basicId, -1 );
1216 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1217 createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1218 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1219 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1220 createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1221 createMenu( separator(), basicId, -1 );
1222 createMenu( GEOMOp::OpVector, basicId, -1 );
1223 createMenu( GEOMOp::OpPlane, basicId, -1 );
1224 createMenu( GEOMOp::OpLCS, basicId, -1 );
1225 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1227 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1228 createMenu( GEOMOp::OpBox, primId, -1 );
1229 createMenu( GEOMOp::OpCylinder, primId, -1 );
1230 createMenu( GEOMOp::OpSphere, primId, -1 );
1231 createMenu( GEOMOp::OpTorus, primId, -1 );
1232 createMenu( GEOMOp::OpCone, primId, -1 );
1233 createMenu( GEOMOp::OpRectangle, primId, -1 );
1234 createMenu( GEOMOp::OpDisk, primId, -1 );
1235 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1237 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1238 createMenu( GEOMOp::OpPrism, genId, -1 );
1239 createMenu( GEOMOp::OpRevolution, genId, -1 );
1240 createMenu( GEOMOp::OpFilling, genId, -1 );
1241 createMenu( GEOMOp::OpPipe, genId, -1 );
1242 createMenu( GEOMOp::OpPipePath, genId, -1 );
1243 createMenu( GEOMOp::OpThickness, genId, -1 );
1245 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1246 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1247 //@@ 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 @@//
1249 createMenu( separator(), newEntId, -1 );
1251 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1252 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1253 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1254 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1255 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1256 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1258 createMenu( separator(), newEntId, -1 );
1260 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1261 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1262 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1264 createMenu( separator(), newEntId, -1 );
1266 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1267 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1268 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1269 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1270 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1272 createMenu( separator(), newEntId, -1 );
1274 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1276 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1277 createMenu( GEOMOp::OpEdge, buildId, -1 );
1278 createMenu( GEOMOp::OpWire, buildId, -1 );
1279 createMenu( GEOMOp::OpFace, buildId, -1 );
1280 createMenu( GEOMOp::OpShell, buildId, -1 );
1281 createMenu( GEOMOp::OpSolid, buildId, -1 );
1282 createMenu( GEOMOp::OpCompound, buildId, -1 );
1284 createMenu( separator(), newEntId, -1 );
1286 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1288 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1291 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1293 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1294 createMenu( GEOMOp::OpFuse, boolId, -1 );
1295 createMenu( GEOMOp::OpCommon, boolId, -1 );
1296 createMenu( GEOMOp::OpCut, boolId, -1 );
1297 createMenu( GEOMOp::OpSection, boolId, -1 );
1299 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1300 createMenu( GEOMOp::OpTranslate, transId, -1 );
1301 createMenu( GEOMOp::OpRotate, transId, -1 );
1302 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1303 createMenu( GEOMOp::OpMirror, transId, -1 );
1304 createMenu( GEOMOp::OpScale, transId, -1 );
1305 createMenu( GEOMOp::OpOffset, transId, -1 );
1306 createMenu( GEOMOp::OpProjection, transId, -1 );
1307 createMenu( GEOMOp::OpExtension, transId, -1 );
1308 createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
1309 createMenu( separator(), transId, -1 );
1310 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1311 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1313 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1314 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1315 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1316 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1318 createMenu( separator(), operId, -1 );
1320 createMenu( GEOMOp::OpPartition, operId, -1 );
1321 createMenu( GEOMOp::OpArchimede, operId, -1 );
1322 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1323 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1324 createMenu( GEOMOp::OpTransferData, operId, -1 );
1325 createMenu( GEOMOp::OpExtraction, operId, -1 );
1327 createMenu( separator(), operId, -1 );
1329 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1330 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1331 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1332 createMenu( GEOMOp::OpChamfer, operId, -1 );
1333 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1334 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1336 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1337 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1338 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1339 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1340 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1341 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1342 createMenu( GEOMOp::OpSewing, repairId, -1 );
1343 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1344 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1345 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1346 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1347 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1348 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1349 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1350 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1351 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1352 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1353 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1355 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1356 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1357 createMenu( GEOMOp::OpProperties, measurId, -1 );
1358 createMenu( separator(), measurId, -1 );
1359 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1360 createMenu( GEOMOp::OpInertia, measurId, -1 );
1361 createMenu( GEOMOp::OpNormale, measurId, -1 );
1362 createMenu( separator(), measurId, -1 );
1363 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1364 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1365 createMenu( separator(), measurId, -1 );
1367 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1368 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1369 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1370 createMenu( GEOMOp::OpAngle, dimId, -1 );
1371 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1373 createMenu( GEOMOp::OpAnnotation, measurId, -1 );
1375 createMenu( separator(), measurId, -1 );
1376 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1377 createMenu( separator(), measurId, -1 );
1378 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1379 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1380 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1381 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1382 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1383 createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1384 createMenu( GEOMOp::OpInspectObj, measurId, -1 );
1385 #ifndef DISABLE_PLOT2DVIEWER
1386 createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1389 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1390 #ifndef DISABLE_PYCONSOLE
1391 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1392 createMenu( separator(), toolsId, -1 );
1393 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1397 createMenu( separator(), toolsId, -1 );
1398 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1399 createMenu( separator(), toolsId, -1 );
1401 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1402 createMenu( separator(), viewId, -1 );
1404 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1405 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1406 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1407 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1408 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1409 createMenu( separator(), dispmodeId, -1 );
1410 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1411 createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
1412 createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
1414 createMenu( separator(), viewId, -1 );
1415 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1416 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1417 createMenu( separator(), viewId, -1 );
1418 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1419 createMenu( separator(), viewId, -1 );
1423 because of these items are accessible through object browser and viewers
1424 we have removed they from main menu
1426 createMenu( GEOMOp::OpShow, viewId, -1 );
1427 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1428 createMenu( GEOMOp::OpHide, viewId, -1 );
1431 // ---- create toolbars --------------------------
1433 int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1434 createTool( GEOMOp::OpPoint, basicTbId );
1435 createTool( GEOMOp::OpLine, basicTbId );
1436 createTool( GEOMOp::OpCircle, basicTbId );
1437 createTool( GEOMOp::OpEllipse, basicTbId );
1438 createTool( GEOMOp::OpArc, basicTbId );
1439 createTool( GEOMOp::OpCurve, basicTbId );
1440 createTool( GEOMOp::OpVector, basicTbId );
1441 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1442 createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
1443 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1444 createTool( GEOMOp::OpIsoline, basicTbId );
1445 createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
1446 createTool( GEOMOp::OpPlane, basicTbId );
1447 createTool( GEOMOp::OpLCS, basicTbId );
1448 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1450 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1451 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1452 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1454 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1455 createTool( GEOMOp::OpBox, primTbId );
1456 createTool( GEOMOp::OpCylinder, primTbId );
1457 createTool( GEOMOp::OpSphere, primTbId );
1458 createTool( GEOMOp::OpTorus, primTbId );
1459 createTool( GEOMOp::OpCone, primTbId );
1460 createTool( GEOMOp::OpRectangle, primTbId );
1461 createTool( GEOMOp::OpDisk, primTbId );
1462 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1464 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1465 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1466 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1468 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1469 createTool( GEOMOp::OpFuse, boolTbId );
1470 createTool( GEOMOp::OpCommon, boolTbId );
1471 createTool( GEOMOp::OpCut, boolTbId );
1472 createTool( GEOMOp::OpSection, boolTbId );
1474 int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1475 createTool( GEOMOp::OpPrism, genTbId );
1476 createTool( GEOMOp::OpRevolution, genTbId );
1477 createTool( GEOMOp::OpFilling, genTbId );
1478 createTool( GEOMOp::OpPipe, genTbId );
1479 createTool( GEOMOp::OpPipePath, genTbId );
1480 createTool( GEOMOp::OpThickness, genTbId );
1482 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1483 createTool( GEOMOp::OpTranslate, transTbId );
1484 createTool( GEOMOp::OpRotate, transTbId );
1485 createTool( GEOMOp::OpChangeLoc, transTbId );
1486 createTool( GEOMOp::OpMirror, transTbId );
1487 createTool( GEOMOp::OpScale, transTbId );
1488 createTool( GEOMOp::OpOffset, transTbId );
1489 createTool( GEOMOp::OpProjection, transTbId );
1490 createTool( GEOMOp::OpExtension, transTbId );
1491 createTool( GEOMOp::OpProjOnCyl, transTbId );
1492 createTool( separator(), transTbId );
1493 createTool( GEOMOp::OpMultiTranslate, transTbId );
1494 createTool( GEOMOp::OpMultiRotate, transTbId );
1496 int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1497 createTool( GEOMOp::OpExplode, operTbId );
1498 createTool( GEOMOp::OpPartition, operTbId );
1499 createTool( GEOMOp::OpArchimede, operTbId );
1500 createTool( GEOMOp::OpShapesOnShape, operTbId );
1501 createTool( GEOMOp::OpSharedShapes, operTbId );
1502 createTool( GEOMOp::OpTransferData, operTbId );
1503 createTool( GEOMOp::OpExtraction, operTbId );
1505 int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1506 createTool( GEOMOp::OpFillet1d, featTbId );
1507 createTool( GEOMOp::OpFillet2d, featTbId );
1508 createTool( GEOMOp::OpFillet3d, featTbId );
1509 createTool( GEOMOp::OpChamfer, featTbId );
1510 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1511 createTool( GEOMOp::OpExtrudedCut, featTbId );
1513 int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1514 createTool( GEOMOp::OpEdge, buildTbId );
1515 createTool( GEOMOp::OpWire, buildTbId );
1516 createTool( GEOMOp::OpFace, buildTbId );
1517 createTool( GEOMOp::OpShell, buildTbId );
1518 createTool( GEOMOp::OpSolid, buildTbId );
1519 createTool( GEOMOp::OpCompound, buildTbId );
1521 int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1522 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1523 createTool( GEOMOp::OpProperties, measureTbId );
1524 createTool( GEOMOp::OpCenterMass, measureTbId );
1525 createTool( GEOMOp::OpInertia, measureTbId );
1526 createTool( GEOMOp::OpNormale, measureTbId );
1527 createTool( separator(), measureTbId );
1528 createTool( GEOMOp::OpBoundingBox, measureTbId );
1529 createTool( GEOMOp::OpMinDistance, measureTbId );
1530 createTool( GEOMOp::OpAngle, measureTbId );
1531 createTool( GEOMOp::OpAnnotation, measureTbId );
1532 createTool( GEOMOp::OpTolerance , measureTbId );
1533 createTool( separator(), measureTbId );
1534 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1535 createTool( GEOMOp::OpFreeFaces, measureTbId );
1536 createTool( separator(), measureTbId );
1537 createTool( GEOMOp::OpWhatIs, measureTbId );
1538 createTool( GEOMOp::OpCheckShape, measureTbId );
1539 createTool( GEOMOp::OpCheckCompound, measureTbId );
1540 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1541 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1542 createTool( GEOMOp::OpFastCheckInters, measureTbId );
1544 int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1545 createTool( GEOMOp::OpPictureImport, picturesTbId );
1547 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1550 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1551 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1552 //@@ 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 @@//
1554 // ---- create popup menus --------------------------
1556 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1557 QString clientOCC = "(client='OCCViewer')";
1558 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1559 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1561 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1562 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1563 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1564 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1566 QString notGEOMShape = "(not ($component={'GEOM'}) and ($displayer={'Geometry'}))";
1568 QString autoColorPrefix =
1569 "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1571 QtxPopupMgr* mgr = popupMgr();
1573 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1574 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1575 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1576 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1577 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1578 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1579 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1580 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1582 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1583 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1584 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1585 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1586 mgr->insert( separator(), -1, -1 ); // -----------
1588 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1589 QString bringRule = clientOCCorOB + " and ($displayer={'Geometry'}) and isFolder=false and (selcount>0) and isOCC=true";
1590 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1591 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1592 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1593 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1594 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1595 mgr->insert( separator(), -1, -1 ); // -----------
1596 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1597 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1598 //mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1599 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1600 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1601 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1602 // mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1603 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1604 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1605 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1606 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1607 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1608 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1609 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1610 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1611 mgr->insert( separator(), dispmodeId, -1 );
1612 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1613 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1614 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1615 mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1616 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1617 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1618 mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1619 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1620 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1621 mgr->insert( separator(), -1, -1 ); // -----------
1623 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1624 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($displayer={'Geometry'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1625 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1626 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1627 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1628 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1629 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1630 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1631 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1632 mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and ($type in {'Shape' 'Group' 'Field' 'FieldStep'} or " + notGEOMShape + ") and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1634 // material properties
1635 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1636 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=false", QtxPopupMgr::VisibleRule );
1637 mgr->insert( action( GEOMOp::OpMaterialMenu ), -1, -1 );
1638 mgr->setRule( action( GEOMOp::OpMaterialMenu ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=true", QtxPopupMgr::VisibleRule );
1641 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1642 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1644 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1645 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1646 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1648 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1649 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1651 mgr->insert( separator(), -1, -1 ); // -----------
1652 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1653 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1654 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1655 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1656 mgr->insert( separator(), -1, -1 ); // -----------
1658 mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
1659 mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1660 mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
1661 mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1662 mgr->insert( separator(), -1, -1 ); // -----------
1664 //QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1665 // onlyComponent = "((type='Component') and selcount=1)",
1666 // rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1667 // types = "'Shape' 'Group' 'FieldStep'";
1669 QString canDisplay = "($displayer={'Geometry'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1670 onlyComponent = "((type='Component') and ($component={'GEOM'}) and selcount=1)",
1671 rule = canDisplay + "and ((($type in {%1} or " + notGEOMShape + ") and( %2 )) or " + onlyComponent + ")",
1672 types = "'Shape' 'Group' 'FieldStep'";
1674 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1675 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1677 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1678 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1680 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1681 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1683 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1685 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1686 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1687 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1688 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1689 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1690 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1691 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1692 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1693 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1694 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1695 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1696 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1697 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1698 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1699 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1700 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1701 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1702 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1703 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1704 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1705 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1706 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1707 mgr->insert( separator(), selectonlyId, -1);
1708 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1709 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1710 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1711 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1712 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1713 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1714 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1716 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1718 mgr->insert( separator(), -1, -1 ); // -----------
1719 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1720 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1721 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1722 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1723 mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1724 mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1725 mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1726 mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1728 mgr->insert( separator(), -1, -1 ); // -----------
1729 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1730 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1732 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1733 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1735 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1736 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1738 mgr->insert( separator(), -1, -1 ); // -----------
1739 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1740 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1742 mgr->insert( separator(), -1, -1 ); // -----------
1743 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1744 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1746 #ifndef DISABLE_GRAPHICSVIEW
1747 mgr->insert( separator(), -1, -1 ); // -----------
1748 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1749 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1752 mgr->insert( separator(), -1, -1 ); // -----------
1753 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1754 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1756 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1758 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1760 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1761 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1762 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1765 // create plugin actions and menus
1769 //=======================================================================
1770 // function : GeometryGUI::addPluginActions()
1772 //=======================================================================
1773 void GeometryGUI::addPluginActions()
1776 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1777 if (!resMgr) return;
1779 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1780 if (!appStudy) return;
1782 // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1784 GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1786 int id = GEOMOp::OpLastOperationID; // TODO?
1789 GEOMUtils::PluginInfo::const_iterator it;
1790 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1791 // bind action lib and label to its ID for activateOperation() method proper work
1792 GEOMUtils::PluginData pdata = (*it);
1793 myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1794 std::list<GEOMUtils::ActionData> actions = (*it).actions;
1795 std::list<GEOMUtils::ActionData>::const_iterator ait;
1796 for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1797 GEOMUtils::ActionData adata = (*ait);
1800 if ( !adata.icon.empty() )
1801 icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1803 QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1804 QString actionName = smenus.last();
1805 actionName = actionName.toUpper().prepend( "MEN_" );
1806 smenus.removeLast();
1808 // path to action in toolbar
1809 QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1810 QString actionTool = stools.last();
1811 actionTool = actionTool.toUpper().prepend( "TOP_" );
1812 stools.removeLast();
1814 QString actionStat = adata.statusText.c_str();
1815 actionStat = actionStat.toUpper().prepend( "STB_" );
1817 createAction( id, // ~ adata.label
1818 tr( actionTool.toLatin1().constData() ),
1820 tr( actionName.toLatin1().constData() ),
1821 tr( actionStat.toLatin1().constData() ),
1822 QKeySequence( tr( adata.accel.c_str() ) ),
1823 application()->desktop(),
1825 this, SLOT( OnGUIEvent() ),
1826 QString() /*shortcutAction*/ );
1829 foreach ( QString subMenu, smenus ) {
1830 QStringList subMenuList = subMenu.split( ":" );
1831 QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1832 int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1833 menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1835 createMenu( id, menuId, -1 );
1837 if ( !stools.isEmpty() ) {
1838 QString subTool = stools[0];
1839 subTool = subTool.toUpper().prepend( "TOOL_" );
1840 int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1841 createTool(id, toolId);
1844 // add action id to map
1845 PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1846 myPluginActions[id] = anAction;
1855 QString wrap(const QString& text, const QString& tag)
1856 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
1859 //=======================================================================
1860 // function : GeometryGUI::activateModule()
1861 // purpose : Called when GEOM module is activated
1862 //=======================================================================
1863 bool GeometryGUI::activateModule( SUIT_Study* study )
1865 // Fill in: Help Panel
1866 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
1867 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_GEOM"));
1869 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MODEL"));
1872 items << wrap(tr("INFO_VERTICES"), "li")
1873 << wrap(tr("INFO_EDGES"), "li")
1874 << wrap(tr("INFO_WIRES"), "li")
1875 << wrap(tr("INFO_FACES"), "li")
1876 << wrap(tr("INFO_SHELLS"), "li")
1877 << wrap(tr("INFO_SOLIDS"), "li");
1878 lab = tr("INFO_BOTTOM_UP_CONSTRUCTION") + ":" + wrap(items.join(""), "ul");
1881 items << wrap(tr("INFO_BOX"), "li")
1882 << wrap(tr("INFO_CYLINDER"), "li")
1883 << wrap(tr("INFO_CONE"), "li")
1884 << wrap("...", "li");
1885 lab = lab + tr("INFO_PRIMITIVES") + ":" + wrap(items.join(""), "ul");
1888 lab = lab + tr("INFO_BOOLEANS") + "<br/>";
1889 lab = lab + tr("INFO_TRANSFORMATIONS");
1891 app->infoPanel()->addLabel(lab, gb);
1893 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MODEL"));
1894 items << wrap("BREP", "li")
1895 << wrap("STEP", "li")
1896 << wrap("IGES", "li")
1897 << wrap("STL", "li")
1898 << wrap("XAO", "li");
1899 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
1902 app->infoPanel()->addLabel(lab, gb);
1905 if ( CORBA::is_nil( myComponentGeom ) )
1908 bool res = SalomeApp_Module::activateModule( study );
1912 setMenuShown( true );
1913 setToolShown( true );
1915 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1916 PyGILState_STATE gstate = PyGILState_Ensure();
1917 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1918 if ( !pluginsmanager ) {
1923 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1924 tr("MEN_NEW_ENTITY").toUtf8().data(),
1925 tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1930 PyGILState_Release(gstate);
1931 // end of GEOM plugins loading
1933 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1934 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
1936 // Reset actions accelerator keys
1937 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1939 GUIMap::Iterator it;
1940 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1941 it.value()->activate( application()->desktop() );
1943 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1945 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ), Qt::UniqueConnection );
1946 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ), Qt::UniqueConnection );
1947 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ), Qt::UniqueConnection );
1949 if ( !myCreationInfoWdg )
1950 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1951 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1952 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1954 if ( !myTextTreeWdg ) {
1955 myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1956 new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1959 getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1960 getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1963 SALOME_ListIO selected;
1964 sm->selectedObjects( selected );
1965 sm->clearSelected();
1967 SUIT_ViewManager* vm;
1968 ViewManagerList OCCViewManagers, VTKViewManagers;
1970 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1971 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1972 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1973 onViewManagerAdded(vm);
1975 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1976 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1977 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1978 onViewManagerAdded(vm);
1980 sm->setSelectedObjects( selected, true ); //NPAL 19674
1982 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1984 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ), Qt::UniqueConnection );
1986 // 0020836 (Basic vectors and origin)
1987 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1988 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1989 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1991 _PTR(Study) studyDS = appStudy->studyDS();
1993 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1994 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1995 createOriginAndBaseVectors();
2000 Py_XDECREF(pluginsmanager);
2005 //=======================================================================
2006 // function : GeometryGUI::deactivateModule()
2007 // purpose : Called when GEOM module is deactivated
2008 //=======================================================================
2009 bool GeometryGUI::deactivateModule( SUIT_Study* study )
2011 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
2013 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
2015 setMenuShown( false );
2016 setToolShown( false );
2018 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
2019 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
2021 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
2023 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
2024 //disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
2025 if ( myCreationInfoWdg ) {
2026 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
2027 myCreationInfoWdg = 0;
2029 if ( myTextTreeWdg ) {
2030 getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
2031 disconnect( application(), 0, myTextTreeWdg, 0 );
2035 EmitSignalCloseAllDialogs();
2037 GUIMap::Iterator it;
2038 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
2039 it.value()->deactivate();
2041 // Unset actions accelerator keys
2042 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
2044 qDeleteAll(myOCCSelectors);
2045 myOCCSelectors.clear();
2046 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
2048 qDeleteAll(myVTKSelectors);
2049 myVTKSelectors.clear();
2050 selMrg->setEnabled( true, SVTK_Viewer::Type() );
2052 return SalomeApp_Module::deactivateModule( study );
2055 //=======================================================================
2056 // function : onWindowActivated()
2057 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
2058 //=======================================================================
2059 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
2064 const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
2065 //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
2067 // disable non-OCC viewframe menu commands
2068 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
2069 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
2070 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
2071 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
2072 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
2073 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
2074 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2076 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2077 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2078 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2079 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2081 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2084 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2086 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2087 mappa.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea );
2088 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2089 #ifndef DISABLE_PYCONSOLE
2090 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2092 if ( myCreationInfoWdg )
2093 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2094 if ( myTextTreeWdg )
2095 mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2098 void GeometryGUI::viewManagers( QStringList& lst ) const
2100 lst.append( OCCViewer_Viewer::Type() );
2103 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2105 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2107 qDebug( "connect" );
2108 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
2109 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2110 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2111 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2112 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2113 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2114 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2115 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2117 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2118 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2120 // disable OCC selectors
2121 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2122 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2123 while ( itOCCSel.hasNext() )
2124 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2125 sr->setEnabled(true);
2127 else if ( vm->getType() == SVTK_Viewer::Type() )
2129 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2130 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2132 // disable VTK selectors
2133 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2134 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2135 while ( itVTKSel.hasNext() )
2136 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2137 sr->setEnabled(true);
2141 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2143 SUIT_ViewModel* viewer = vm->getViewModel();
2144 if ( vm->getType() == OCCViewer_Viewer::Type() )
2146 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2147 while ( itOCCSel.hasNext() )
2148 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2149 if ( sr->viewer() == viewer )
2151 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2155 if ( vm->getType() == SVTK_Viewer::Type() )
2157 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2158 while ( itVTKSel.hasNext() )
2159 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2160 if ( sr->viewer() == viewer )
2162 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2166 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2168 GetAnnotationMgr()->RemoveView( aSOCCView );
2172 //================================================================================
2174 * \brief Slot called when selection changed. Shows creation info of a selected object
2176 //================================================================================
2178 void GeometryGUI::updateCreationInfo()
2180 if ( myCreationInfoWdg )
2181 myCreationInfoWdg->clear();
2183 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2184 // if ( !myCreationInfoWdg->isVisible() )
2187 // look for a sole selected GEOM_Object
2188 GEOM::GEOM_BaseObject_var geomObj;
2190 SALOME_ListIO selected;
2191 getApp()->selectionMgr()->selectedObjects( selected );
2193 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2194 SALOME_ListIteratorOfListIO selIt( selected );
2195 for ( ; selIt.More(); selIt.Next() )
2197 Handle(SALOME_InteractiveObject) io = selIt.Value();
2198 if ( !io->hasEntry() ) continue;
2199 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2200 if ( !GeometryGUI::IsInGeomComponent( sobj )) continue;
2201 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2202 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2203 if ( !gobj->_is_nil() )
2205 if ( !geomObj->_is_nil() )
2206 return; // several GEOM objects selected
2210 if ( geomObj->_is_nil() ) return;
2212 // pass creation info of geomObj to myCreationInfoWdg
2214 if ( myCreationInfoWdg ) {
2216 GEOM::CreationInformationSeq_var info;
2219 info = geomObj->GetCreationInformation();
2223 myCreationInfoWdg->setInfo( info );
2227 void GeometryGUI::onAutoBringToFront()
2229 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2230 if( !isAutoBringToFront )
2233 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2234 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2237 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2238 if (!appStudy) return;
2240 GEOM_Displayer displayer;
2242 SALOME_View* window = displayer.GetActiveView();
2243 if ( !window ) return;
2245 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2247 SALOME_ListIO selected;
2248 getApp()->selectionMgr()->selectedObjects( selected );
2249 if (!myTopLevelIOList.IsEmpty())
2251 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2253 Handle( SALOME_InteractiveObject ) io = It.Value();
2254 bool isSelected = false;
2255 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2257 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2258 if( io->isSame( sel_io ) )
2261 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2263 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2264 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2269 myTopLevelIOList.Assign(selected);
2270 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2272 Handle( SALOME_InteractiveObject ) io = It.Value();
2273 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2274 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2277 displayer.UpdateViewer();
2278 GeometryGUI::Modified();
2281 void GeometryGUI::updateFieldColorScale()
2283 GEOM_Displayer aDisplayer;
2284 aDisplayer.UpdateColorScale();
2287 QString GeometryGUI::engineIOR() const
2289 if ( !CORBA::is_nil( GetGeomGen() ) )
2290 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2294 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2296 theWidth = theHeight = 0;
2297 Handle(TColStd_HArray1OfByte) aTexture;
2299 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2300 if ( !aInsOp->_is_nil() ) {
2301 CORBA::Long aWidth, aHeight;
2302 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2303 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2305 theHeight = aHeight;
2307 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2309 for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2310 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2316 LightApp_Selection* GeometryGUI::createSelection() const
2318 return new GEOMGUI_Selection();
2321 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2323 SalomeApp_Module::contextMenuPopup( client, menu, title );
2325 getApp()->selectionMgr()->selectedObjects( lst );
2327 // Update submenu for predefined materials
2328 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2329 QMenu* matMenu = action( GEOMOp::OpMaterialMenu )->menu();
2331 QSignalMapper* signalMapper = new QSignalMapper( menu );
2334 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2335 if ( anApp && anApp->activeViewManager() ) {
2336 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2338 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2341 QString curModel = "";
2342 if ( v.canConvert<QString>() ) curModel = v.toString();
2344 // get list of all predefined materials
2345 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2347 foreach ( QString material, materials )
2349 QAction* a = matMenu->addAction( material );
2350 connect( a, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2351 signalMapper->setMapping( a, material );
2352 a->setCheckable( true );
2354 Material_Model aModel;
2355 aModel.fromResources( material );
2356 if ( !found && aModel.toProperties() == curModel ) {
2357 a->setChecked( true );
2361 matMenu->addSeparator();
2362 matMenu->addAction( action( GEOMOp::OpPredefMaterCustom ) );
2363 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2364 this, SLOT( OnSetMaterial( const QString & ) ) );
2367 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2368 Handle(SALOME_InteractiveObject) io = lst.First();
2369 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2370 _PTR(Study) study = appStudy->studyDS();
2371 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2373 QString aName = QString( obj->GetName().c_str() );
2374 aName.remove( QRegExp("\\s+$") );
2380 void GeometryGUI::OnSetMaterial(const QString& theName)
2382 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2386 void GeometryGUI::createPreferences()
2388 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2390 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2392 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2393 setPreferenceProperty( genGroup, "columns", 2 );
2395 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2396 LightApp_Preferences::Selector,
2397 "Geometry", "display_mode" );
2399 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2400 LightApp_Preferences::Color, "Geometry", "shading_color" );
2402 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2403 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2405 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2406 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2408 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2409 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2411 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2412 LightApp_Preferences::Color, "Geometry", "line_color" );
2414 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2415 LightApp_Preferences::Color, "Geometry", "point_color" );
2417 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2418 LightApp_Preferences::Color, "Geometry", "isos_color" );
2420 addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2421 LightApp_Preferences::Color, "Geometry", "label_color" );
2423 addPreference( "", genGroup, LightApp_Preferences::Space );
2425 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2426 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2428 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2429 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2431 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2432 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2434 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2435 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2437 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2438 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2440 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2441 LightApp_Preferences::Selector,
2442 "Geometry", "material" );
2444 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2445 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2451 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2452 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2454 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2455 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2457 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2458 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2460 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2461 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2463 for (int i = 0; i < nb; i++) {
2464 setPreferenceProperty( wd[i], "min", 1 );
2465 setPreferenceProperty( wd[i], "max", 5 );
2468 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2469 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2471 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2472 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2474 // --------------------------------------------------------------------------
2475 // Dimensions (Measurements) preferences
2476 // --------------------------------------------------------------------------
2478 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2479 setPreferenceProperty( aDimGroupId, "columns", 2 );
2481 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2482 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2484 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2485 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2487 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2488 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2490 int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2492 int f = QtxFontEdit::Family | QtxFontEdit::Size;
2493 setPreferenceProperty( aDimFontId, "features", f );
2494 setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2496 Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2497 QString aFontFile = "";
2498 resMgr->value("resources", "GEOM", aFontFile);
2499 aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2500 // add enginier font into combobox
2501 /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2502 Handle(Font_SystemFont) sf = new Font_SystemFont( TCollection_AsciiString("Y14.5M-2009") );
2503 sf->SetFontPath( Font_FA_Regular,
2504 TCollection_AsciiString( aFontFile.toLatin1().data() ) );
2505 // register font in OCC font manager
2506 fmgr->RegisterFont( sf, Standard_False );
2508 // get list of supported fonts by OCC
2509 QStringList anOCCFonts;
2510 TColStd_SequenceOfHAsciiString theFontsNames;
2511 fmgr->GetAvailableFontsNames( theFontsNames );
2512 for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2513 Handle(TCollection_HAsciiString) str = theFontsNames(i);
2514 anOCCFonts << str->ToCString();
2516 anOCCFonts.removeDuplicates();
2517 // set the supported fonts into combobox to use its only
2518 setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2520 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2521 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2523 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2524 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2525 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2527 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2528 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2530 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2531 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2533 QStringList aListOfLengthUnits;
2534 aListOfLengthUnits << "m";
2535 aListOfLengthUnits << "cm";
2536 aListOfLengthUnits << "mm";
2537 aListOfLengthUnits << "in.";
2538 aListOfLengthUnits << "ft.";
2540 QStringList aListOfAngUnits;
2541 aListOfAngUnits << "rad";
2542 aListOfAngUnits << "deg";
2544 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2545 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2547 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2548 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2550 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2551 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2553 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2554 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2555 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2557 addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2558 LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2560 // --------------------------------------------------------------------------
2561 // Shape annotation preferences
2562 // --------------------------------------------------------------------------
2564 const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2565 setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2567 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2568 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2569 const int aShapeAnnFont =
2570 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2572 int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2573 setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2574 setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2575 setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2577 const int aShapeAnnLineWidth =
2578 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2580 setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2581 setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2583 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2585 const int aShapeAnnLineStyle =
2586 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2588 QStringList aLineStyleList;
2589 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2590 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2591 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2592 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2594 QList<QVariant> aLineStyleIds;
2595 aLineStyleIds.append(0);
2596 aLineStyleIds.append(1);
2597 aLineStyleIds.append(2);
2598 aLineStyleIds.append(3);
2600 setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2601 setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2603 // --------------------------------------------------------------------------
2604 // Isoline drawing preferences
2605 // --------------------------------------------------------------------------
2607 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2608 setPreferenceProperty( isoGroup, "columns", 2 );
2609 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2610 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2611 setPreferenceProperty( isoU, "min", 0 );
2612 setPreferenceProperty( isoU, "max", 100000 );
2613 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2614 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2615 setPreferenceProperty( isoV, "min", 0 );
2616 setPreferenceProperty( isoV, "max", 100000 );
2618 // Quantities with individual precision settings
2619 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2620 setPreferenceProperty( precGroup, "columns", 2 );
2622 const int nbQuantities = 8;
2623 int prec[nbQuantities], ii = 0;
2624 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2625 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2626 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2627 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2628 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2629 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2630 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2631 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2632 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2633 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2634 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2635 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2636 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2637 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2638 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2639 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2641 // Set property for precision value for spinboxes
2642 for ( ii = 0; ii < nbQuantities; ii++ ){
2643 setPreferenceProperty( prec[ii], "min", -14 );
2644 setPreferenceProperty( prec[ii], "max", 14 );
2645 setPreferenceProperty( prec[ii], "precision", 2 );
2648 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2649 setPreferenceProperty( VertexGroup, "columns", 2 );
2651 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2652 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2654 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2655 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2657 // Set property for default display mode
2658 QStringList aModesList;
2659 aModesList.append( tr("MEN_WIREFRAME") );
2660 aModesList.append( tr("MEN_SHADING") );
2661 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2662 aModesList.append( tr("MEN_TEXTURE") );
2664 QList<QVariant> anIndexesList;
2665 anIndexesList.append(0);
2666 anIndexesList.append(1);
2667 anIndexesList.append(2);
2668 anIndexesList.append(3);
2670 setPreferenceProperty( dispmode, "strings", aModesList );
2671 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2673 // Set property for top level display mode
2674 QStringList aTopModesList;
2675 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2676 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2677 aTopModesList.append( tr("MEN_WIREFRAME") );
2678 aTopModesList.append( tr("MEN_SHADING") );
2679 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2681 QList<QVariant> aTopIndexesList;
2682 aTopIndexesList.append(0);
2683 aTopIndexesList.append(1);
2684 aTopIndexesList.append(2);
2685 aTopIndexesList.append(3);
2686 aTopIndexesList.append(4);
2688 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2689 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2691 // Set property for step value for spinboxes
2692 setPreferenceProperty( step, "min", 1 );
2693 setPreferenceProperty( step, "max", 10000 );
2694 setPreferenceProperty( step, "precision", 3 );
2696 // Set property for trandparency value for spinboxes
2697 setPreferenceProperty( transparency, "min", 0 );
2698 setPreferenceProperty( transparency, "max", 100 );
2700 // Set property for deflection value for spinboxes
2701 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2702 setPreferenceProperty( defl, "max", 1.0 );
2703 setPreferenceProperty( defl, "step", 1.0e-04 );
2704 setPreferenceProperty( defl, "precision", 6 );
2706 // Set property for default material
2707 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2709 // Set property vertex marker type
2710 QList<QVariant> aMarkerTypeIndicesList;
2711 QList<QVariant> aMarkerTypeIconsList;
2713 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2714 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2715 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2716 aMarkerTypeIndicesList << (i-1);
2717 aMarkerTypeIconsList << pixmap;
2720 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2721 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2723 // Set property for vertex marker scale
2724 QList<QVariant> aMarkerScaleIndicesList;
2725 QStringList aMarkerScaleValuesList;
2727 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2728 aMarkerScaleIndicesList << iii;
2729 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2732 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2733 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2735 // Scalar bar for field step presentation
2736 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2737 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2739 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2740 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2741 setPreferenceProperty( sbXPosition, "min", 0 );
2742 setPreferenceProperty( sbXPosition, "max", 1 );
2743 setPreferenceProperty( sbXPosition, "step", 0.05 );
2745 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2746 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2747 setPreferenceProperty( sbYPosition, "min", 0 );
2748 setPreferenceProperty( sbYPosition, "max", 1 );
2749 setPreferenceProperty( sbYPosition, "step", 0.05 );
2751 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2752 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2753 setPreferenceProperty( sbWidth, "min", 0 );
2754 setPreferenceProperty( sbWidth, "max", 1 );
2755 setPreferenceProperty( sbWidth, "step", 0.05 );
2757 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2758 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2759 setPreferenceProperty( sbHeight, "min", 0 );
2760 setPreferenceProperty( sbHeight, "max", 1 );
2761 setPreferenceProperty( sbHeight, "step", 0.05 );
2763 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2764 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2765 setPreferenceProperty( sbTextHeight, "min", 6 );
2766 setPreferenceProperty( sbTextHeight, "max", 24 );
2767 setPreferenceProperty( sbTextHeight, "step", 1 );
2769 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2770 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2771 setPreferenceProperty( sbNbIntervals, "min", 2 );
2772 setPreferenceProperty( sbNbIntervals, "max", 64 );
2773 setPreferenceProperty( sbNbIntervals, "step", 1 );
2775 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2776 setPreferenceProperty( originGroup, "columns", 2 );
2778 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2779 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2780 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2781 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2783 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2784 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2786 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2787 setPreferenceProperty( operationsGroup, "columns", 2 );
2789 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2790 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2792 addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2793 LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2795 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2797 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2799 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2800 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2802 QStringList aHierarchyTypeList;
2803 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2804 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2805 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2807 QList<QVariant> aHierarchyTypeIndexesList;
2808 aHierarchyTypeIndexesList.append(0);
2809 aHierarchyTypeIndexesList.append(1);
2810 aHierarchyTypeIndexesList.append(2);
2812 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2813 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2815 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2816 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2818 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2820 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2821 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2823 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2824 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2825 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2826 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2827 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2828 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2829 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2830 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2832 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2833 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2834 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2835 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2836 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2837 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2844 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2846 if (section == "Geometry") {
2847 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2848 if (param == QString("SettingsGeomStep")) {
2849 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2850 EmitSignalDefaultStepValueChanged(spin_step);
2852 else if (param == QString("toplevel_color")) {
2853 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2854 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2856 else if (param == QString("toplevel_dm")) {
2857 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2859 else if (param == QString("scalar_bar_x_position") ||
2860 param == QString("scalar_bar_y_position") ||
2861 param == QString("scalar_bar_width") ||
2862 param == QString("scalar_bar_height") ||
2863 param == QString("scalar_bar_text_height") ||
2864 param == QString("scalar_bar_nb_intervals")) {
2865 updateFieldColorScale();
2867 else if ( param == QString("dimensions_color") ||
2868 param == QString("dimensions_line_width") ||
2869 param == QString("dimensions_font") ||
2870 param == QString("dimensions_arrow_length") ||
2871 param == QString("dimensions_show_units") ||
2872 param == QString("dimensions_length_units") ||
2873 param == QString("dimensions_angle_units") ||
2874 param == QString("dimensions_use_text3d") ||
2875 param == QString("shape_annotation_font_color") ||
2876 param == QString("shape_annotation_line_color") ||
2877 param == QString("shape_annotation_font") ||
2878 param == QString("shape_annotation_line_width") ||
2879 param == QString("shape_annotation_autohide") ||
2880 param == QString("shape_annotation_line_style") ||
2881 param == QString("shape_annotation_line_style") ||
2882 param == QString("label_color") )
2884 SalomeApp_Application* anApp = getApp();
2890 GEOM_Displayer aDisplayer;
2892 ViewManagerList aVMs;
2893 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2894 ViewManagerList::Iterator anIt = aVMs.begin();
2895 for ( ; anIt != aVMs.end(); ++anIt )
2897 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2903 SALOME_ListIO aVisible;
2904 aViewer->GetVisible( aVisible );
2906 GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2907 if ( anAnnotationMgr ) {
2908 SALOME_ListIteratorOfListIO anIter( aVisible );
2909 while ( anIter.More() ) {
2910 if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2911 aVisible.Remove( anIter );
2919 aDisplayer.Redisplay( aVisible, false, aViewer );
2921 if ( param == QString( "label_color" ) ) {
2922 ViewManagerList aVMsVTK;
2923 anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2924 ViewManagerList::Iterator anIt = aVMsVTK.begin();
2925 for ( ; anIt != aVMsVTK.end(); ++anIt )
2927 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2932 SALOME_ListIO aVisible;
2933 aViewer->GetVisible( aVisible );
2934 aDisplayer.Redisplay( aVisible, false, aViewer );
2937 aDisplayer.UpdateViewer();
2939 else if ( param.startsWith( "dependency_tree") )
2940 emit SignalDependencyTreeParamChanged( section, param );
2944 LightApp_Displayer* GeometryGUI::displayer()
2947 myDisplayer = new GEOM_Displayer();
2951 void GeometryGUI::setLocalSelectionMode(const int mode)
2953 myLocalSelectionMode = mode;
2956 int GeometryGUI::getLocalSelectionMode() const
2958 return myLocalSelectionMode;
2961 const char gSeparator = '_'; // character used to separate parameter names
2962 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2965 * \brief Store visual parameters
2967 * This method is called just before the study document is saved.
2968 * Store visual parameters in AttributeParameter attribute(s)
2970 void GeometryGUI::storeVisualParameters (int savePoint)
2972 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2973 if ( !appStudy || !appStudy->studyDS() )
2976 _PTR(Study) studyDS = appStudy->studyDS();
2978 // componentName is used for encoding of entries when storing them in IParameters
2979 std::string componentName = myComponentGeom->ComponentDataType();
2980 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2981 //if (!aSComponent) return;
2984 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2985 componentName.c_str(),
2987 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2989 QSet<QString> anEntriesToStoreShared;
2990 QList<SUIT_ViewManager*> lst;
2991 QList<SUIT_ViewManager*>::Iterator it;
2993 GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
2995 // main cycle to store parameters of displayed objects
2997 getApp()->viewManagers(lst);
2998 for (it = lst.begin(); it != lst.end(); it++) {
2999 SUIT_ViewManager* vman = *it;
3000 QString vType = vman->getType();
3001 SUIT_ViewModel* vmodel = vman->getViewModel();
3002 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3004 int aMgrId = vman->getGlobalId();
3005 // saving VTK actors properties
3006 QVector<SUIT_ViewWindow*> views = vman->getViews();
3007 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
3008 const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
3009 ObjMap::ConstIterator o_it = anObjects.begin();
3010 for (; o_it != anObjects.end(); o_it++) {
3011 const PropMap& aProps = o_it.value();
3013 //Check that object exists in the study
3014 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toUtf8().data() ) );
3015 if ( !obj || !(aProps.count() > 0))
3017 // entry is "encoded" = it does NOT contain component address, since it is a
3018 // subject to change on next component loading
3020 std::string entry = ip->encodeEntry(o_it.key().toUtf8().data(), componentName);
3022 _PTR(GenericAttribute) anAttr;
3023 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
3026 // remember entry of object to store shared GEOM properties
3027 // (e.g. dimension properties).
3028 if ( vType == OCCViewer_Viewer::Type() )
3030 anEntriesToStoreShared.insert( o_it.key() );
3033 QString param, occParam = vType;
3034 occParam += GEOM::sectionSeparator();
3035 occParam += QString::number(aMgrId);
3036 occParam += GEOM::sectionSeparator();
3038 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
3039 param = occParam + GEOM::propertyName( GEOM::Visibility );
3040 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
3043 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
3044 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
3045 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
3048 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
3049 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
3051 val << QString::number(c.redF());
3052 val << QString::number(c.greenF());
3053 val << QString::number(c.blueF());
3054 param = occParam + GEOM::propertyName( GEOM::Color );
3055 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
3058 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
3059 param = occParam + GEOM::propertyName( GEOM::Texture );
3060 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
3063 if (vType == SVTK_Viewer::Type()) {
3064 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
3065 param = occParam + GEOM::propertyName( GEOM::Opacity );
3066 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
3068 } else if (vType == SOCC_Viewer::Type()) {
3069 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3070 param = occParam + GEOM::propertyName( GEOM::Transparency );
3071 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3074 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3075 param = occParam + GEOM::propertyName( GEOM::TopLevel );
3076 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3080 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3081 param = occParam + GEOM::propertyName( GEOM::NbIsos );
3082 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3085 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3086 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3087 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3090 if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3091 param = occParam + GEOM::propertyName( GEOM::Vertices );
3092 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3095 if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3096 param = occParam + GEOM::propertyName( GEOM::ShowName );
3097 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3100 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3101 param = occParam + GEOM::propertyName( GEOM::Deflection );
3102 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3105 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3106 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3107 param = occParam + GEOM::propertyName( GEOM::PointMarker );
3108 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3111 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3112 param = occParam + GEOM::propertyName( GEOM::Material );
3113 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3116 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3117 param = occParam + GEOM::propertyName( GEOM::LineWidth );
3118 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3121 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3122 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3123 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3126 if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3127 std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3128 o_it.key().toUtf8().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3129 if (!anAnnotationInfo.empty()) {
3130 param = occParam + "ShapeAnnotationVisibleItems";
3131 ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3134 } // object iterator
3136 } // for (viewManagers)
3138 // store shape annotation and dimension attributes of objects:
3139 // since the displayed object always persists in property map, we remember the object entries
3140 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3141 const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3142 const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3143 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3144 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3146 std::string aStudyEntry = (*aEntryIt).toUtf8().data();
3147 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3149 // store dimension parameters
3150 GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3151 if ( aDimensions.GetNumber() != 0 ) {
3152 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toUtf8().data() );
3155 _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3156 const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3157 if ( !aShapeAnnAttr.IsNull() ) {
3158 ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toUtf8().data() );
3164 * \brief Restore visual parameters
3166 * This method is called after the study document is opened.
3167 * Restore visual parameters from AttributeParameter attribute(s)
3169 void GeometryGUI::restoreVisualParameters (int savePoint)
3171 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3172 if (!appStudy || !appStudy->studyDS())
3174 _PTR(Study) studyDS = appStudy->studyDS();
3176 // componentName is used for encoding of entries when storing them in IParameters
3177 std::string componentName = myComponentGeom->ComponentDataType();
3178 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3179 //if (!aSComponent) return;
3182 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3183 componentName.c_str(),
3185 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3187 std::vector<std::string> entries = ip->getEntries();
3189 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3191 // entry is a normal entry - it should be "decoded" (setting base address of component)
3192 QString entry (ip->decodeEntry(*entIt).c_str());
3194 // Check that the entry corresponds to a real object in the Study
3195 // as the object may be deleted or modified after the visual state is saved.
3196 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
3197 if (!so) continue; //Skip the not existent entry
3199 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3200 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3202 std::vector<std::string>::iterator namesIt = paramNames.begin();
3203 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3205 // actors are stored in a map after displaying of them for
3206 // quicker access in the future: map < viewID to actor >
3207 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
3208 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3210 QString viewerTypStr;
3211 QString viewIndexStr;
3213 QVector<PropMap> aListOfMap;
3215 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3217 // visual parameters are stored in strings as follows:
3218 // 1) ViewerType_ViewIndex_ParamName
3219 // 2) ViewerType_ParamName (shared for GEOM module)
3220 // '_' is used as separator and should not be used in viewer type or parameter names.
3221 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3223 bool isShared = lst.size() == 2;
3224 bool isViewer = lst.size() == 3;
3225 if ( !isShared && !isViewer )
3230 // shared visual parameters
3233 QString aParamNameStr( lst[1] );
3234 QString aValuesStr( (*valuesIt).c_str() );
3236 // shared dimension properties are stored as attribute
3237 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3239 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3240 aDimensionProp.SaveToAttribute( entry.toUtf8().data() );
3242 else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3244 Handle(GEOMGUI_AnnotationAttrs) anAttr =
3245 GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3247 anAttr->ImportFromPropertyString( aValuesStr );
3253 // per view visual parameters
3254 viewerTypStr = lst[0];
3255 viewIndexStr = lst[1];
3256 QString paramNameStr = lst[2];
3259 viewIndex = viewIndexStr.toUInt(&ok);
3260 if (!ok) // bad conversion of view index to integer
3263 if ((viewIndex + 1) > aListOfMap.count()) {
3264 aListOfMap.resize(viewIndex + 1);
3267 QString val((*valuesIt).c_str());
3268 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3269 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3270 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3271 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3272 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3273 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3274 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3275 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3276 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3277 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3278 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3279 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3280 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3281 QStringList rgb = val.split(GEOM::subSectionSeparator());
3282 if (rgb.count() == 3) {
3283 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3284 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3286 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3287 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3288 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3289 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3290 } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3291 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3292 } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3293 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3294 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3295 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3296 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3297 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3298 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3299 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3300 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3301 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3302 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3303 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3304 } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3305 aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3308 } // for names/parameters iterator
3310 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3312 for (int index = 0; index < aListOfMap.count(); index++) {
3313 appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3315 //Get Visibility property of the current PropMap
3316 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3317 SUIT_ViewManager* vman = lst.at(index);
3318 SUIT_ViewModel* vmodel = vman->getViewModel();
3319 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3320 displayer()->Display(entry, true, aView);
3322 if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3323 PropMap& aProps = aListOfMap[index];
3324 if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3325 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3326 GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3331 } // for entries iterator
3333 // update all VTK and OCC views
3334 QList<SUIT_ViewManager*> lst;
3335 getApp()->viewManagers(lst);
3336 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3337 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3340 if (vmodel->getType() == SVTK_Viewer::Type()) {
3341 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3342 vtkView->getRenderer()->ResetCameraClippingRange();
3345 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3346 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3347 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3353 if ( myTextTreeWdg ) {
3354 myTextTreeWdg->updateTree();
3358 // Compute current name mode of the viewer
3359 void UpdateNameMode( SalomeApp_Application* app )
3361 bool isMode = false;
3362 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3363 SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3364 GEOM_Displayer displayer;
3365 int aMgrId = viewWindow->getViewManager()->getGlobalId();
3367 SALOME_View* window = displayer.GetActiveView();
3368 if ( !window ) return;
3370 SALOME_ListIO anIOlst;
3371 window->GetVisible( anIOlst );
3373 for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3374 Handle( SALOME_InteractiveObject ) io = It.Value();
3375 QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3376 bool isIONameMode = v.isValid() ? v.toBool() : false;
3380 viewWindow->setProperty( "NameMode", isMode );
3383 void GeometryGUI::onViewAboutToShow()
3385 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3386 QAction* a = action( GEOMOp::OpSwitchVectors );
3387 QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3388 QAction* aNameAction = action( GEOMOp::OpSwitchName );
3390 a->setEnabled(true);
3391 bool vmode = window->property("VectorsMode").toBool();
3392 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3393 aVerticesAction->setEnabled(true);
3394 vmode = window->property("VerticesMode").toBool();
3395 aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3396 UpdateNameMode( getApp() );
3397 aNameAction->setEnabled(true);
3398 vmode = window->property("NameMode").toBool();
3399 aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3401 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3402 a->setEnabled(false);
3403 aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3404 aVerticesAction->setEnabled(false);
3405 aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3406 aNameAction->setEnabled(false);
3411 \brief Return action by id
3412 \param id identifier of the action
3415 QAction* GeometryGUI::getAction(const int id) {
3420 \brief GEOM module message handler
3422 This method can be re-implemented in the subclasses.
3423 This is a GEOM module message handler.
3425 \param msg the message received.
3427 void GeometryGUI::message(const QString& msg)
3430 QStringList data = msg.split("/");
3431 const int nbStrings = data.count();
3433 if (nbStrings > 0) {
3434 if (data[0] == "modified") {
3436 QString anIOR = nbStrings > 1 ? data[1] : QString();
3438 if ( anIOR.isEmpty() ) {
3442 // Get the geom object.
3443 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3445 // Clear the shape buffer
3446 GeometryGUI::ClearShapeBuffer (anObj);
3452 \brief Clears the shape buffer.
3454 This is a static method. It clears the shape buffer.
3456 \param theObj the object
3458 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3460 if ( CORBA::is_nil( theObj ) )
3463 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3464 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3465 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3467 SalomeApp_Application* app =
3468 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3469 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3474 _PTR(Study) aStudy = appStudy->studyDS();
3479 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3483 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3484 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3485 _PTR(GenericAttribute) anAttr;
3486 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3487 _PTR(AttributeIOR) anIOR ( anAttr );
3488 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3489 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3495 \brief Returns the object from IOR.
3497 This is a static method. It returns the object from its IOR.
3499 \param IOR object IOR
3500 \return GEOM object.
3502 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3504 GEOM::GEOM_Object_var geomObj;
3505 if ( !IOR.isEmpty() ) {
3506 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3507 ( IOR.toLatin1().constData() );
3508 if ( !CORBA::is_nil( corbaObj ) )
3509 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3511 return geomObj._retn();
3515 \brief Returns IOR of the object.
3517 This is a static method. It returns the object's IOR.
3519 \param object the GEOM object.
3520 \return object's IOR.
3522 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3525 if ( !CORBA::is_nil( object ) ) {
3526 CORBA::String_var anIOR =
3527 SalomeApp_Application::orb()->object_to_string( object );
3534 \brief Check if this object is can't be renamed in place
3536 This method can be re-implemented in the subclasses.
3537 Return true in case if object isn't reference or component (module root).
3539 \param entry column id
3540 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3542 bool GeometryGUI::renameAllowed( const QString& entry) const {
3544 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3545 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3546 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3548 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3552 Rename object by entry.
3553 \param entry entry of the object
3554 \param name new name of the object
3555 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3557 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3559 bool result = false;
3561 SalomeApp_Application* app =
3562 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3563 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3568 _PTR(Study) aStudy = appStudy->studyDS();
3573 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3575 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3579 _PTR(SObject) obj ( aStudy->FindObjectID(qUtf8Printable(entry)) );
3580 _PTR(GenericAttribute) anAttr;
3582 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3583 _PTR(AttributeName) aName (anAttr);
3585 aName->SetValue( name.toUtf8().data() ); // rename the SObject
3586 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3587 if (!CORBA::is_nil(anObj)) {
3588 anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
3589 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3590 emit SignalTextTreeRenameObject( entry );
3598 void GeometryGUI::updateMaterials()
3600 LightApp_Preferences* pref = preferences();
3602 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3603 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3604 if ( !materials.contains( currentMaterial ) )
3605 // user material set as default in the preferences, might be removed
3606 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3608 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3610 setPreferenceProperty( prefItem->id(),
3611 "strings", materials );
3612 prefItem->retrieve();
3618 \brief Check if the module allows "drag" operation of its objects.
3620 Overloaded from LightApp_Module class.
3622 This function is a part of the general drag-n-drop mechanism.
3623 The goal of this function is to check data object passed as a parameter
3624 and decide if it can be dragged or no.
3626 \param what data object being tested for drag operation
3627 \return \c true if module allows dragging of the specified object
3628 \sa isDropAccepted(), dropObjects()
3630 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3632 // we allow dragging object under root and object from folder
3633 int aLevel = what->level();
3634 bool anObjectInFolder = false;
3636 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3638 _PTR(SObject) aSO = dataObj->object();
3640 _PTR(GenericAttribute) anAttr;
3641 _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3642 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3643 _PTR(AttributeLocalID) aLocalID( anAttr );
3644 anObjectInFolder = aLocalID->Value() == 999;
3649 return aLevel == 2 || anObjectInFolder;
3653 \brief Check if the module allows "drop" operation on the given object.
3655 Overloaded from LightApp_Module class.
3657 This function is a part of the general drag-n-drop mechanism.
3658 The goal of this function is to check data object passed as a parameter
3659 and decide if it can be used as a target for the "drop" operation.
3660 The processing of the drop operation itself is done in the dropObjects() function.
3662 \param where target data object
3663 \return \c true if module supports dropping on the \a where data object
3664 \sa isDraggable(), dropObjects()
3666 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3668 // we allow dropping into folder and top-level GEOM object
3669 int aLevel = where->level();
3670 bool isFolder = false;
3672 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3674 _PTR(SObject) aSO = dataObj->object();
3676 _PTR(GenericAttribute) anAttr;
3677 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3678 _PTR(AttributeLocalID) aLocalID( anAttr );
3679 isFolder = aLocalID->Value() == 999;
3684 return aLevel == 1 || isFolder;
3688 \brief Complete drag-n-drop operation.
3690 Overloaded from LightApp_Module class.
3692 This function is a part of the general drag-n-drop mechanism.
3693 Its goal is to handle dropping of the objects being dragged according
3694 to the chosen operation (move). The dropping is performed in the
3695 context of the parent data object \a where and the \a row (position in the
3696 children index) at which the data should be dropped. If \a row is equal to -1,
3697 this means that objects are added to the end of the children list.
3699 \param what objects being dropped
3700 \param where target data object
3701 \param row child index at which the drop operation is performed
3702 \param action drag-n-drop operation (Qt::DropAction) - move
3704 \sa isDraggable(), isDropAccepted()
3706 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3707 const int row, Qt::DropAction action )
3709 if (action != Qt::CopyAction && action != Qt::MoveAction)
3710 return; // unsupported action
3712 // get parent object
3713 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3714 if ( !dataObj ) return; // wrong parent
3715 _PTR(SObject) parentObj = dataObj->object();
3717 // Find the current Study and StudyBuilder
3718 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3719 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3720 // collect all parents of the target node
3721 QStringList parentIDs;
3722 _PTR(SObject) parent = parentObj;
3723 while( !parent->IsNull() ) {
3724 parentIDs << parent->GetID().c_str();
3725 parent = aUseCaseBuilder->GetFather(parent);
3728 // collect objects being dropped
3729 GEOM::object_list_var objects = new GEOM::object_list();
3730 objects->length( what.count() );
3732 for ( int i = 0; i < what.count(); i++ ) {
3733 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3734 if ( !dataObj ) continue; // skip wrong objects
3735 _PTR(SObject) sobj = dataObj->object();
3736 // check that dropped object is not a parent of target object
3737 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3738 return; // it's not allowed to move node into it's child
3740 objects[i] = _CAST(SObject, sobj)->GetSObject();
3743 objects->length( count );
3745 // call engine function
3746 GetGeomGen()->Move( objects.in(), // what
3747 _CAST(SObject, parentObj)->GetSObject(), // where
3750 // update Object browser
3751 getApp()->updateObjectBrowser( false );
3754 void GeometryGUI::emitDimensionsUpdated( QString entry )
3756 emit DimensionsUpdated( entry );
3759 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3761 emit SignalAnnotationsUpdated( entry );