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"
44 #include "GEOM_Component_Generator.hxx"
46 #include "GEOM_Actor.h"
48 #include <Material_ResourceMgr.h>
49 #include <Material_Model.h>
51 #include <Basics_OCCTVersion.hxx>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_MessageBox.h>
55 #include <SUIT_ResourceMgr.h>
56 #include <SUIT_Session.h>
57 #include <SUIT_ViewManager.h>
59 #include <OCCViewer_ViewWindow.h>
60 #include <OCCViewer_ViewPort3d.h>
61 #include <OCCViewer_ViewModel.h>
62 #include <OCCViewer_ViewManager.h>
64 #include <SOCC_ViewModel.h>
65 #include <SOCC_ViewWindow.h>
67 #include <SVTK_ViewWindow.h>
68 #include <SVTK_RenderWindowInteractor.h>
69 #include <SVTK_InteractorStyle.h>
70 #include <SVTK_ViewModel.h>
72 #ifndef DISABLE_GRAPHICSVIEW
73 #include <GraphicsView_Viewer.h>
76 #include <SalomeApp_Application.h>
77 #include <SalomeApp_DataObject.h>
78 #include <SalomeApp_Study.h>
79 #include <SalomeApp_Tools.h>
81 #include <LightApp_SelectionMgr.h>
82 #include <LightApp_VTKSelector.h>
83 #include <LightApp_DataObject.h>
84 #include <LightApp_Preferences.h>
86 #include <SALOME_LifeCycleCORBA.hxx>
87 #include <SALOME_ListIO.hxx>
89 #include <SALOMEDSClient_ClientFactory.hxx>
90 #include <SALOMEDSClient_IParameters.hxx>
91 #include "SALOME_KernelServices.hxx"
93 #include <SALOMEDS_SObject.hxx>
95 #include <QtxFontEdit.h>
96 #include <QtxInfoPanel.h>
107 #include <QSignalMapper>
108 #include <QFontDatabase>
110 #include <AIS_ListOfInteractive.hxx>
111 #include <AIS_ListIteratorOfListOfInteractive.hxx>
112 #include <Prs3d_Drawer.hxx>
113 #include <Prs3d_IsoAspect.hxx>
114 #include <Aspect_TypeOfMarker.hxx>
115 #include <OSD_SharedLibrary.hxx>
116 #include <NCollection_DataMap.hxx>
118 #include <TColStd_HArray1OfByte.hxx>
119 #include <TColStd_SequenceOfHAsciiString.hxx>
121 #include <utilities.h>
123 #include <vtkCamera.h>
124 #include <vtkRenderer.h>
126 #include <Standard_Failure.hxx>
127 #include <Standard_ErrorHandler.hxx>
129 #include <Font_SystemFont.hxx>
130 #include <Font_FontMgr.hxx>
131 #include <TCollection_HAsciiString.hxx>
133 #include "GEOM_version.h"
134 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
137 Standard_EXPORT CAM_Module* createModule() {
138 return new GeometryGUI();
141 Standard_EXPORT char* getModuleVersion() {
142 return (char*)GEOM_VERSION_STR;
146 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
148 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
150 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
151 if (CORBA::is_nil(myComponentGeom))
153 return GeometryGUI::myComponentGeom;
156 bool GeometryGUI::InitGeomGen()
159 if ( CORBA::is_nil( myComponentGeom ) ) return false;
163 //=======================================================================
164 // function : ClientSObjectToObject
166 //=======================================================================
167 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
169 _PTR(GenericAttribute) anAttr;
170 CORBA::Object_var anObj;
172 std::string aValue = theSObject->GetIOR();
173 if (strcmp(aValue.c_str(), "") != 0) {
174 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
175 anObj = anORB->string_to_object(aValue.c_str());
178 INFOS("ClientSObjectToObject - Unknown exception has occurred!!!");
180 return anObj._retn();
182 //=================================================================================
183 // function : IsInGeomComponent
184 // purpose : Check if an SObject is under GEOM component
185 //=================================================================================
186 bool GeometryGUI::IsInGeomComponent( _PTR(SObject) sobject )
189 if ( _PTR(SComponent) aComp = sobject->GetFatherComponent() )
190 return aComp->ComponentDataType() == "GEOM";
194 //=======================================================================
195 // function : GetStudy
197 //=======================================================================
198 SALOMEDS::Study_var GeometryGUI::getStudyServant()
200 SALOME_NamingService_Abstract *aNamingService = SalomeApp_Application::namingService();
201 CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
202 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
203 return aStudy._retn();
206 void GeometryGUI::Modified (bool theIsUpdateActions)
208 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
209 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
210 appStudy->Modified();
211 if ( theIsUpdateActions )
212 app->updateActions();
217 //=======================================================================
218 // function : GeometryGUI::GeometryGUI()
219 // purpose : Constructor
220 //=======================================================================
221 GeometryGUI::GeometryGUI() : SalomeApp_Module( "GEOM" )
223 if ( CORBA::is_nil( myComponentGeom ) )
225 SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
226 Engines::EngineComponent_var comp;
227 if( dynamic_cast<SALOME_NamingService *>(ns) )
229 comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
233 comp = RetrieveGEOMInstance();
234 CORBA::Object_var comp2 = CORBA::Object::_narrow(comp);
235 KERNEL::RegisterCompo("GEOM",comp2);
237 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
240 myActiveDialogBox = 0;
242 gp_Pnt origin = gp_Pnt(0., 0., 0.);
243 gp_Dir direction = gp_Dir(0., 0., 1.);
244 myWorkingPlane = gp_Ax3(origin, direction);
247 myLocalSelectionMode = GEOM_ALLOBJECTS;
249 myCreationInfoWdg = 0;
253 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ), Qt::UniqueConnection );
255 Q_INIT_RESOURCE( GEOMGUI );
258 //=======================================================================
259 // function : GeometryGUI::~GeometryGUI()
260 // purpose : Destructor
261 //=======================================================================
262 GeometryGUI::~GeometryGUI()
264 while (!myOCCSelectors.isEmpty())
265 delete myOCCSelectors.takeFirst();
267 while (!myVTKSelectors.isEmpty())
268 delete myVTKSelectors.takeFirst();
270 qDeleteAll(myGUIMap);
273 //=======================================================================
274 // function : GeometryGUI::getLibrary()
275 // purpose : get or load GUI library by name [ internal ]
276 //=======================================================================
277 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
278 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
280 if ( !myGUIMap.contains( libraryName ) ) {
281 // try to load library if it is not loaded yet
283 QString dirs = Qtx::getenv( "PATH" );
284 #elif defined(__APPLE__)
285 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
287 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
295 if ( !dirs.isEmpty() ) {
296 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
297 QListIterator<QString> it( dirList ); it.toBack();
298 while ( it.hasPrevious() ) {
299 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
301 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
302 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
304 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
305 continue; // continue search further
307 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
308 if ( osdF != NULL ) {
309 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
310 GEOMGUI* libGUI = (*func)( this );
312 myGUIMap[ libraryName ] = libGUI;
313 break; // found and loaded!
320 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
323 //=======================================================================
324 // function : GeometryGUI::getPluginLibrary()
325 // purpose : get or load GUI Plugin library by name [ internal ]
326 //=======================================================================
327 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
328 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
330 if ( !myGUIMap.contains( libraryName ) ) {
331 // try to load library if it is not loaded yet
334 QString dirs = Qtx::getenv( "PATH" );
335 #elif defined(__APPLE__)
336 QString dirs = Qtx::getenv( "DYLD_LIBRARY_PATH" );
338 QString dirs = Qtx::getenv( "LD_LIBRARY_PATH" );
346 if ( !dirs.isEmpty() ) {
347 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
348 QListIterator<QString> it( dirList ); it.toBack();
349 while ( it.hasPrevious() ) {
350 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
352 OSD_SharedLibrary aSharedLibrary( fi.fileName().toUtf8().constData() );
353 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
355 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
356 continue; // continue search further
358 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
359 if ( osdF != NULL ) {
360 PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
361 GEOMPluginGUI* libGUI = (*func)( this );
363 myGUIMap[ libraryName ] = libGUI;
364 break; // found and loaded!
371 return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
374 //=======================================================================
375 // function : GeometryGUI::ActiveWorkingPlane()
376 // purpose : Activate Working Plane View
377 //=======================================================================
378 void GeometryGUI::ActiveWorkingPlane()
380 gp_Dir DZ = myWorkingPlane.Direction();
381 gp_Dir DY = myWorkingPlane.YDirection();
383 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
384 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
385 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
388 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
390 Handle(V3d_View) view3d = vw->getViewPort()->getView();
392 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
393 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
397 else if ( ViewVTK ) {
398 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
400 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
402 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
403 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
404 camera->SetFocalPoint(0,0,0);
411 //=======================================================================
412 // function : GeometryGUI::SetActiveDialogBox()
413 // purpose : Set active dialog box
414 //=======================================================================
415 GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
417 if ( !myAnnotationMgr )
418 myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
419 return myAnnotationMgr;
422 //=======================================================================
423 // function : GeometryGUI::SetActiveDialogBox()
424 // purpose : Set active dialog box
425 //=======================================================================
426 GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
428 return myTextTreeWdg;
431 //=======================================================================
432 // function : GeometryGUI::SetActiveDialogBox()
433 // purpose : Set active dialog box
434 //=======================================================================
435 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
437 myActiveDialogBox = (QDialog*)aDlg;
440 //=======================================================================
441 // function : GeometryGUI::EmitSignalDeactivateDialog()
442 // purpose : Emit a signal to deactivate the active dialog Box
443 //=======================================================================
444 void GeometryGUI::EmitSignalDeactivateDialog()
446 emit SignalDeactivateActiveDialog();
449 //=======================================================================
450 // function : GeometryGUI::EmitSignalCloseAllDialogs()
451 // purpose : Emit a signal to close all non modal dialogs box
452 //=======================================================================
453 void GeometryGUI::EmitSignalCloseAllDialogs()
455 emit SignalCloseAllDialogs();
458 //=======================================================================
459 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
460 // purpose : Emit a signal to inform that default real spin box step has
462 //=======================================================================
463 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
465 emit SignalDefaultStepValueChanged(newVal);
468 //=======================================================================
469 // function : GeometryGUI::OnGUIEvent()
470 // purpose : common slot for all menu/toolbar actions
471 //=======================================================================
472 void GeometryGUI::OnGUIEvent()
474 const QObject* obj = sender();
475 if ( !obj || !obj->inherits( "QAction" ) )
477 int id = actionId((QAction*)obj);
482 //=======================================================================
483 // function : GeometryGUI::OnGUIEvent()
484 // purpose : manage all events on GUI [static]
485 //=======================================================================
486 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
488 SUIT_Application* anApp = application();
490 SUIT_Desktop* desk = anApp->desktop();
492 // check type of the active viewframe
493 SUIT_ViewWindow* window = desk->activeWindow();
494 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
495 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
496 #ifndef DISABLE_GRAPHICSVIEW
497 bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
501 // if current viewframe is not of OCC and not of VTK type - return immediately
502 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
503 QList<int> NotViewerDependentCommands;
504 NotViewerDependentCommands << GEOMOp::OpDelete
506 << GEOMOp::OpShowOnly
507 << GEOMOp::OpShowOnlyChildren
508 << GEOMOp::OpDiscloseChildren
509 << GEOMOp::OpConcealChildren
510 << GEOMOp::OpUnpublishObject
511 << GEOMOp::OpPublishObject
512 << GEOMOp::OpPointMarker
513 << GEOMOp::OpCreateFolder
514 << GEOMOp::OpSortChildren;
515 if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
516 // activate OCC viewer
517 getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
520 // fix for IPAL9103, point 2
521 if ( CORBA::is_nil( GetGeomGen() ) ) {
522 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
527 // find corresponding GUI library
529 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
530 createOriginAndBaseVectors(); // internal operation
532 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
533 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
534 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
535 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
536 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
537 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
538 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
539 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
540 case GEOMOp::OpDelete: // MENU EDIT - DELETE
541 #ifndef DISABLE_PYCONSOLE
542 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
544 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
545 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
546 case GEOMOp::OpColor: // POPUP MENU - COLOR
547 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
548 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
549 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
550 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
551 case GEOMOp::OpIsos: // POPUP MENU - ISOS
552 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
553 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
554 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
555 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
556 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
557 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
558 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
559 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
560 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
561 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
562 case GEOMOp::OpMaterialMenu: // POPUP MENU - MATERIAL PROPERTIES (sub-menu)
563 case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - <SOME MATERIAL>
564 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES (sub-menu) - CUSTOM...
565 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
566 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
567 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
568 case GEOMOp::OpClsBringToFront: //
569 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
570 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
571 #ifndef DISABLE_GRAPHICSVIEW
572 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
574 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
575 libName = "GEOMToolsGUI";
577 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
578 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
579 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
580 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
581 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
582 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
583 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
584 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
585 case GEOMOp::OpHide: // MENU VIEW - ERASE
586 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
587 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
588 case GEOMOp::OpSwitchVertices: // MENU VIEW - VERTICES MODE
589 case GEOMOp::OpSwitchName: // MENU VIEW - VERTICES MODE
590 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
591 case GEOMOp::OpShading: // POPUP MENU - SHADING
592 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
593 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
594 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
595 case GEOMOp::OpVertices: // POPUP MENU - VERTICES
596 case GEOMOp::OpShowName: // POPUP MENU - SHOW NAME
597 libName = "DisplayGUI";
599 case GEOMOp::OpPoint: // MENU BASIC - POINT
600 case GEOMOp::OpLine: // MENU BASIC - LINE
601 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
602 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
603 case GEOMOp::OpArc: // MENU BASIC - ARC
604 case GEOMOp::OpVector: // MENU BASIC - VECTOR
605 case GEOMOp::OpPlane: // MENU BASIC - PLANE
606 case GEOMOp::OpCurve: // MENU BASIC - CURVE
607 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
608 libName = "BasicGUI";
610 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
611 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
612 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
613 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
614 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
615 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
616 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
617 libName = "PrimitiveGUI";
619 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
620 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
621 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
622 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
623 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
624 case GEOMOp::OpThickness: // MENU GENERATION - THICKNESS
625 libName = "GenerationGUI";
627 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
628 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
629 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
630 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
631 case GEOMOp::OpSurfaceFromFace: // MENU ENTITY - SURFACE FROM FACE
633 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
635 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
636 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
637 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
638 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
639 case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
640 libName = "EntityGUI";
642 case GEOMOp::OpEdge: // MENU BUILD - EDGE
643 case GEOMOp::OpWire: // MENU BUILD - WIRE
644 case GEOMOp::OpFace: // MENU BUILD - FACE
645 case GEOMOp::OpShell: // MENU BUILD - SHELL
646 case GEOMOp::OpSolid: // MENU BUILD - SOLID
647 case GEOMOp::OpCompound: // MENU BUILD - COMPOUND
648 libName = "BuildGUI";
650 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
651 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
652 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
653 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
654 libName = "BooleanGUI";
656 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
657 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
658 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
659 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
660 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
661 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
662 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
663 case GEOMOp::OpProjOnCyl: // MENU TRANSFORMATION - PROJECTION ON CYLINDER
664 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
665 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
666 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
667 case GEOMOp::OpExtension: // MENU TRANSFORMATION - EXTENSION
668 libName = "TransformationGUI";
670 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
671 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
672 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
673 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
674 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
675 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
676 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
677 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
678 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
679 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
680 case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA
681 case GEOMOp::OpExtraction: // MENU OPERATION - EXTRACT AND REBUILD
682 libName = "OperationGUI";
684 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
685 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
686 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
687 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
688 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
689 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
690 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
691 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
692 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
693 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
694 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
695 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
696 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
697 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
698 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
699 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
700 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
701 case GEOMOp::OpInspectObj: // MENU REPAIR - INSPECT OBJECT
702 libName = "RepairGUI";
704 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
705 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
706 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
707 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
708 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
709 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
710 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
711 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
712 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
713 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
714 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
715 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
716 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
717 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
718 case GEOMOp::OpFastCheckInters: // MENU MEASURE - FAST CHECK INTERSECTIONS
719 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
720 case GEOMOp::OpAnnotation: // MENU MEASURE - ANNOTATION
721 case GEOMOp::OpEditAnnotation: // POPUP MENU - EDIT ANNOTATION
722 case GEOMOp::OpDeleteAnnotation: // POPUP MENU - DELETE ANNOTATION
723 #ifndef DISABLE_PLOT2DVIEWER
724 case GEOMOp::OpShapeStatistics: // MENU MEASURE - SHAPE STATISTICS
726 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
727 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
728 case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
729 case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
730 libName = "MeasureGUI";
732 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
733 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
734 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
735 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
736 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
737 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
738 libName = "GroupGUI";
740 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
741 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
742 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
743 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
744 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
745 libName = "BlocksGUI";
747 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
748 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
749 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
750 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
751 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
752 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
753 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
754 //libName = "AdvancedGUI";
757 if (myPluginActions.contains(id)) {
758 libName = myPluginActions[id].first;
760 GEOMPluginGUI* library = 0;
761 if ( !libName.isEmpty() ) {
763 libName = libName + ".dll";
764 #elif defined(__APPLE__)
765 libName = QString( "lib" ) + libName + ".dylib";
767 libName = QString( "lib" ) + libName + ".so";
769 library = getPluginLibrary( libName );
772 // call method of corresponding GUI library
774 //QString action ("%1");
775 //action = action.arg(id);
777 //if( !theParam.isValid() )
778 library->OnGUIEvent( myPluginActions[id].second, desk );
780 // library->OnGUIEvent( id, desk, theParam);
783 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
785 updateCreationInfo();
791 GEOMGUI* library = 0;
792 if ( !libName.isEmpty() ) {
794 libName = libName + ".dll";
795 #elif defined(__APPLE__)
796 libName = QString( "lib" ) + libName + ".dylib";
798 libName = QString( "lib" ) + libName + ".so";
800 library = getLibrary( libName );
803 // call method of corresponding GUI library
805 if( !theParam.isValid() )
806 library->OnGUIEvent( id, desk );
808 library->OnGUIEvent( id, desk, theParam);
811 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
813 updateCreationInfo();
816 //=================================================================================
817 // function : GeometryGUI::activateOperation()
819 //=================================================================================
820 bool GeometryGUI::activateOperation( int actionId )
822 OnGUIEvent(actionId);
826 //=================================================================================
827 // function : GeometryGUI::activateOperation()
829 //=================================================================================
830 bool GeometryGUI::activateOperation( const QString& actionId )
834 int id = actionId.toInt(&isOk);
841 //=================================================================================
842 // function : GeometryGUI::activateOperation()
844 //=================================================================================
845 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
849 QString pluginLib = plugin;
850 // TODO: if <plugin> is a plugin name, find plugin library name
851 if (myPluginLibs.contains(plugin))
852 pluginLib = myPluginLibs[plugin];
854 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
855 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
856 const PluginAction& anAction = actionsIter.value();
857 if (anAction.first == pluginLib && anAction.second == actionId) {
858 // activate operation
859 OnGUIEvent(actionsIter.key());
867 //=================================================================================
868 // function : GeometryGUI::OnKeyPress()
869 // purpose : Called when any key is pressed by user [static]
870 //=================================================================================
871 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
873 if ( !application() )
875 foreach ( GEOMGUI* lib, myGUIMap )
876 lib->OnKeyPress( e, application()->desktop(), w );
879 //=================================================================================
880 // function : GeometryGUI::OnMouseMove()
881 // purpose : Manages mouse move events [static]
882 //=================================================================================
883 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
885 if ( !application() )
887 foreach ( GEOMGUI* lib, myGUIMap )
888 lib->OnMouseMove( e, application()->desktop(), w );
891 //=================================================================================
892 // function : GeometryGUI::OnMouseRelease()
893 // purpose : Manages mouse release events [static]
894 //=================================================================================
895 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
897 if ( !application() )
899 foreach ( GEOMGUI* lib, myGUIMap )
900 lib->OnMouseRelease( e, application()->desktop(), w );
903 //=================================================================================
904 // function : GeometryGUI::OnMousePress()
905 // purpose : Manage mouse press events [static]
906 //=================================================================================
907 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
909 if ( !application() )
911 foreach ( GEOMGUI* lib, myGUIMap )
912 lib->OnMousePress( e, application()->desktop(), w );
915 //=======================================================================
916 // function : createGeomAction
918 //=======================================================================
919 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
920 const int accel, const bool toggle, const QString& shortcutAction )
922 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
923 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
924 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
926 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
928 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
929 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
931 application()->desktop(),
933 this, SLOT( OnGUIEvent() ),
937 //=======================================================================
938 // function : createOriginAndBaseVectors
940 //=======================================================================
941 void GeometryGUI::createOriginAndBaseVectors()
943 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
944 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
946 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
950 if ( !CORBA::is_nil( GetGeomGen() ) ) {
951 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
952 if ( !aBasicOperations->_is_nil() ) {
953 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
954 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
955 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
956 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
957 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
958 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
960 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
961 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
962 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
963 GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
964 anOrigin->UnRegister();
968 aBasicOperations->UnRegister();
970 getApp()->updateObjectBrowser( true );
976 //=======================================================================
977 // function : GeometryGUI::initialize()
978 // purpose : Called when GEOM module is created
979 //=======================================================================
980 void GeometryGUI::initialize( CAM_Application* app )
982 SalomeApp_Module::initialize( app );
984 // ----- create actions --------------
986 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
988 createGeomAction( GEOMOp::OpPoint, "POINT" );
989 createGeomAction( GEOMOp::OpLine, "LINE" );
990 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
991 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
992 createGeomAction( GEOMOp::OpArc, "ARC" );
993 createGeomAction( GEOMOp::OpCurve, "CURVE" );
994 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
995 createGeomAction( GEOMOp::OpVector, "VECTOR" );
996 createGeomAction( GEOMOp::OpPlane, "PLANE" );
997 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
998 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
999 createGeomAction( GEOMOp::OpSurfaceFromFace, "SURFACE_FROM_FACE" );
1001 createGeomAction( GEOMOp::OpBox, "BOX" );
1002 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
1003 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
1004 createGeomAction( GEOMOp::OpTorus, "TORUS" );
1005 createGeomAction( GEOMOp::OpCone, "CONE" );
1006 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
1007 createGeomAction( GEOMOp::OpDisk, "DISK" );
1009 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
1010 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
1011 createGeomAction( GEOMOp::OpFilling, "FILLING" );
1012 createGeomAction( GEOMOp::OpPipe, "PIPE" );
1013 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
1014 createGeomAction( GEOMOp::OpThickness, "THICKNESS" );
1016 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
1017 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
1018 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
1019 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
1020 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
1022 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
1023 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
1025 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
1027 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
1028 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
1030 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
1031 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
1032 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
1034 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1036 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1037 createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1039 createGeomAction( GEOMOp::OpEdge, "EDGE" );
1040 createGeomAction( GEOMOp::OpWire, "WIRE" );
1041 createGeomAction( GEOMOp::OpFace, "FACE" );
1042 createGeomAction( GEOMOp::OpShell, "SHELL" );
1043 createGeomAction( GEOMOp::OpSolid, "SOLID" );
1044 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
1046 createGeomAction( GEOMOp::OpFuse, "FUSE" );
1047 createGeomAction( GEOMOp::OpCommon, "COMMON" );
1048 createGeomAction( GEOMOp::OpCut, "CUT" );
1049 createGeomAction( GEOMOp::OpSection, "SECTION" );
1051 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
1052 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
1053 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
1054 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
1055 createGeomAction( GEOMOp::OpScale, "SCALE" );
1056 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
1057 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
1058 createGeomAction( GEOMOp::OpProjOnCyl, "PROJ_ON_CYL" );
1059 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1060 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
1061 createGeomAction( GEOMOp::OpExtension, "EXTENSION" );
1063 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
1064 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
1065 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
1066 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
1067 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
1068 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
1069 createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" );
1070 createGeomAction( GEOMOp::OpExtraction, "EXTRACTION" );
1071 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
1072 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
1073 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
1074 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
1076 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1077 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
1078 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
1080 createGeomAction( GEOMOp::OpSewing, "SEWING" );
1081 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
1082 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
1083 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
1084 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
1085 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1086 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1087 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1088 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1089 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1090 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1091 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1092 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1093 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1094 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1095 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1096 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1097 createGeomAction( GEOMOp::OpInspectObj, "INSPECT_OBJECT" );
1099 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1100 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1101 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1102 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1103 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1104 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1105 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1106 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1107 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1108 createGeomAction( GEOMOp::OpAnnotation, "ANNOTATION" );
1109 createGeomAction( GEOMOp::OpEditAnnotation, "EDIT_ANNOTATION" );
1110 createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1112 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1113 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1114 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1115 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1116 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1117 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1118 createGeomAction( GEOMOp::OpFastCheckInters, "FAST_CHECK_INTERSECTIONS" );
1119 #ifndef DISABLE_PLOT2DVIEWER
1120 createGeomAction( GEOMOp::OpShapeStatistics, "SHAPE_STATISTICS" );
1123 #ifndef DISABLE_PYCONSOLE
1124 #ifdef _DEBUG_ // PAL16821
1125 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1129 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1130 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1131 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1132 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1133 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1134 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1135 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1136 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1137 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1138 createGeomAction( GEOMOp::OpSwitchVertices, "VERTICES_MODE");
1139 createGeomAction( GEOMOp::OpSwitchName, "NAME_MODE");
1140 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1141 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1142 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1143 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1144 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1145 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1146 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1147 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1148 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1149 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1150 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1151 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1152 createGeomAction( GEOMOp::OpHide, "ERASE" );
1154 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1155 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1156 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1157 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1158 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1159 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1160 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1161 createGeomAction( GEOMOp::OpVertices, "POP_VERTICES", "", 0, true );
1162 createGeomAction( GEOMOp::OpShowName, "POP_SHOW_NAME", "", 0, true );
1163 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1164 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1165 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1166 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1167 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1168 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1169 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1170 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1171 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1172 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1173 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1174 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1175 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1176 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1177 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1178 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1179 createGeomAction( GEOMOp::OpMaterialMenu, "POP_MATERIAL_PROPERTIES");
1180 action(GEOMOp::OpMaterialMenu)->setMenu( new QMenu() );
1181 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1182 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1183 #ifndef DISABLE_GRAPHICSVIEW
1184 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1186 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1187 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1188 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1189 createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1190 createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1192 // Create actions for increase/decrease transparency shortcuts
1193 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1194 "Geometry:Increase transparency");
1195 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1196 "Geometry:Decrease transparency");
1198 // Create actions for increase/decrease number of isolines
1199 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1200 "Geometry:Increase number of isolines");
1201 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1202 "Geometry:Decrease number of isolines");
1204 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1205 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1206 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1207 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1208 //@@ 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 @@//
1210 // ---- create menus --------------------------
1212 /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1214 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1215 createMenu( GEOMOp::OpDelete, editId, -1 );
1217 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1219 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1220 createMenu( GEOMOp::OpPoint, basicId, -1 );
1221 createMenu( GEOMOp::OpLine, basicId, -1 );
1222 createMenu( GEOMOp::OpCircle, basicId, -1 );
1223 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1224 createMenu( GEOMOp::OpArc, basicId, -1 );
1225 createMenu( GEOMOp::OpCurve, basicId, -1 );
1226 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1227 createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1228 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1229 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1230 createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1231 createMenu( separator(), basicId, -1 );
1232 createMenu( GEOMOp::OpVector, basicId, -1 );
1233 createMenu( GEOMOp::OpPlane, basicId, -1 );
1234 createMenu( GEOMOp::OpLCS, basicId, -1 );
1235 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1237 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1238 createMenu( GEOMOp::OpBox, primId, -1 );
1239 createMenu( GEOMOp::OpCylinder, primId, -1 );
1240 createMenu( GEOMOp::OpSphere, primId, -1 );
1241 createMenu( GEOMOp::OpTorus, primId, -1 );
1242 createMenu( GEOMOp::OpCone, primId, -1 );
1243 createMenu( GEOMOp::OpRectangle, primId, -1 );
1244 createMenu( GEOMOp::OpDisk, primId, -1 );
1245 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1247 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1248 createMenu( GEOMOp::OpPrism, genId, -1 );
1249 createMenu( GEOMOp::OpRevolution, genId, -1 );
1250 createMenu( GEOMOp::OpFilling, genId, -1 );
1251 createMenu( GEOMOp::OpPipe, genId, -1 );
1252 createMenu( GEOMOp::OpPipePath, genId, -1 );
1253 createMenu( GEOMOp::OpThickness, genId, -1 );
1255 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1256 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1257 //@@ 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 @@//
1259 createMenu( separator(), newEntId, -1 );
1261 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1262 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1263 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1264 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1265 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1266 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1268 createMenu( separator(), newEntId, -1 );
1270 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1271 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1272 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1274 createMenu( separator(), newEntId, -1 );
1276 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1277 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1278 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1279 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1280 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1282 createMenu( separator(), newEntId, -1 );
1284 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1286 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1287 createMenu( GEOMOp::OpEdge, buildId, -1 );
1288 createMenu( GEOMOp::OpWire, buildId, -1 );
1289 createMenu( GEOMOp::OpFace, buildId, -1 );
1290 createMenu( GEOMOp::OpShell, buildId, -1 );
1291 createMenu( GEOMOp::OpSolid, buildId, -1 );
1292 createMenu( GEOMOp::OpCompound, buildId, -1 );
1294 createMenu( separator(), newEntId, -1 );
1296 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1298 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1301 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1303 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1304 createMenu( GEOMOp::OpFuse, boolId, -1 );
1305 createMenu( GEOMOp::OpCommon, boolId, -1 );
1306 createMenu( GEOMOp::OpCut, boolId, -1 );
1307 createMenu( GEOMOp::OpSection, boolId, -1 );
1309 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1310 createMenu( GEOMOp::OpTranslate, transId, -1 );
1311 createMenu( GEOMOp::OpRotate, transId, -1 );
1312 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1313 createMenu( GEOMOp::OpMirror, transId, -1 );
1314 createMenu( GEOMOp::OpScale, transId, -1 );
1315 createMenu( GEOMOp::OpOffset, transId, -1 );
1316 createMenu( GEOMOp::OpProjection, transId, -1 );
1317 createMenu( GEOMOp::OpExtension, transId, -1 );
1318 createMenu( GEOMOp::OpProjOnCyl, transId, -1 );
1319 createMenu( separator(), transId, -1 );
1320 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1321 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1323 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1324 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1325 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1326 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1328 createMenu( separator(), operId, -1 );
1330 createMenu( GEOMOp::OpPartition, operId, -1 );
1331 createMenu( GEOMOp::OpArchimede, operId, -1 );
1332 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1333 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1334 createMenu( GEOMOp::OpTransferData, operId, -1 );
1335 createMenu( GEOMOp::OpExtraction, operId, -1 );
1337 createMenu( separator(), operId, -1 );
1339 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1340 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1341 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1342 createMenu( GEOMOp::OpChamfer, operId, -1 );
1343 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1344 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1346 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1347 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1348 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1349 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1350 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1351 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1352 createMenu( GEOMOp::OpSewing, repairId, -1 );
1353 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1354 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1355 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1356 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1357 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1358 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1359 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1360 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1361 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1362 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1363 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1365 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1366 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1367 createMenu( GEOMOp::OpProperties, measurId, -1 );
1368 createMenu( separator(), measurId, -1 );
1369 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1370 createMenu( GEOMOp::OpInertia, measurId, -1 );
1371 createMenu( GEOMOp::OpNormale, measurId, -1 );
1372 createMenu( separator(), measurId, -1 );
1373 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1374 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1375 createMenu( separator(), measurId, -1 );
1377 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1378 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1379 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1380 createMenu( GEOMOp::OpAngle, dimId, -1 );
1381 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1383 createMenu( GEOMOp::OpAnnotation, measurId, -1 );
1385 createMenu( separator(), measurId, -1 );
1386 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1387 createMenu( separator(), measurId, -1 );
1388 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1389 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1390 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1391 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1392 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1393 createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1394 createMenu( GEOMOp::OpInspectObj, measurId, -1 );
1395 #ifndef DISABLE_PLOT2DVIEWER
1396 createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1399 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1400 #ifndef DISABLE_PYCONSOLE
1401 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1402 createMenu( separator(), toolsId, -1 );
1403 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1407 createMenu( separator(), toolsId, -1 );
1408 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1409 createMenu( separator(), toolsId, -1 );
1411 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1412 createMenu( separator(), viewId, -1 );
1414 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1415 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1416 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1417 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1418 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1419 createMenu( separator(), dispmodeId, -1 );
1420 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1421 createMenu( GEOMOp::OpSwitchVertices, dispmodeId, -1 );
1422 createMenu( GEOMOp::OpSwitchName, dispmodeId, -1 );
1424 createMenu( separator(), viewId, -1 );
1425 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1426 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1427 createMenu( separator(), viewId, -1 );
1428 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1429 createMenu( separator(), viewId, -1 );
1433 because of these items are accessible through object browser and viewers
1434 we have removed they from main menu
1436 createMenu( GEOMOp::OpShow, viewId, -1 );
1437 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1438 createMenu( GEOMOp::OpHide, viewId, -1 );
1441 // ---- create toolbars --------------------------
1443 int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1444 createTool( GEOMOp::OpPoint, basicTbId );
1445 createTool( GEOMOp::OpLine, basicTbId );
1446 createTool( GEOMOp::OpCircle, basicTbId );
1447 createTool( GEOMOp::OpEllipse, basicTbId );
1448 createTool( GEOMOp::OpArc, basicTbId );
1449 createTool( GEOMOp::OpCurve, basicTbId );
1450 createTool( GEOMOp::OpVector, basicTbId );
1451 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1452 createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
1453 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1454 createTool( GEOMOp::OpIsoline, basicTbId );
1455 createTool( GEOMOp::OpSurfaceFromFace, basicTbId );
1456 createTool( GEOMOp::OpPlane, basicTbId );
1457 createTool( GEOMOp::OpLCS, basicTbId );
1458 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1460 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1461 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1462 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1464 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1465 createTool( GEOMOp::OpBox, primTbId );
1466 createTool( GEOMOp::OpCylinder, primTbId );
1467 createTool( GEOMOp::OpSphere, primTbId );
1468 createTool( GEOMOp::OpTorus, primTbId );
1469 createTool( GEOMOp::OpCone, primTbId );
1470 createTool( GEOMOp::OpRectangle, primTbId );
1471 createTool( GEOMOp::OpDisk, primTbId );
1472 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1474 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1475 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1476 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1478 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1479 createTool( GEOMOp::OpFuse, boolTbId );
1480 createTool( GEOMOp::OpCommon, boolTbId );
1481 createTool( GEOMOp::OpCut, boolTbId );
1482 createTool( GEOMOp::OpSection, boolTbId );
1484 int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1485 createTool( GEOMOp::OpPrism, genTbId );
1486 createTool( GEOMOp::OpRevolution, genTbId );
1487 createTool( GEOMOp::OpFilling, genTbId );
1488 createTool( GEOMOp::OpPipe, genTbId );
1489 createTool( GEOMOp::OpPipePath, genTbId );
1490 createTool( GEOMOp::OpThickness, genTbId );
1492 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1493 createTool( GEOMOp::OpTranslate, transTbId );
1494 createTool( GEOMOp::OpRotate, transTbId );
1495 createTool( GEOMOp::OpChangeLoc, transTbId );
1496 createTool( GEOMOp::OpMirror, transTbId );
1497 createTool( GEOMOp::OpScale, transTbId );
1498 createTool( GEOMOp::OpOffset, transTbId );
1499 createTool( GEOMOp::OpProjection, transTbId );
1500 createTool( GEOMOp::OpExtension, transTbId );
1501 createTool( GEOMOp::OpProjOnCyl, transTbId );
1502 createTool( separator(), transTbId );
1503 createTool( GEOMOp::OpMultiTranslate, transTbId );
1504 createTool( GEOMOp::OpMultiRotate, transTbId );
1506 int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1507 createTool( GEOMOp::OpExplode, operTbId );
1508 createTool( GEOMOp::OpPartition, operTbId );
1509 createTool( GEOMOp::OpArchimede, operTbId );
1510 createTool( GEOMOp::OpShapesOnShape, operTbId );
1511 createTool( GEOMOp::OpSharedShapes, operTbId );
1512 createTool( GEOMOp::OpTransferData, operTbId );
1513 createTool( GEOMOp::OpExtraction, operTbId );
1515 int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1516 createTool( GEOMOp::OpFillet1d, featTbId );
1517 createTool( GEOMOp::OpFillet2d, featTbId );
1518 createTool( GEOMOp::OpFillet3d, featTbId );
1519 createTool( GEOMOp::OpChamfer, featTbId );
1520 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1521 createTool( GEOMOp::OpExtrudedCut, featTbId );
1523 int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1524 createTool( GEOMOp::OpEdge, buildTbId );
1525 createTool( GEOMOp::OpWire, buildTbId );
1526 createTool( GEOMOp::OpFace, buildTbId );
1527 createTool( GEOMOp::OpShell, buildTbId );
1528 createTool( GEOMOp::OpSolid, buildTbId );
1529 createTool( GEOMOp::OpCompound, buildTbId );
1531 int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1532 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1533 createTool( GEOMOp::OpProperties, measureTbId );
1534 createTool( GEOMOp::OpCenterMass, measureTbId );
1535 createTool( GEOMOp::OpInertia, measureTbId );
1536 createTool( GEOMOp::OpNormale, measureTbId );
1537 createTool( separator(), measureTbId );
1538 createTool( GEOMOp::OpBoundingBox, measureTbId );
1539 createTool( GEOMOp::OpMinDistance, measureTbId );
1540 createTool( GEOMOp::OpAngle, measureTbId );
1541 createTool( GEOMOp::OpAnnotation, measureTbId );
1542 createTool( GEOMOp::OpTolerance , measureTbId );
1543 createTool( separator(), measureTbId );
1544 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1545 createTool( GEOMOp::OpFreeFaces, measureTbId );
1546 createTool( separator(), measureTbId );
1547 createTool( GEOMOp::OpWhatIs, measureTbId );
1548 createTool( GEOMOp::OpCheckShape, measureTbId );
1549 createTool( GEOMOp::OpCheckCompound, measureTbId );
1550 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1551 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1552 createTool( GEOMOp::OpFastCheckInters, measureTbId );
1554 int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1555 createTool( GEOMOp::OpPictureImport, picturesTbId );
1557 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1560 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1561 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1562 //@@ 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 @@//
1564 // ---- create popup menus --------------------------
1566 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1567 QString clientOCC = "(client='OCCViewer')";
1568 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1569 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1571 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1572 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1573 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1574 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1576 QString notGEOMShape = "(not ($component={'GEOM'}) and ($displayer={'Geometry'}))";
1578 QString autoColorPrefix =
1579 "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1581 QtxPopupMgr* mgr = popupMgr();
1583 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1584 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1585 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1586 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1587 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1588 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1589 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1590 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1592 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1593 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1594 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1595 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1596 mgr->insert( separator(), -1, -1 ); // -----------
1598 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1599 QString bringRule = clientOCCorOB + " and ($displayer={'Geometry'}) and isFolder=false and (selcount>0) and isOCC=true";
1600 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1601 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1602 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1603 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1604 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1605 mgr->insert( separator(), -1, -1 ); // -----------
1606 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1607 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1608 //mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1609 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1610 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1611 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1612 // mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1613 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1614 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1615 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1616 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1617 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1618 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1619 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1620 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1621 mgr->insert( separator(), dispmodeId, -1 );
1622 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1623 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1624 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1625 mgr->insert( action( GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1626 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1627 mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1628 mgr->insert( action( GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1629 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1630 mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1631 mgr->insert( separator(), -1, -1 ); // -----------
1633 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1634 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($displayer={'Geometry'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1635 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1636 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1637 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1638 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1639 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1640 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1641 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1642 mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and ($type in {'Shape' 'Group' 'Field' 'FieldStep'} or " + notGEOMShape + ") and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1644 // material properties
1645 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1646 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=false", QtxPopupMgr::VisibleRule );
1647 mgr->insert( action( GEOMOp::OpMaterialMenu ), -1, -1 );
1648 mgr->setRule( action( GEOMOp::OpMaterialMenu ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'}) and matMenu=true", QtxPopupMgr::VisibleRule );
1651 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1652 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1654 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1655 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1656 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1658 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1659 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($displayer={'Geometry'})", QtxPopupMgr::VisibleRule );
1661 mgr->insert( separator(), -1, -1 ); // -----------
1662 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1663 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1664 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1665 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1666 mgr->insert( separator(), -1, -1 ); // -----------
1668 mgr->insert( action( GEOMOp::OpEditAnnotation ), -1, -1 ); // edit annotation
1669 mgr->setRule( action( GEOMOp::OpEditAnnotation ), clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1670 mgr->insert( action( GEOMOp::OpDeleteAnnotation ), -1, -1 ); // delete annotation
1671 mgr->setRule( action( GEOMOp::OpDeleteAnnotation ), clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1672 mgr->insert( separator(), -1, -1 ); // -----------
1674 //QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1675 // onlyComponent = "((type='Component') and selcount=1)",
1676 // rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1677 // types = "'Shape' 'Group' 'FieldStep'";
1679 QString canDisplay = "($displayer={'Geometry'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1680 onlyComponent = "((type='Component') and ($component={'GEOM'}) and selcount=1)",
1681 rule = canDisplay + "and ((($type in {%1} or " + notGEOMShape + ") and( %2 )) or " + onlyComponent + ")",
1682 types = "'Shape' 'Group' 'FieldStep'";
1684 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1685 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1687 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1688 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1690 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1691 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1693 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1695 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1696 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1697 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1698 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1699 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1700 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1701 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1702 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1703 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1704 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1705 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1706 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1707 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1708 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1709 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1710 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1711 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1712 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1713 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1714 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1715 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1716 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1717 mgr->insert( separator(), selectonlyId, -1);
1718 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1719 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1720 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1721 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1722 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1723 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1724 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1726 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1728 mgr->insert( separator(), -1, -1 ); // -----------
1729 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1730 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1731 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1732 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1733 mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1734 mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1735 mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1736 mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1738 mgr->insert( separator(), -1, -1 ); // -----------
1739 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1740 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1742 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1743 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1745 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1746 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1748 mgr->insert( separator(), -1, -1 ); // -----------
1749 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1750 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1752 mgr->insert( separator(), -1, -1 ); // -----------
1753 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1754 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1756 #ifndef DISABLE_GRAPHICSVIEW
1757 mgr->insert( separator(), -1, -1 ); // -----------
1758 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1759 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1762 mgr->insert( separator(), -1, -1 ); // -----------
1763 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1764 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1766 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1768 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1770 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1771 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1772 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1775 // create plugin actions and menus
1779 //=======================================================================
1780 // function : GeometryGUI::addPluginActions()
1782 //=======================================================================
1783 void GeometryGUI::addPluginActions()
1786 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1787 if (!resMgr) return;
1789 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1790 if (!appStudy) return;
1792 // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1794 GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1796 int id = GEOMOp::OpLastOperationID; // TODO?
1799 GEOMUtils::PluginInfo::const_iterator it;
1800 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1801 // bind action lib and label to its ID for activateOperation() method proper work
1802 GEOMUtils::PluginData pdata = (*it);
1803 myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1804 std::list<GEOMUtils::ActionData> actions = (*it).actions;
1805 std::list<GEOMUtils::ActionData>::const_iterator ait;
1806 for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1807 GEOMUtils::ActionData adata = (*ait);
1810 if ( !adata.icon.empty() )
1811 icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1813 QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1814 QString actionName = smenus.last();
1815 actionName = actionName.toUpper().prepend( "MEN_" );
1816 smenus.removeLast();
1818 // path to action in toolbar
1819 QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1820 QString actionTool = stools.last();
1821 actionTool = actionTool.toUpper().prepend( "TOP_" );
1822 stools.removeLast();
1824 QString actionStat = adata.statusText.c_str();
1825 actionStat = actionStat.toUpper().prepend( "STB_" );
1827 createAction( id, // ~ adata.label
1828 tr( actionTool.toLatin1().constData() ),
1830 tr( actionName.toLatin1().constData() ),
1831 tr( actionStat.toLatin1().constData() ),
1832 QKeySequence( tr( adata.accel.c_str() ) ),
1833 application()->desktop(),
1835 this, SLOT( OnGUIEvent() ),
1836 QString() /*shortcutAction*/ );
1839 foreach ( QString subMenu, smenus ) {
1840 QStringList subMenuList = subMenu.split( ":" );
1841 QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1842 int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1843 menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1845 createMenu( id, menuId, -1 );
1847 if ( !stools.isEmpty() ) {
1848 QString subTool = stools[0];
1849 subTool = subTool.toUpper().prepend( "TOOL_" );
1850 int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1851 createTool(id, toolId);
1854 // add action id to map
1855 PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1856 myPluginActions[id] = anAction;
1865 QString wrap(const QString& text, const QString& tag)
1866 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
1869 //=======================================================================
1870 // function : GeometryGUI::activateModule()
1871 // purpose : Called when GEOM module is activated
1872 //=======================================================================
1873 bool GeometryGUI::activateModule( SUIT_Study* study )
1875 // Fill in: Help Panel
1876 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
1877 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_GEOM"));
1879 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MODEL"));
1882 items << wrap(tr("INFO_VERTICES"), "li")
1883 << wrap(tr("INFO_EDGES"), "li")
1884 << wrap(tr("INFO_WIRES"), "li")
1885 << wrap(tr("INFO_FACES"), "li")
1886 << wrap(tr("INFO_SHELLS"), "li")
1887 << wrap(tr("INFO_SOLIDS"), "li");
1888 lab = tr("INFO_BOTTOM_UP_CONSTRUCTION") + ":" + wrap(items.join(""), "ul");
1891 items << wrap(tr("INFO_BOX"), "li")
1892 << wrap(tr("INFO_CYLINDER"), "li")
1893 << wrap(tr("INFO_CONE"), "li")
1894 << wrap("...", "li");
1895 lab = lab + tr("INFO_PRIMITIVES") + ":" + wrap(items.join(""), "ul");
1898 lab = lab + tr("INFO_BOOLEANS") + "<br/>";
1899 lab = lab + tr("INFO_TRANSFORMATIONS");
1901 app->infoPanel()->addLabel(lab, gb);
1903 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MODEL"));
1904 items << wrap("BREP", "li")
1905 << wrap("STEP", "li")
1906 << wrap("IGES", "li")
1907 << wrap("STL", "li")
1908 << wrap("XAO", "li");
1909 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
1912 app->infoPanel()->addLabel(lab, gb);
1915 if ( CORBA::is_nil( myComponentGeom ) )
1918 bool res = SalomeApp_Module::activateModule( study );
1922 setMenuShown( true );
1923 setToolShown( true );
1925 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1926 PyGILState_STATE gstate = PyGILState_Ensure();
1927 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1928 if ( !pluginsmanager ) {
1933 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1934 tr("MEN_NEW_ENTITY").toUtf8().data(),
1935 tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1940 PyGILState_Release(gstate);
1941 // end of GEOM plugins loading
1943 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1944 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
1946 // Reset actions accelerator keys
1947 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1949 GUIMap::Iterator it;
1950 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1951 it.value()->activate( application()->desktop() );
1953 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1955 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ), Qt::UniqueConnection );
1956 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ), Qt::UniqueConnection );
1957 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ), Qt::UniqueConnection );
1959 if ( !myCreationInfoWdg )
1960 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1961 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1962 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1964 if ( !myTextTreeWdg ) {
1965 myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1966 new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1969 getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1970 getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1973 SALOME_ListIO selected;
1974 sm->selectedObjects( selected );
1975 sm->clearSelected();
1977 SUIT_ViewManager* vm;
1978 ViewManagerList OCCViewManagers, VTKViewManagers;
1980 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1981 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1982 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1983 onViewManagerAdded(vm);
1985 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1986 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1987 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1988 onViewManagerAdded(vm);
1990 sm->setSelectedObjects( selected, true ); //NPAL 19674
1992 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1994 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ), Qt::UniqueConnection );
1996 // 0020836 (Basic vectors and origin)
1997 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1998 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1999 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2001 _PTR(Study) studyDS = appStudy->studyDS();
2003 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2004 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
2005 createOriginAndBaseVectors();
2010 Py_XDECREF(pluginsmanager);
2015 //=======================================================================
2016 // function : GeometryGUI::deactivateModule()
2017 // purpose : Called when GEOM module is deactivated
2018 //=======================================================================
2019 bool GeometryGUI::deactivateModule( SUIT_Study* study )
2021 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
2023 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
2025 setMenuShown( false );
2026 setToolShown( false );
2028 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
2029 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
2031 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
2033 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
2034 //disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
2035 if ( myCreationInfoWdg ) {
2036 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
2037 myCreationInfoWdg = 0;
2039 if ( myTextTreeWdg ) {
2040 getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
2041 disconnect( application(), 0, myTextTreeWdg, 0 );
2045 EmitSignalCloseAllDialogs();
2047 GUIMap::Iterator it;
2048 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
2049 it.value()->deactivate();
2051 // Unset actions accelerator keys
2052 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
2054 qDeleteAll(myOCCSelectors);
2055 myOCCSelectors.clear();
2056 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
2058 qDeleteAll(myVTKSelectors);
2059 myVTKSelectors.clear();
2060 selMrg->setEnabled( true, SVTK_Viewer::Type() );
2062 return SalomeApp_Module::deactivateModule( study );
2065 //=======================================================================
2066 // function : onWindowActivated()
2067 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
2068 //=======================================================================
2069 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
2074 const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
2075 //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
2077 // disable non-OCC viewframe menu commands
2078 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
2079 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
2080 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
2081 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
2082 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
2083 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
2084 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2086 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2087 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2088 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2089 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2091 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2094 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2096 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2097 mappa.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea );
2098 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2099 #ifndef DISABLE_PYCONSOLE
2100 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2102 if ( myCreationInfoWdg )
2103 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2104 if ( myTextTreeWdg )
2105 mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2108 void GeometryGUI::viewManagers( QStringList& lst ) const
2110 lst.append( OCCViewer_Viewer::Type() );
2113 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2115 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2117 qDebug( "connect" );
2118 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
2119 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2120 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2121 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2122 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2123 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2124 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2125 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2127 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2128 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2130 // disable OCC selectors
2131 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2132 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2133 while ( itOCCSel.hasNext() )
2134 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2135 sr->setEnabled(true);
2137 else if ( vm->getType() == SVTK_Viewer::Type() )
2139 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2140 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2142 // disable VTK selectors
2143 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2144 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2145 while ( itVTKSel.hasNext() )
2146 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2147 sr->setEnabled(true);
2151 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2153 SUIT_ViewModel* viewer = vm->getViewModel();
2154 if ( vm->getType() == OCCViewer_Viewer::Type() )
2156 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2157 while ( itOCCSel.hasNext() )
2158 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2159 if ( sr->viewer() == viewer )
2161 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2165 if ( vm->getType() == SVTK_Viewer::Type() )
2167 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2168 while ( itVTKSel.hasNext() )
2169 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2170 if ( sr->viewer() == viewer )
2172 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2176 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2178 GetAnnotationMgr()->RemoveView( aSOCCView );
2182 //================================================================================
2184 * \brief Slot called when selection changed. Shows creation info of a selected object
2186 //================================================================================
2188 void GeometryGUI::updateCreationInfo()
2190 if ( myCreationInfoWdg )
2191 myCreationInfoWdg->clear();
2193 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2194 // if ( !myCreationInfoWdg->isVisible() )
2197 // look for a sole selected GEOM_Object
2198 GEOM::GEOM_BaseObject_var geomObj;
2200 SALOME_ListIO selected;
2201 getApp()->selectionMgr()->selectedObjects( selected );
2203 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2204 SALOME_ListIteratorOfListIO selIt( selected );
2205 for ( ; selIt.More(); selIt.Next() )
2207 Handle(SALOME_InteractiveObject) io = selIt.Value();
2208 if ( !io->hasEntry() ) continue;
2209 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2210 if ( !GeometryGUI::IsInGeomComponent( sobj )) continue;
2211 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2212 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2213 if ( !gobj->_is_nil() )
2215 if ( !geomObj->_is_nil() )
2216 return; // several GEOM objects selected
2220 if ( geomObj->_is_nil() ) return;
2222 // pass creation info of geomObj to myCreationInfoWdg
2224 if ( myCreationInfoWdg ) {
2226 GEOM::CreationInformationSeq_var info;
2229 info = geomObj->GetCreationInformation();
2233 myCreationInfoWdg->setInfo( info );
2237 void GeometryGUI::onAutoBringToFront()
2239 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2240 if( !isAutoBringToFront )
2243 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2244 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2247 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2248 if (!appStudy) return;
2250 GEOM_Displayer displayer;
2252 SALOME_View* window = displayer.GetActiveView();
2253 if ( !window ) return;
2255 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2257 SALOME_ListIO selected;
2258 getApp()->selectionMgr()->selectedObjects( selected );
2259 if (!myTopLevelIOList.IsEmpty())
2261 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2263 Handle( SALOME_InteractiveObject ) io = It.Value();
2264 bool isSelected = false;
2265 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2267 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2268 if( io->isSame( sel_io ) )
2271 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2273 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2274 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2279 myTopLevelIOList.Assign(selected);
2280 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2282 Handle( SALOME_InteractiveObject ) io = It.Value();
2283 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2284 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2287 displayer.UpdateViewer();
2288 GeometryGUI::Modified();
2291 void GeometryGUI::updateFieldColorScale()
2293 GEOM_Displayer aDisplayer;
2294 aDisplayer.UpdateColorScale();
2297 QString GeometryGUI::engineIOR() const
2299 if ( !CORBA::is_nil( GetGeomGen() ) )
2300 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2304 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2306 theWidth = theHeight = 0;
2307 Handle(TColStd_HArray1OfByte) aTexture;
2309 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2310 if ( !aInsOp->_is_nil() ) {
2311 CORBA::Long aWidth, aHeight;
2312 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2313 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2315 theHeight = aHeight;
2317 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2319 for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2320 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2326 LightApp_Selection* GeometryGUI::createSelection() const
2328 return new GEOMGUI_Selection();
2331 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2333 SalomeApp_Module::contextMenuPopup( client, menu, title );
2335 getApp()->selectionMgr()->selectedObjects( lst );
2337 // Update submenu for predefined materials
2338 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2339 QMenu* matMenu = action( GEOMOp::OpMaterialMenu )->menu();
2341 QSignalMapper* signalMapper = new QSignalMapper( menu );
2344 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2345 if ( anApp && anApp->activeViewManager() ) {
2346 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2348 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2351 QString curModel = "";
2352 if ( v.canConvert<QString>() ) curModel = v.toString();
2354 // get list of all predefined materials
2355 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2357 foreach ( QString material, materials )
2359 QAction* a = matMenu->addAction( material );
2360 connect( a, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2361 signalMapper->setMapping( a, material );
2362 a->setCheckable( true );
2364 Material_Model aModel;
2365 aModel.fromResources( material );
2366 if ( !found && aModel.toProperties() == curModel ) {
2367 a->setChecked( true );
2371 matMenu->addSeparator();
2372 matMenu->addAction( action( GEOMOp::OpPredefMaterCustom ) );
2373 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2374 this, SLOT( OnSetMaterial( const QString & ) ) );
2377 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2378 Handle(SALOME_InteractiveObject) io = lst.First();
2379 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2380 _PTR(Study) study = appStudy->studyDS();
2381 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2383 QString aName = QString( obj->GetName().c_str() );
2384 aName.remove( QRegExp("\\s+$") );
2390 void GeometryGUI::OnSetMaterial(const QString& theName)
2392 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2396 void GeometryGUI::createPreferences()
2398 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2400 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2402 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2403 setPreferenceProperty( genGroup, "columns", 2 );
2405 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2406 LightApp_Preferences::Selector,
2407 "Geometry", "display_mode" );
2409 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2410 LightApp_Preferences::Color, "Geometry", "shading_color" );
2412 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2413 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2415 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2416 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2418 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2419 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2421 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2422 LightApp_Preferences::Color, "Geometry", "line_color" );
2424 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2425 LightApp_Preferences::Color, "Geometry", "point_color" );
2427 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2428 LightApp_Preferences::Color, "Geometry", "isos_color" );
2430 addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2431 LightApp_Preferences::Color, "Geometry", "label_color" );
2433 addPreference( "", genGroup, LightApp_Preferences::Space );
2435 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2436 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2438 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2439 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2441 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2442 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2444 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2445 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2447 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2448 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2450 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2451 LightApp_Preferences::Selector,
2452 "Geometry", "material" );
2454 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2455 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2461 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2462 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2464 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2465 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2467 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2468 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2470 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2471 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2473 for (int i = 0; i < nb; i++) {
2474 setPreferenceProperty( wd[i], "min", 1 );
2475 setPreferenceProperty( wd[i], "max", 5 );
2478 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2479 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2481 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2482 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2484 // --------------------------------------------------------------------------
2485 // Dimensions (Measurements) preferences
2486 // --------------------------------------------------------------------------
2488 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2489 setPreferenceProperty( aDimGroupId, "columns", 2 );
2491 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2492 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2494 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2495 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2497 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2498 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2500 int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2502 int f = QtxFontEdit::Family | QtxFontEdit::Size;
2503 setPreferenceProperty( aDimFontId, "features", f );
2504 setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2506 Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2507 QString aFontFile = "";
2508 resMgr->value("resources", "GEOM", aFontFile);
2509 aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2510 // add enginier font into combobox
2511 /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2512 Handle(Font_SystemFont) sf = new Font_SystemFont( TCollection_AsciiString("Y14.5M-2009") );
2513 sf->SetFontPath( Font_FA_Regular,
2514 TCollection_AsciiString( aFontFile.toLatin1().data() ) );
2515 // register font in OCC font manager
2516 fmgr->RegisterFont( sf, Standard_False );
2518 // get list of supported fonts by OCC
2519 QStringList anOCCFonts;
2520 TColStd_SequenceOfHAsciiString theFontsNames;
2521 fmgr->GetAvailableFontsNames( theFontsNames );
2522 for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2523 Handle(TCollection_HAsciiString) str = theFontsNames(i);
2524 anOCCFonts << str->ToCString();
2526 anOCCFonts.removeDuplicates();
2527 // set the supported fonts into combobox to use its only
2528 setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2530 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2531 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2533 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2534 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2535 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2537 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2538 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2540 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2541 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2543 QStringList aListOfLengthUnits;
2544 aListOfLengthUnits << "m";
2545 aListOfLengthUnits << "cm";
2546 aListOfLengthUnits << "mm";
2547 aListOfLengthUnits << "in.";
2548 aListOfLengthUnits << "ft.";
2550 QStringList aListOfAngUnits;
2551 aListOfAngUnits << "rad";
2552 aListOfAngUnits << "deg";
2554 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2555 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2557 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2558 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2560 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2561 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2563 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2564 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2565 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2567 addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2568 LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2570 // --------------------------------------------------------------------------
2571 // Shape annotation preferences
2572 // --------------------------------------------------------------------------
2574 const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2575 setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2577 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2578 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2579 const int aShapeAnnFont =
2580 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2582 int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2583 setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2584 setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2585 setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2587 const int aShapeAnnLineWidth =
2588 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2590 setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2591 setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2593 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2595 const int aShapeAnnLineStyle =
2596 addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2598 QStringList aLineStyleList;
2599 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2600 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2601 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2602 aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2604 QList<QVariant> aLineStyleIds;
2605 aLineStyleIds.append(0);
2606 aLineStyleIds.append(1);
2607 aLineStyleIds.append(2);
2608 aLineStyleIds.append(3);
2610 setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2611 setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2613 // --------------------------------------------------------------------------
2614 // Isoline drawing preferences
2615 // --------------------------------------------------------------------------
2617 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2618 setPreferenceProperty( isoGroup, "columns", 2 );
2619 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2620 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2621 setPreferenceProperty( isoU, "min", 0 );
2622 setPreferenceProperty( isoU, "max", 100000 );
2623 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2624 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2625 setPreferenceProperty( isoV, "min", 0 );
2626 setPreferenceProperty( isoV, "max", 100000 );
2628 // Quantities with individual precision settings
2629 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2630 setPreferenceProperty( precGroup, "columns", 2 );
2632 const int nbQuantities = 8;
2633 int prec[nbQuantities], ii = 0;
2634 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2635 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2636 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2637 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2638 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2639 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2640 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2641 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2642 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2643 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2644 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2645 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2646 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2647 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2648 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2649 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2651 // Set property for precision value for spinboxes
2652 for ( ii = 0; ii < nbQuantities; ii++ ){
2653 setPreferenceProperty( prec[ii], "min", -14 );
2654 setPreferenceProperty( prec[ii], "max", 14 );
2655 setPreferenceProperty( prec[ii], "precision", 2 );
2658 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2659 setPreferenceProperty( VertexGroup, "columns", 2 );
2661 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2662 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2664 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2665 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2667 // Set property for default display mode
2668 QStringList aModesList;
2669 aModesList.append( tr("MEN_WIREFRAME") );
2670 aModesList.append( tr("MEN_SHADING") );
2671 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2672 aModesList.append( tr("MEN_TEXTURE") );
2674 QList<QVariant> anIndexesList;
2675 anIndexesList.append(0);
2676 anIndexesList.append(1);
2677 anIndexesList.append(2);
2678 anIndexesList.append(3);
2680 setPreferenceProperty( dispmode, "strings", aModesList );
2681 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2683 // Set property for top level display mode
2684 QStringList aTopModesList;
2685 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2686 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2687 aTopModesList.append( tr("MEN_WIREFRAME") );
2688 aTopModesList.append( tr("MEN_SHADING") );
2689 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2691 QList<QVariant> aTopIndexesList;
2692 aTopIndexesList.append(0);
2693 aTopIndexesList.append(1);
2694 aTopIndexesList.append(2);
2695 aTopIndexesList.append(3);
2696 aTopIndexesList.append(4);
2698 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2699 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2701 // Set property for step value for spinboxes
2702 setPreferenceProperty( step, "min", 1 );
2703 setPreferenceProperty( step, "max", 10000 );
2704 setPreferenceProperty( step, "precision", 3 );
2706 // Set property for trandparency value for spinboxes
2707 setPreferenceProperty( transparency, "min", 0 );
2708 setPreferenceProperty( transparency, "max", 100 );
2710 // Set property for deflection value for spinboxes
2711 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2712 setPreferenceProperty( defl, "max", 1.0 );
2713 setPreferenceProperty( defl, "step", 1.0e-04 );
2714 setPreferenceProperty( defl, "precision", 6 );
2716 // Set property for default material
2717 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2719 // Set property vertex marker type
2720 QList<QVariant> aMarkerTypeIndicesList;
2721 QList<QVariant> aMarkerTypeIconsList;
2723 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2724 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2725 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2726 aMarkerTypeIndicesList << (i-1);
2727 aMarkerTypeIconsList << pixmap;
2730 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2731 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2733 // Set property for vertex marker scale
2734 QList<QVariant> aMarkerScaleIndicesList;
2735 QStringList aMarkerScaleValuesList;
2737 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2738 aMarkerScaleIndicesList << iii;
2739 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2742 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2743 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2745 // Scalar bar for field step presentation
2746 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2747 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2749 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2750 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2751 setPreferenceProperty( sbXPosition, "min", 0 );
2752 setPreferenceProperty( sbXPosition, "max", 1 );
2753 setPreferenceProperty( sbXPosition, "step", 0.05 );
2755 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2756 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2757 setPreferenceProperty( sbYPosition, "min", 0 );
2758 setPreferenceProperty( sbYPosition, "max", 1 );
2759 setPreferenceProperty( sbYPosition, "step", 0.05 );
2761 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2762 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2763 setPreferenceProperty( sbWidth, "min", 0 );
2764 setPreferenceProperty( sbWidth, "max", 1 );
2765 setPreferenceProperty( sbWidth, "step", 0.05 );
2767 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2768 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2769 setPreferenceProperty( sbHeight, "min", 0 );
2770 setPreferenceProperty( sbHeight, "max", 1 );
2771 setPreferenceProperty( sbHeight, "step", 0.05 );
2773 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2774 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2775 setPreferenceProperty( sbTextHeight, "min", 6 );
2776 setPreferenceProperty( sbTextHeight, "max", 24 );
2777 setPreferenceProperty( sbTextHeight, "step", 1 );
2779 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2780 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2781 setPreferenceProperty( sbNbIntervals, "min", 2 );
2782 setPreferenceProperty( sbNbIntervals, "max", 64 );
2783 setPreferenceProperty( sbNbIntervals, "step", 1 );
2785 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2786 setPreferenceProperty( originGroup, "columns", 2 );
2788 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2789 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2790 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2791 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2793 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2794 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2796 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2797 setPreferenceProperty( operationsGroup, "columns", 2 );
2799 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2800 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2802 addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2803 LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2805 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2807 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2809 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2810 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2812 QStringList aHierarchyTypeList;
2813 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2814 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2815 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2817 QList<QVariant> aHierarchyTypeIndexesList;
2818 aHierarchyTypeIndexesList.append(0);
2819 aHierarchyTypeIndexesList.append(1);
2820 aHierarchyTypeIndexesList.append(2);
2822 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2823 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2825 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2826 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2828 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2830 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2831 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2833 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2834 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2835 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2836 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2837 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2838 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2839 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2840 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2842 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2843 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2844 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2845 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2846 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2847 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2854 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2856 if (section == "Geometry") {
2857 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2858 if (param == QString("SettingsGeomStep")) {
2859 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2860 EmitSignalDefaultStepValueChanged(spin_step);
2862 else if (param == QString("toplevel_color")) {
2863 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2864 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2866 else if (param == QString("toplevel_dm")) {
2867 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2869 else if (param == QString("scalar_bar_x_position") ||
2870 param == QString("scalar_bar_y_position") ||
2871 param == QString("scalar_bar_width") ||
2872 param == QString("scalar_bar_height") ||
2873 param == QString("scalar_bar_text_height") ||
2874 param == QString("scalar_bar_nb_intervals")) {
2875 updateFieldColorScale();
2877 else if ( param == QString("dimensions_color") ||
2878 param == QString("dimensions_line_width") ||
2879 param == QString("dimensions_font") ||
2880 param == QString("dimensions_arrow_length") ||
2881 param == QString("dimensions_show_units") ||
2882 param == QString("dimensions_length_units") ||
2883 param == QString("dimensions_angle_units") ||
2884 param == QString("dimensions_use_text3d") ||
2885 param == QString("shape_annotation_font_color") ||
2886 param == QString("shape_annotation_line_color") ||
2887 param == QString("shape_annotation_font") ||
2888 param == QString("shape_annotation_line_width") ||
2889 param == QString("shape_annotation_autohide") ||
2890 param == QString("shape_annotation_line_style") ||
2891 param == QString("shape_annotation_line_style") ||
2892 param == QString("label_color") )
2894 SalomeApp_Application* anApp = getApp();
2900 GEOM_Displayer aDisplayer;
2902 ViewManagerList aVMs;
2903 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2904 ViewManagerList::Iterator anIt = aVMs.begin();
2905 for ( ; anIt != aVMs.end(); ++anIt )
2907 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2913 SALOME_ListIO aVisible;
2914 aViewer->GetVisible( aVisible );
2916 GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2917 if ( anAnnotationMgr ) {
2918 SALOME_ListIteratorOfListIO anIter( aVisible );
2919 while ( anIter.More() ) {
2920 if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2921 aVisible.Remove( anIter );
2929 aDisplayer.Redisplay( aVisible, false, aViewer );
2931 if ( param == QString( "label_color" ) ) {
2932 ViewManagerList aVMsVTK;
2933 anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2934 ViewManagerList::Iterator anIt = aVMsVTK.begin();
2935 for ( ; anIt != aVMsVTK.end(); ++anIt )
2937 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2942 SALOME_ListIO aVisible;
2943 aViewer->GetVisible( aVisible );
2944 aDisplayer.Redisplay( aVisible, false, aViewer );
2947 aDisplayer.UpdateViewer();
2949 else if ( param.startsWith( "dependency_tree") )
2950 emit SignalDependencyTreeParamChanged( section, param );
2954 LightApp_Displayer* GeometryGUI::displayer()
2957 myDisplayer = new GEOM_Displayer();
2961 void GeometryGUI::setLocalSelectionMode(const int mode)
2963 myLocalSelectionMode = mode;
2966 int GeometryGUI::getLocalSelectionMode() const
2968 return myLocalSelectionMode;
2971 const char gSeparator = '_'; // character used to separate parameter names
2972 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2975 * \brief Store visual parameters
2977 * This method is called just before the study document is saved.
2978 * Store visual parameters in AttributeParameter attribute(s)
2980 void GeometryGUI::storeVisualParameters (int savePoint)
2982 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2983 if ( !appStudy || !appStudy->studyDS() )
2986 _PTR(Study) studyDS = appStudy->studyDS();
2988 // componentName is used for encoding of entries when storing them in IParameters
2989 std::string componentName = myComponentGeom->ComponentDataType();
2990 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2991 //if (!aSComponent) return;
2994 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2995 componentName.c_str(),
2997 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2999 QSet<QString> anEntriesToStoreShared;
3000 QList<SUIT_ViewManager*> lst;
3001 QList<SUIT_ViewManager*>::Iterator it;
3003 GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
3005 // main cycle to store parameters of displayed objects
3007 getApp()->viewManagers(lst);
3008 for (it = lst.begin(); it != lst.end(); it++) {
3009 SUIT_ViewManager* vman = *it;
3010 QString vType = vman->getType();
3011 SUIT_ViewModel* vmodel = vman->getViewModel();
3012 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3014 int aMgrId = vman->getGlobalId();
3015 // saving VTK actors properties
3016 QVector<SUIT_ViewWindow*> views = vman->getViews();
3017 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
3018 const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
3019 ObjMap::ConstIterator o_it = anObjects.begin();
3020 for (; o_it != anObjects.end(); o_it++) {
3021 const PropMap& aProps = o_it.value();
3023 //Check that object exists in the study
3024 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toUtf8().data() ) );
3025 if ( !obj || !(aProps.count() > 0))
3027 // entry is "encoded" = it does NOT contain component address, since it is a
3028 // subject to change on next component loading
3030 std::string entry = ip->encodeEntry(o_it.key().toUtf8().data(), componentName);
3032 _PTR(GenericAttribute) anAttr;
3033 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
3036 // remember entry of object to store shared GEOM properties
3037 // (e.g. dimension properties).
3038 if ( vType == OCCViewer_Viewer::Type() )
3040 anEntriesToStoreShared.insert( o_it.key() );
3043 QString param, occParam = vType;
3044 occParam += GEOM::sectionSeparator();
3045 occParam += QString::number(aMgrId);
3046 occParam += GEOM::sectionSeparator();
3048 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
3049 param = occParam + GEOM::propertyName( GEOM::Visibility );
3050 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
3053 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
3054 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
3055 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
3058 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
3059 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
3061 val << QString::number(c.redF());
3062 val << QString::number(c.greenF());
3063 val << QString::number(c.blueF());
3064 param = occParam + GEOM::propertyName( GEOM::Color );
3065 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
3068 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
3069 param = occParam + GEOM::propertyName( GEOM::Texture );
3070 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
3073 if (vType == SVTK_Viewer::Type()) {
3074 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
3075 param = occParam + GEOM::propertyName( GEOM::Opacity );
3076 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
3078 } else if (vType == SOCC_Viewer::Type()) {
3079 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3080 param = occParam + GEOM::propertyName( GEOM::Transparency );
3081 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3084 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3085 param = occParam + GEOM::propertyName( GEOM::TopLevel );
3086 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3090 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3091 param = occParam + GEOM::propertyName( GEOM::NbIsos );
3092 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3095 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3096 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3097 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3100 if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3101 param = occParam + GEOM::propertyName( GEOM::Vertices );
3102 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3105 if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3106 param = occParam + GEOM::propertyName( GEOM::ShowName );
3107 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3110 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3111 param = occParam + GEOM::propertyName( GEOM::Deflection );
3112 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3115 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3116 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3117 param = occParam + GEOM::propertyName( GEOM::PointMarker );
3118 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3121 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3122 param = occParam + GEOM::propertyName( GEOM::Material );
3123 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3126 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3127 param = occParam + GEOM::propertyName( GEOM::LineWidth );
3128 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3131 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3132 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3133 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3136 if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3137 std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3138 o_it.key().toUtf8().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3139 if (!anAnnotationInfo.empty()) {
3140 param = occParam + "ShapeAnnotationVisibleItems";
3141 ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3144 } // object iterator
3146 } // for (viewManagers)
3148 // store shape annotation and dimension attributes of objects:
3149 // since the displayed object always persists in property map, we remember the object entries
3150 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3151 const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3152 const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3153 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3154 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3156 std::string aStudyEntry = (*aEntryIt).toUtf8().data();
3157 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3159 // store dimension parameters
3160 GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3161 if ( aDimensions.GetNumber() != 0 ) {
3162 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toUtf8().data() );
3165 _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3166 const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3167 if ( !aShapeAnnAttr.IsNull() ) {
3168 ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toUtf8().data() );
3174 * \brief Restore visual parameters
3176 * This method is called after the study document is opened.
3177 * Restore visual parameters from AttributeParameter attribute(s)
3179 void GeometryGUI::restoreVisualParameters (int savePoint)
3181 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3182 if (!appStudy || !appStudy->studyDS())
3184 _PTR(Study) studyDS = appStudy->studyDS();
3186 // componentName is used for encoding of entries when storing them in IParameters
3187 std::string componentName = myComponentGeom->ComponentDataType();
3188 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3189 //if (!aSComponent) return;
3192 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3193 componentName.c_str(),
3195 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3197 std::vector<std::string> entries = ip->getEntries();
3199 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3201 // entry is a normal entry - it should be "decoded" (setting base address of component)
3202 QString entry (ip->decodeEntry(*entIt).c_str());
3204 // Check that the entry corresponds to a real object in the Study
3205 // as the object may be deleted or modified after the visual state is saved.
3206 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
3207 if (!so) continue; //Skip the not existent entry
3209 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3210 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3212 std::vector<std::string>::iterator namesIt = paramNames.begin();
3213 std::vector<std::string>::iterator valuesIt = paramValues.begin();
3215 // actors are stored in a map after displaying of them for
3216 // quicker access in the future: map < viewID to actor >
3217 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
3218 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3220 QString viewerTypStr;
3221 QString viewIndexStr;
3223 QVector<PropMap> aListOfMap;
3225 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3227 // visual parameters are stored in strings as follows:
3228 // 1) ViewerType_ViewIndex_ParamName
3229 // 2) ViewerType_ParamName (shared for GEOM module)
3230 // '_' is used as separator and should not be used in viewer type or parameter names.
3231 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3233 bool isShared = lst.size() == 2;
3234 bool isViewer = lst.size() == 3;
3235 if ( !isShared && !isViewer )
3240 // shared visual parameters
3243 QString aParamNameStr( lst[1] );
3244 QString aValuesStr( (*valuesIt).c_str() );
3246 // shared dimension properties are stored as attribute
3247 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3249 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3250 aDimensionProp.SaveToAttribute( entry.toUtf8().data() );
3252 else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3254 Handle(GEOMGUI_AnnotationAttrs) anAttr =
3255 GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3257 anAttr->ImportFromPropertyString( aValuesStr );
3263 // per view visual parameters
3264 viewerTypStr = lst[0];
3265 viewIndexStr = lst[1];
3266 QString paramNameStr = lst[2];
3269 viewIndex = viewIndexStr.toUInt(&ok);
3270 if (!ok) // bad conversion of view index to integer
3273 if ((viewIndex + 1) > aListOfMap.count()) {
3274 aListOfMap.resize(viewIndex + 1);
3277 QString val((*valuesIt).c_str());
3278 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3279 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3280 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3281 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3282 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3283 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3284 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3285 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3286 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3287 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3288 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3289 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3290 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3291 QStringList rgb = val.split(GEOM::subSectionSeparator());
3292 if (rgb.count() == 3) {
3293 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3294 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3296 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3297 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3298 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3299 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3300 } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3301 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3302 } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3303 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3304 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3305 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3306 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3307 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3308 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3309 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3310 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3311 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3312 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3313 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3314 } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3315 aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3318 } // for names/parameters iterator
3320 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3322 for (int index = 0; index < aListOfMap.count(); index++) {
3323 appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3325 //Get Visibility property of the current PropMap
3326 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3327 SUIT_ViewManager* vman = lst.at(index);
3328 SUIT_ViewModel* vmodel = vman->getViewModel();
3329 SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3330 displayer()->Display(entry, true, aView);
3332 if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3333 PropMap& aProps = aListOfMap[index];
3334 if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3335 SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3336 GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3341 } // for entries iterator
3343 // update all VTK and OCC views
3344 QList<SUIT_ViewManager*> lst;
3345 getApp()->viewManagers(lst);
3346 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3347 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3350 if (vmodel->getType() == SVTK_Viewer::Type()) {
3351 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3352 vtkView->getRenderer()->ResetCameraClippingRange();
3355 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3356 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3357 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3363 if ( myTextTreeWdg ) {
3364 myTextTreeWdg->updateTree();
3368 // Compute current name mode of the viewer
3369 void UpdateNameMode( SalomeApp_Application* app )
3371 bool isMode = false;
3372 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3373 SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3374 GEOM_Displayer displayer;
3375 int aMgrId = viewWindow->getViewManager()->getGlobalId();
3377 SALOME_View* window = displayer.GetActiveView();
3378 if ( !window ) return;
3380 SALOME_ListIO anIOlst;
3381 window->GetVisible( anIOlst );
3383 for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3384 Handle( SALOME_InteractiveObject ) io = It.Value();
3385 QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3386 bool isIONameMode = v.isValid() ? v.toBool() : false;
3390 viewWindow->setProperty( "NameMode", isMode );
3393 void GeometryGUI::onViewAboutToShow()
3395 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3396 QAction* a = action( GEOMOp::OpSwitchVectors );
3397 QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3398 QAction* aNameAction = action( GEOMOp::OpSwitchName );
3400 a->setEnabled(true);
3401 bool vmode = window->property("VectorsMode").toBool();
3402 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3403 aVerticesAction->setEnabled(true);
3404 vmode = window->property("VerticesMode").toBool();
3405 aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3406 UpdateNameMode( getApp() );
3407 aNameAction->setEnabled(true);
3408 vmode = window->property("NameMode").toBool();
3409 aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3411 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3412 a->setEnabled(false);
3413 aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3414 aVerticesAction->setEnabled(false);
3415 aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3416 aNameAction->setEnabled(false);
3421 \brief Return action by id
3422 \param id identifier of the action
3425 QAction* GeometryGUI::getAction(const int id) {
3430 \brief GEOM module message handler
3432 This method can be re-implemented in the subclasses.
3433 This is a GEOM module message handler.
3435 \param msg the message received.
3437 void GeometryGUI::message(const QString& msg)
3440 QStringList data = msg.split("/");
3441 const int nbStrings = data.count();
3443 if (nbStrings > 0) {
3444 if (data[0] == "modified") {
3446 QString anIOR = nbStrings > 1 ? data[1] : QString();
3448 if ( anIOR.isEmpty() ) {
3452 // Get the geom object.
3453 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3455 // Clear the shape buffer
3456 GeometryGUI::ClearShapeBuffer (anObj);
3462 \brief Clears the shape buffer.
3464 This is a static method. It clears the shape buffer.
3466 \param theObj the object
3468 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3470 if ( CORBA::is_nil( theObj ) )
3473 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3474 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3475 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3477 SalomeApp_Application* app =
3478 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3479 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3484 _PTR(Study) aStudy = appStudy->studyDS();
3489 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3493 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3494 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3495 _PTR(GenericAttribute) anAttr;
3496 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3497 _PTR(AttributeIOR) anIOR ( anAttr );
3498 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3499 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3505 \brief Returns the object from IOR.
3507 This is a static method. It returns the object from its IOR.
3509 \param IOR object IOR
3510 \return GEOM object.
3512 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3514 GEOM::GEOM_Object_var geomObj;
3515 if ( !IOR.isEmpty() ) {
3516 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3517 ( IOR.toLatin1().constData() );
3518 if ( !CORBA::is_nil( corbaObj ) )
3519 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3521 return geomObj._retn();
3525 \brief Returns IOR of the object.
3527 This is a static method. It returns the object's IOR.
3529 \param object the GEOM object.
3530 \return object's IOR.
3532 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3535 if ( !CORBA::is_nil( object ) ) {
3536 CORBA::String_var anIOR =
3537 SalomeApp_Application::orb()->object_to_string( object );
3544 \brief Check if this object is can't be renamed in place
3546 This method can be re-implemented in the subclasses.
3547 Return true in case if object isn't reference or component (module root).
3549 \param entry column id
3550 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3552 bool GeometryGUI::renameAllowed( const QString& entry) const {
3554 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3555 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3556 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3558 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3562 Rename object by entry.
3563 \param entry entry of the object
3564 \param name new name of the object
3565 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3567 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3569 bool result = false;
3571 SalomeApp_Application* app =
3572 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3573 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3578 _PTR(Study) aStudy = appStudy->studyDS();
3583 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3585 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3589 _PTR(SObject) obj ( aStudy->FindObjectID(qUtf8Printable(entry)) );
3590 _PTR(GenericAttribute) anAttr;
3592 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3593 _PTR(AttributeName) aName (anAttr);
3595 aName->SetValue( name.toUtf8().data() ); // rename the SObject
3596 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3597 if (!CORBA::is_nil(anObj)) {
3598 anObj->SetName( name.toUtf8().data() ); // Rename the corresponding GEOM_Object
3599 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3600 emit SignalTextTreeRenameObject( entry );
3608 void GeometryGUI::updateMaterials()
3610 LightApp_Preferences* pref = preferences();
3612 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3613 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3614 if ( !materials.contains( currentMaterial ) )
3615 // user material set as default in the preferences, might be removed
3616 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3618 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3620 setPreferenceProperty( prefItem->id(),
3621 "strings", materials );
3622 prefItem->retrieve();
3628 \brief Check if the module allows "drag" operation of its objects.
3630 Overloaded from LightApp_Module class.
3632 This function is a part of the general drag-n-drop mechanism.
3633 The goal of this function is to check data object passed as a parameter
3634 and decide if it can be dragged or no.
3636 \param what data object being tested for drag operation
3637 \return \c true if module allows dragging of the specified object
3638 \sa isDropAccepted(), dropObjects()
3640 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3642 // we allow dragging object under root and object from folder
3643 int aLevel = what->level();
3644 bool anObjectInFolder = false;
3646 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3648 _PTR(SObject) aSO = dataObj->object();
3650 _PTR(GenericAttribute) anAttr;
3651 _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3652 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3653 _PTR(AttributeLocalID) aLocalID( anAttr );
3654 anObjectInFolder = aLocalID->Value() == 999;
3659 return aLevel == 2 || anObjectInFolder;
3663 \brief Check if the module allows "drop" operation on the given object.
3665 Overloaded from LightApp_Module class.
3667 This function is a part of the general drag-n-drop mechanism.
3668 The goal of this function is to check data object passed as a parameter
3669 and decide if it can be used as a target for the "drop" operation.
3670 The processing of the drop operation itself is done in the dropObjects() function.
3672 \param where target data object
3673 \return \c true if module supports dropping on the \a where data object
3674 \sa isDraggable(), dropObjects()
3676 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3678 // we allow dropping into folder and top-level GEOM object
3679 int aLevel = where->level();
3680 bool isFolder = false;
3682 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3684 _PTR(SObject) aSO = dataObj->object();
3686 _PTR(GenericAttribute) anAttr;
3687 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3688 _PTR(AttributeLocalID) aLocalID( anAttr );
3689 isFolder = aLocalID->Value() == 999;
3694 return aLevel == 1 || isFolder;
3698 \brief Complete drag-n-drop operation.
3700 Overloaded from LightApp_Module class.
3702 This function is a part of the general drag-n-drop mechanism.
3703 Its goal is to handle dropping of the objects being dragged according
3704 to the chosen operation (move). The dropping is performed in the
3705 context of the parent data object \a where and the \a row (position in the
3706 children index) at which the data should be dropped. If \a row is equal to -1,
3707 this means that objects are added to the end of the children list.
3709 \param what objects being dropped
3710 \param where target data object
3711 \param row child index at which the drop operation is performed
3712 \param action drag-n-drop operation (Qt::DropAction) - move
3714 \sa isDraggable(), isDropAccepted()
3716 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3717 const int row, Qt::DropAction action )
3719 if (action != Qt::CopyAction && action != Qt::MoveAction)
3720 return; // unsupported action
3722 // get parent object
3723 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3724 if ( !dataObj ) return; // wrong parent
3725 _PTR(SObject) parentObj = dataObj->object();
3727 // Find the current Study and StudyBuilder
3728 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3729 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3730 // collect all parents of the target node
3731 QStringList parentIDs;
3732 _PTR(SObject) parent = parentObj;
3733 while( !parent->IsNull() ) {
3734 parentIDs << parent->GetID().c_str();
3735 parent = aUseCaseBuilder->GetFather(parent);
3738 // collect objects being dropped
3739 GEOM::object_list_var objects = new GEOM::object_list();
3740 objects->length( what.count() );
3742 for ( int i = 0; i < what.count(); i++ ) {
3743 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3744 if ( !dataObj ) continue; // skip wrong objects
3745 _PTR(SObject) sobj = dataObj->object();
3746 // check that dropped object is not a parent of target object
3747 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3748 return; // it's not allowed to move node into it's child
3750 objects[i] = _CAST(SObject, sobj)->GetSObject();
3753 objects->length( count );
3755 // call engine function
3756 GetGeomGen()->Move( objects.in(), // what
3757 _CAST(SObject, parentObj)->GetSObject(), // where
3760 // update Object browser
3761 getApp()->updateObjectBrowser( false );
3764 void GeometryGUI::emitDimensionsUpdated( QString entry )
3766 emit DimensionsUpdated( entry );
3769 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3771 emit SignalAnnotationsUpdated( entry );