2 // File : GeometryGUI.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI.h"
13 # include "Utils_ORB_INIT.hxx"
14 # include "Utils_SINGLETON.hxx"
17 #include "QAD_Tools.h"
18 #include "QAD_Config.h"
19 #include "QAD_Settings.h"
20 #include "QAD_RightFrame.h"
21 #include "QAD_MessageBox.h"
22 #include "QAD_Resource.h"
23 #include "QAD_FileDlg.h"
25 #include "OCCViewer_ViewPort.h"
26 #include "OCCViewer_ViewPort3d.h"
27 #include "OCCViewer_Viewer3d.h"
29 #include "VTKViewer_RenderWindowInteractor.h"
30 #include "VTKViewer_ViewFrame.h"
32 #include "GEOM_Actor.h"
33 #include "GEOM_Client.hxx"
34 #include "GEOM_AISShape.hxx"
35 #include "GEOM_AssemblyBuilder.h"
36 #include "GEOM_InteractiveObject.hxx"
38 #include "SALOME_NamingService.hxx"
39 #include "SALOME_ListIteratorOfListIO.hxx"
40 #include "SALOME_InteractiveObject.hxx"
42 #include "SALOMEGUI_ImportOperation.h"
43 #include "SALOMEGUI_QtCatchCorbaException.hxx"
44 #include "SALOMEGUI_NameDlg.h"
45 #include "utilities.h"
47 // Open CASCADE Includes
48 #include <AIS_Shape.hxx>
49 #include <AIS_InteractiveContext.hxx>
50 #include <AIS_ListIteratorOfListOfInteractive.hxx>
51 #include <AIS_Drawer.hxx>
52 #include <AIS_Trihedron.hxx>
53 #include <Prs3d_Drawer.hxx>
54 #include <Prs3d_IsoAspect.hxx>
55 #include <Prs3d_ShadingAspect.hxx>
57 #include <BRep_Builder.hxx>
58 #include <BRepAdaptor_Surface.hxx>
59 #include <BRepAdaptor_Curve.hxx>
60 #include <BRep_Tool.hxx>
61 #include <BRepGProp.hxx>
62 #include <BRepExtrema_DistShapeShape.hxx>
63 #include <GProp_GProps.hxx>
64 #include <GProp_PrincipalProps.hxx>
66 #include <BRepAlgoAPI_Fuse.hxx>
67 #include <BRepAlgoAPI_Cut.hxx>
68 #include <BRepAlgoAPI_Section.hxx>
69 #include <BRepAlgoAPI_Common.hxx>
70 #include <BRepPrimAPI_MakeBox.hxx>
71 #include <BRepPrimAPI_MakeCylinder.hxx>
72 #include <BRepPrimAPI_MakePrism.hxx>
73 #include <BRepPrimAPI_MakeSphere.hxx>
74 #include <BRepPrimAPI_MakeRevol.hxx>
75 #include <BRepPrimAPI_MakeTorus.hxx>
76 #include <BRepPrimAPI_MakeCone.hxx>
77 #include <BRepBuilderAPI_MakeVertex.hxx>
78 #include <BRepBuilderAPI_MakeEdge.hxx>
79 #include <BRepBuilderAPI_MakeWire.hxx>
80 #include <BRepBuilderAPI_MakeFace.hxx>
81 #include <BRepBuilderAPI_Transform.hxx>
83 #include <BRepTools.hxx>
84 #include <BRepTools_WireExplorer.hxx>
85 #include <BRepCheck_Analyzer.hxx>
87 #include <Geom_Circle.hxx>
88 #include <Geom_Line.hxx>
89 #include <Geom_Plane.hxx>
90 #include <Geom_Surface.hxx>
91 #include <Geom_Axis2Placement.hxx>
92 #include <Geom_TrimmedCurve.hxx>
94 #include <GeomAPI_ProjectPointOnCurve.hxx>
95 #include <GC_MakeArcOfCircle.hxx>
97 #include <gp_Circ.hxx>
101 #include <TopTools_MapOfShape.hxx>
102 #include <TopTools_MapIteratorOfMapOfShape.hxx>
103 #include <TopTools_ListIteratorOfListOfShape.hxx>
104 #include <TopoDS_Iterator.hxx>
106 //VRV: OCC 4.0 migration
107 #include <IGESControl_Writer.hxx>
108 #include <IGESControl_Controller.hxx>
109 #include <STEPControl_Writer.hxx>
110 //#include <STEPControlStd_StepModelType.hxx>
111 //VRV: OCC 4.0 migration
113 #include <TopoDS.hxx>
114 #include <TopoDS_Wire.hxx>
115 #include <TopoDS_Shape.hxx>
116 #include <TopoDS_Compound.hxx>
117 #include <TopAbs.hxx>
118 #include <TopExp.hxx>
119 #include <TopExp_Explorer.hxx>
121 #include <Precision.hxx>
122 #include <ProjLib.hxx>
123 #include <ElSLib.hxx>
125 #include <IFSelect_ReturnStatus.hxx>
126 #include <Interface_Static.hxx>
129 #define INCLUDE_MENUITEM_DEF
130 #include <qapplication.h>
131 #include <qmenudata.h>
132 #include <qmenubar.h>
133 #include <qpopupmenu.h>
136 #include <qcheckbox.h>
137 #include <qcolordialog.h>
138 #include <qmessagebox.h>
139 #include <qspinbox.h>
143 #include <qlineedit.h>
144 #include "GeometryGUI_aParameterDlg.h"
146 #include "GeometryGUI_PointDlg.h" // Method POINT
147 #include "GeometryGUI_BoxDlg.h" // Method BOX
148 #include "GeometryGUI_VectorDlg.h" // Method VECTOR
149 #include "GeometryGUI_PlaneDlg.h" // Method PLANE
150 #include "GeometryGUI_PrismDlg.h" // Method PRISM
151 #include "GeometryGUI_FuseDlg.h" // Method FUSE
152 #include "GeometryGUI_CommonDlg.h" // Method COMMON
153 #include "GeometryGUI_CutDlg.h" // Method CUT
154 #include "GeometryGUI_SectionDlg.h" // Method SECTION
156 #include "GeometryGUI_LineDlg.h" // Method LINE
157 #include "GeometryGUI_ScaleDlg.h" // Method SCALE
158 #include "GeometryGUI_MirrorDlg.h" // Method MIRROR
159 #include "GeometryGUI_SphereDlg.h" // Method SPHERE
160 #include "GeometryGUI_CircleDlg.h" // Method CIRCLE
161 #include "GeometryGUI_RevolDlg.h" // Method REVOL
162 #include "GeometryGUI_RotationDlg.h" // Method ROTATION
163 #include "GeometryGUI_TranslationDlg.h" // Method TRANSLATION
164 #include "GeometryGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
165 #include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION
166 #include "GeometryGUI_ArcDlg.h" // Method ARC
167 #include "GeometryGUI_PipeDlg.h" // Method PIPE
168 #include "GeometryGUI_CylinderDlg.h" // Method CYLINDER
169 #include "GeometryGUI_ConeDlg.h" // Method CONE
170 #include "GeometryGUI_TorusDlg.h" // Method TORUS
171 #include "GeometryGUI_FillingDlg.h" // Method FILLING
172 #include "GeometryGUI_SewingDlg.h" // Method SEWING
173 #include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND
174 #include "GeometryGUI_EdgeDlg.h" // Method GEOM::EDGE
175 #include "GeometryGUI_OrientationDlg.h" // Method ORIENTATION
176 #include "GeometryGUI_PartitionDlg.h" // Method PARTITION
177 #include "GeometryGUI_SubShapeDlg.h" // Method EXPLODE
178 #include "GeometryGUI_WireDlg.h" // Method GEOM::WIRE
179 #include "GeometryGUI_WorkingPlaneDlg.h" // Method WORKING PLANE
180 #include "GeometryGUI_PropertiesDlg.h" // Method PROPERTIES
181 #include "GeometryGUI_CenterMassDlg.h" // Method CENTER MASS
182 #include "GeometryGUI_InertiaDlg.h" // Method INERTIA
183 #include "GeometryGUI_FaceDlg.h" // Method GEOM::FACE
184 #include "GeometryGUI_FilletDlg.h" // Method FILLET
185 #include "GeometryGUI_ChamferDlg.h" // Method CHAMFER
186 #include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE
187 #include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES
188 #include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE
189 #include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE
190 #include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement
191 #include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement
192 #include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX
193 #include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
194 #include "GeometryGUI_WhatisDlg.h" // Method WHATIS
195 #include "GeometryGUI_DistanceDlg.h" // Method DISTANCE
196 #include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE
199 static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape());
200 static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), "");
202 static AIS_ListOfInteractive ListDisplayedObject;
204 static bool Settings_AddInStudy = false;
205 static bool Settings_Copy = false;
206 static Standard_CString Fatherior = "";
207 static GEOM_Client ShapeReader;
209 /* The object itself created in the static method 'GetOrCreateGeometryGUI()' */
210 static GeometryGUI* GeomGUI = 0;
214 //=======================================================================
215 // class : CustomItem
216 // purpose : Set Font to a text.
217 //=======================================================================
218 class CustomItem : public QCustomMenuItem
221 CustomItem( const QString& s, const QFont& f )
222 : string( s ), font( f ){};
225 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
228 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
233 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
243 //=======================================================================
244 // function : GeometryGUI()
245 // purpose : Constructor
246 //=======================================================================
247 GeometryGUI::GeometryGUI() :
252 //=======================================================================
253 // function : ~GeometryGUI()
254 // purpose : Destructor
255 //=======================================================================
256 GeometryGUI::~GeometryGUI()
261 //=======================================================================
262 // function : GetGeometryGUI() static
263 // purpose : Returns current 'GeomGUI' a static pointer
264 //=======================================================================
265 GeometryGUI* GeometryGUI::GetGeometryGUI( )
271 //=====================================================================================
272 // function : GetIndex()
273 // purpose : Get the index of a sub shape in a main shape : index start at 1
274 //=====================================================================================
275 int GeometryGUI::GetIndex(const TopoDS_Shape& subshape,
276 const TopoDS_Shape& shape,
279 if( shape.IsNull() || subshape.IsNull() )
283 if (subshape.ShapeType() == TopAbs_COMPOUND)
286 TopTools_ListOfShape CL;
288 TopTools_ListIteratorOfListOfShape itC;
289 for (itC.Initialize( CL ); itC.More(); itC.Next())
291 for (it.Initialize( itC.Value() ); it.More(); it.Next())
293 if ( it.Value().ShapeType() == TopAbs_COMPOUND)
295 if (it.Value().IsSame(subshape))
299 CL.Append( it.Value() );
306 TopExp_Explorer Exp ( shape, subshape.ShapeType() );
307 TopTools_MapOfShape M;
310 if ( M.Add(Exp.Current()) )
312 if ( Exp.Current().IsSame(subshape) )
322 //=======================================================================
323 // function : GetOrCreateGeometryGUI()
324 // purpose : Gets or create an object 'GeometryGUI' with initialisations
325 // : Returns 'GeomGUI' as a pointer
326 //=======================================================================
327 GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
330 GeomGUI = new GeometryGUI;
331 GeomGUI->myActiveDialogBox = 0 ;
332 GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape());
333 GeomGUI->myState = -1 ;
334 GeomGUI->myDesktop = desktop ;
335 GeomGUI->myActiveStudy = desktop->getActiveStudy();
336 GeomGUI->mySimulationActor = vtkActorCollection::New() ;
338 GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
340 Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
341 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
343 /* GetCurrentStudy */
344 int studyId = GeomGUI->myActiveStudy->getStudyId();
345 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
347 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
349 /* study may have changed */
350 GeomGUI->myActiveStudy = desktop->getActiveStudy();
356 //=================================================================================
357 // function : VertexToPoint()
358 // purpose : If S can be converted in a gp_Pnt returns true and the result is P
359 //=================================================================================
360 bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P )
362 if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX )
364 P = BRep_Tool::Pnt(TopoDS::Vertex( S ));
369 //=================================================================================
370 // function : LinearEdgeExtremities()
371 // purpose : If S can be converted in a linear edge and if initial an final points
372 // : distance is sufficient, returns true else returns false.
373 // : Resulting points are respectively P1 and P2
374 //=================================================================================
375 bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 )
377 if( S.IsNull() || S.ShapeType() != TopAbs_EDGE )
379 BRepAdaptor_Curve curv(TopoDS::Edge(S));
380 if (curv.GetType() != GeomAbs_Line)
383 curv.D0( curv.FirstParameter(), P1 );
384 curv.D0( curv.LastParameter(), P2 );
386 if( P1.Distance(P2) <= Precision::Confusion() )
392 //=================================================================================
393 // function : GetBipointDxDyDz()
395 //=================================================================================
396 void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz )
398 dx = P2.X() - P1.X() ;
399 dy = P2.Y() - P1.Y() ;
400 dz = P2.Z() - P1.Z() ;
404 //=======================================================================
405 // function : GetTopoFromSelection()
406 // purpose : Define tds from a single selection and retuen true
407 //=======================================================================
408 bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
410 if(Sel->IObjectCount() != 1)
413 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
415 if ( IO->hasEntry() ) {
416 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
417 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
418 SALOMEDS::GenericAttribute_var anAttr;
419 SALOMEDS::AttributeIOR_var anIOR;
420 if ( !obj->_is_nil() ) {
421 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
422 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
423 tds = this->GetShapeFromIOR(anIOR->Value());
432 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
433 Standard_CString ior = "";
434 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
435 ior = GIObject->getIOR();
436 tds = this->GetShapeFromIOR(ior);
448 //=====================================================================================
449 // function : PrepareSubShapeSelection()
450 // purpose : ( localContextId of the method is opened and defined here)
451 //=====================================================================================
452 bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
454 //* Test the type of viewer */
455 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
458 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
459 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
461 /* local context opening */
462 SetDisplayedObjectList() ;
465 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
466 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
467 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
468 for(;It.More();It.Next()) {
469 Handle(SALOME_InteractiveObject) IObject = It.Value();
470 Standard_Boolean found;
471 Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found);
472 if ( found && SubShapeType >= Shape->Shape().ShapeType()) {
473 ic->Load(Shape, (8 - SubShapeType), Standard_True);
474 ic->HilightWithColor(Shape, Quantity_NOC_RED);
477 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
483 //=====================================================================================
484 // function : PrepareSubShapeSelectionArgumentShape()
485 // purpose : ( localContextId of the method is opened and defined here )
486 //=====================================================================================
487 bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
488 const int SubShapeType,
489 Standard_Integer& returnLocalContextId )
491 //* Test the type of viewer */
492 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
495 if( aShape.IsNull() )
498 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
499 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
501 /* local context opening */
502 SetDisplayedObjectList() ;
505 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
507 Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ;
508 ic->Display(Shape, 0, (8 - SubShapeType));
510 // Not Load(...) but Display(...)
511 // ic->Load(Shape, (8 - SubShapeType), Standard_True);
512 ic->HilightWithColor(Shape, Quantity_NOC_RED);
514 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
520 //=======================================================================
521 // function : GetNameOfSelectedIObjects()
522 // purpose : Define the name geom++ or other name of mono or multi sel.
523 //=======================================================================
524 int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel,
527 int nbSel = Sel->IObjectCount() ;
529 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
530 aName = IObject->getName();
532 aName = tr( "%1_objects" ).arg( nbSel );
538 //=======================================================================
539 // function : ConvertIOinGEOMAISShape()
541 //=======================================================================
542 Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
543 Standard_Boolean& testResult,
544 bool onlyInActiveView )
546 Handle(GEOM_AISShape) res;
547 int nbSf = myActiveStudy->getStudyFramesCount();
548 for ( int i = 0; i < nbSf; i++ ) {
549 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
550 if ( sf->getTypeView() == VIEW_OCC ) {
551 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
552 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
554 AIS_ListOfInteractive List;
555 ic->DisplayedObjects(List);
556 AIS_ListOfInteractive List1;
557 ic->ObjectsInCollector(List1);
560 AIS_ListIteratorOfListOfInteractive ite(List);
562 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
563 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
564 if ( aSh->hasIO() ) {
565 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
566 if ( GIO->isSame( IO ) ) {
567 if ( onlyInActiveView ) {
568 if ( sf == myActiveStudy->getActiveStudyFrame() ) {
587 //=======================================================================
588 // function : ConvertIORinGEOMAISShape()
590 //=======================================================================
591 Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR,
592 Standard_Boolean& testResult,
593 bool onlyInActiveView )
595 Handle(GEOM_AISShape) resultShape;
597 int nbSf = myActiveStudy->getStudyFramesCount();
598 for ( int i = 0; i < nbSf; i++ )
600 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
601 if ( sf->getTypeView() == VIEW_OCC )
603 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
604 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
606 AIS_ListOfInteractive List;
607 ic->DisplayedObjects(List);
608 AIS_ListOfInteractive List1;
609 ic->ObjectsInCollector(List1);
612 AIS_ListIteratorOfListOfInteractive ite(List);
615 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
617 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
620 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
621 Standard_CString theIOR = GIO->getIOR();
622 if ( strcmp( IOR, theIOR ) == 0 )
624 if ( onlyInActiveView )
626 if ( sf == myActiveStudy->getActiveStudyFrame() )
648 //=======================================================================
649 // function : ConvertIORinGEOMActor()
651 //=======================================================================
652 GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
653 Standard_Boolean& testResult,
654 bool onlyInActiveView )
656 int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount();
657 for ( int i = 0; i < nbSf; i++ ) {
658 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
659 if ( sf->getTypeView() == VIEW_VTK ) {
660 vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
661 vtkActorCollection* theActors = Renderer->GetActors();
662 theActors->InitTraversal();
663 vtkActor *ac = theActors->GetNextActor();
665 if ( ac->IsA("GEOM_Actor") ) {
666 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
667 if ( anActor->hasIO() ) {
668 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO());
669 Standard_CString theIOR = GIO->getIOR();
670 if ( strcmp( IOR, theIOR ) == 0 ) {
671 if ( onlyInActiveView ) {
672 if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) {
683 ac = theActors->GetNextActor();
688 return GEOM_Actor::New();
691 //=======================================================================
692 // function : ConvertIOinGEOMShape()
694 //=======================================================================
695 GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
696 Standard_Boolean& testResult )
698 GEOM::GEOM_Shape_ptr aShape ;
702 if ( IO->hasEntry() ) {
703 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
704 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
705 SALOMEDS::GenericAttribute_var anAttr;
706 SALOMEDS::AttributeIOR_var anIOR;
707 if ( !obj->_is_nil() ) {
708 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
709 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
710 aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
716 /* case Graphical Object */
717 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
718 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
719 Standard_CString ior = GIObject->getIOR();
721 aShape = myComponentGeom->GetIORFromString(ior) ;
728 //=======================================================================
729 // function : ConvertListOfIOInListOfIOR()
731 //=======================================================================
732 void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
733 GEOM::GEOM_Gen::ListOfIOR& listIOR )
735 int nbSel = aList.Extent();
736 listIOR.length(nbSel) ;
738 SALOME_ListIteratorOfListIO It( aList );
739 for ( int i=0; It.More(); It.Next(), i++ )
741 Handle(SALOME_InteractiveObject) IObject = It.Value();
743 if ( IObject->hasEntry() )
745 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
746 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
747 SALOMEDS::GenericAttribute_var anAttr;
748 SALOMEDS::AttributeIOR_var anIOR;
749 if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") )
751 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
752 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
753 CORBA::ORB_var& _orb = init.orb() ;
754 CORBA::String_var theValue = anIOR->Value();
755 CORBA::Object_var theObj = _orb->string_to_object(theValue);
756 if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0"))
758 listIOR[j] = strdup(theValue) ;
763 else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
764 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject );
765 Standard_CString ior = GIObject->getIOR();
766 listIOR[j] = strdup(ior) ;
774 //=================================================================================
775 // function : GetShapeTypeString()
776 // purpose : for a single shape
777 //=================================================================================
778 bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString )
780 if( aShape.IsNull() ) {
781 aTypeString = "aNullShape" ;
784 switch (aShape.ShapeType() )
786 case TopAbs_COMPOUND:
787 { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; }
788 case TopAbs_COMPSOLID:
789 { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; }
791 { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; }
793 { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; }
796 BRepAdaptor_Surface surf(TopoDS::Face(aShape));
797 if ( surf.GetType() == GeomAbs_Plane ) {
798 aTypeString = strdup(tr("GEOM_PLANE")) ;
800 } else if ( surf.GetType() == GeomAbs_Cylinder ) {
801 aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ;
803 } else if ( surf.GetType() == GeomAbs_Sphere ) {
804 aTypeString = strdup(tr("GEOM_SURFSPHERE")) ;
806 } else if ( surf.GetType() == GeomAbs_Torus ) {
807 aTypeString = strdup(tr("GEOM_SURFTORUS")) ;
809 } else if ( surf.GetType() == GeomAbs_Cone ) {
810 aTypeString = strdup(tr("GEOM_SURFCONE")) ;
813 aTypeString = strdup(tr("GEOM_FACE")) ;
818 { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; }
821 BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
822 if ( curv.GetType() == GeomAbs_Line ) {
823 if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
824 (Abs(curv.LastParameter()) >= 1E6 )) {
825 aTypeString = strdup(tr("GEOM_LINE")) ;
827 aTypeString = strdup(tr("GEOM_EDGE")) ;
829 } else if ( curv.GetType() == GeomAbs_Circle ) {
830 if ( curv.IsClosed() )
831 aTypeString = strdup(tr("GEOM_CIRCLE")) ;
833 aTypeString = strdup(tr("GEOM_ARC")) ;
836 aTypeString = strdup(tr("GEOM_EDGE")) ;
841 { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; }
843 { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; }
849 //=================================================================================
850 // function : CreateArrowForLinearEdge()
851 // purpose : Create a cone topology to be used to display an arrow in the middle
852 // : of an edge showing its orientation. (For simulation and Viewer OCC only)
853 //=================================================================================
854 bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone )
856 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE )
859 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
860 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
861 Standard_Real Width, Height ;
862 view3d->Size(Width, Height) ;
863 const Standard_Real aHeight = (Width + Height) / 50.0 ;
866 Standard_Real first, last ;
867 Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
871 const Standard_Real param = (first+last) / 2.0 ;
872 gp_Pnt middleParamPoint ;
874 curv->D1( param, middleParamPoint, V1) ;
875 if ( V1.Magnitude() < Precision::Confusion() )
878 /* Topology orientation not geom orientation */
879 if( tds.Orientation() == TopAbs_REVERSED )
882 gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ;
883 const Standard_Real radius1 = aHeight / 5.0 ;
884 if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) {
885 ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ;
889 catch(Standard_Failure) {
890 // OCC failures are hard to catch in GUI.
891 // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
892 // in SALOME environment : compilation error !
898 //=======================================================================
899 // function : SelectionByNameInDialogs()
900 // purpose : Called when user has entered a name of object in a LineEdit.
901 // : The selection is changed. Dialog box will receive the
902 // : corresponding signal to manage this event.
903 //=======================================================================
904 bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel )
907 /* Find SObject with name in component GEOM */
908 SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ;
909 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
910 listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ;
912 if ( listSO->length() < 1 ) {
913 const QString caption = tr("GEOM_WRN_WARNING") ;
914 const QString text = tr("GEOM_NAME_INCORRECT") ;
915 const QString button0 = tr("GEOM_BUT_OK") ;
916 QMessageBox::warning( aWidget, caption, text, button0 ) ;
919 /* More than one object with same name */
920 if ( listSO->length() > 1 ) {
921 const QString caption = tr("GEOM_WRN_WARNING") ;
922 const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ;
923 const QString button0 = tr("GEOM_BUT_OK") ;
924 QMessageBox::warning( aWidget, caption, text, button0 ) ;
928 SALOMEDS::SObject_var theObj = listSO[0] ;
929 /* Create a SALOME_InteractiveObject with a SALOME::SObject */
930 Standard_CString anEntry = theObj->GetID() ;
931 Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ;
933 /* Add as a selected object */
934 /* Clear any previous selection : */
935 /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
936 Sel->ClearIObjects() ;
937 Sel->AddIObject( SI ) ;
942 //=======================================================================
943 // function : MakePointAndDisplay
945 //=======================================================================
946 void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z )
949 GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z );
950 P->NameType( tr("GEOM_VERTEX") );
951 if ( Display( P, "") )
952 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
954 catch (const SALOME::SALOME_Exception& S_ex) {
955 QtCatchCorbaException(S_ex);
962 //=======================================================================
963 // function : MakeVectorAndDisplay()
965 //=======================================================================
966 void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
969 GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
970 GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
971 GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 );
972 Vector->NameType(tr("GEOM_VECTOR"));
973 if ( Display( Vector, "") )
974 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
976 catch (const SALOME::SALOME_Exception& S_ex) {
977 QtCatchCorbaException(S_ex);
982 //=======================================================================
983 // function : MakeBoxAndDisplay()
985 //=======================================================================
986 void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
989 GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() );
990 box->NameType(tr("GEOM_BOX"));
991 if ( Display( box, "") ) {
992 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
995 catch (const SALOME::SALOME_Exception& S_ex) {
996 QtCatchCorbaException(S_ex);
1003 //=======================================================================
1004 // function : MakePlaneAndDisplay()
1005 // purpose : Plane point is P1 and dx, dy, dz define a normal vector
1006 //=======================================================================
1007 void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
1008 const Standard_Real dy, const Standard_Real dz,
1009 const Standard_Real TrimSize )
1013 aDirection.SetCoord(dx, dy, dz) ;
1014 gp_Ax2 Axis( P1, aDirection );
1016 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1017 GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ;
1018 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1019 GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ;
1020 plane->NameType(tr("GEOM_PLANE"));
1021 if ( Display( plane, "") )
1022 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1024 catch (const SALOME::SALOME_Exception& S_ex) {
1025 QtCatchCorbaException(S_ex);
1030 //=======================================================================
1031 // function : MakeWorkingPlane()
1032 // purpose : Change the point of view3d
1033 //=======================================================================
1034 void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D)
1036 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
1037 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
1040 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
1041 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
1042 view3d->SetAt( P.X(), P.Y(), P.Z() );
1043 view3d->SetProj( D.X(), D.Y(), D.Z() );
1044 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1048 //=======================================================================
1049 // function : MakePrismAndDisplay()
1050 // purpose : P1 and P2 is to define a vector for prism
1051 //=======================================================================
1052 void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 )
1055 GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1056 GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ;
1057 if( BaseShape->_is_nil() ) {
1058 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1062 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ;
1063 if (result->_is_nil()) {
1064 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1068 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1069 Standard_CString type;
1070 GetShapeTypeString(S,type);
1071 result->NameType( type );
1073 if ( Display( result, "") )
1074 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1076 catch (const SALOME::SALOME_Exception& S_ex) {
1077 QtCatchCorbaException(S_ex);
1083 //=====================================================================================
1084 // function : MakeLineAndDisplay()
1085 // purpose : Create an infinite oriented line (linear edge in fact)
1086 //=====================================================================================
1087 void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint )
1091 GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ;
1092 Standard_Real length = InitPoint.Distance(LastPoint) ;
1093 if( length <= Precision::Confusion() ) {
1094 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1098 Standard_Real coeff = 1E6 / length ;
1100 /* To create a line with length = 1E6 */
1101 /* Precision::Infinite() is 1E100 in OCC */
1102 P1.SetX( InitPoint.X() - (coeff * dx) ) ;
1103 P1.SetY( InitPoint.Y() - (coeff * dy) ) ;
1104 P1.SetZ( InitPoint.Z() - (coeff * dz) ) ;
1106 P2.SetX( LastPoint.X() + (coeff * dx) ) ;
1107 P2.SetY( LastPoint.Y() + (coeff * dy) ) ;
1108 P2.SetZ( LastPoint.Z() + (coeff * dz) ) ;
1111 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ;
1112 GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ;
1113 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1115 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ;
1116 if(result->_is_nil()) {
1117 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1120 result->NameType(tr("GEOM_LINE"));
1122 if ( Display( result, "") )
1123 myDesktop->putInfo(tr("GEOM_PRP_READY"));
1125 catch (const SALOME::SALOME_Exception& S_ex) {
1126 QtCatchCorbaException(S_ex);
1133 //=======================================================================
1134 // function : MakeBooleanAndDisplay()
1136 //=======================================================================
1137 void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation )
1140 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ;
1141 if (result->_is_nil()) {
1142 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1146 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1147 Standard_CString type;
1148 GetShapeTypeString(S,type);
1149 result->NameType( type );
1151 if ( Display( result, "") )
1152 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1154 catch (const SALOME::SALOME_Exception& S_ex) {
1155 QtCatchCorbaException(S_ex);
1161 //=====================================================================================
1162 // function : MakeSphere()
1164 //=====================================================================================
1165 void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius )
1168 if( aRadius <= Precision::Confusion() ) {
1169 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"),
1170 tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") );
1173 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius);
1174 result->NameType(tr("GEOM_SPHERE"));
1175 if ( Display( result, "") )
1176 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1178 catch (const SALOME::SALOME_Exception& S_ex) {
1179 QtCatchCorbaException(S_ex);
1185 //=====================================================================================
1186 // function : MakeConeAndDisplay()
1188 //=====================================================================================
1189 void GeometryGUI::MakeConeAndDisplay( const gp_Pnt BasePoint,
1191 const double Radius1,
1192 const double Radius2,
1193 const double aHeight )
1196 if( ( Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion() ) || aHeight <= Precision::Confusion() )
1198 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1199 GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1200 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1202 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ;
1203 if ( result->_is_nil() ) {
1204 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1207 result->NameType(tr("GEOM_CONE"));
1208 if ( Display( result, "") )
1209 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1211 catch (const SALOME::SALOME_Exception& S_ex) {
1212 QtCatchCorbaException(S_ex);
1218 //=====================================================================================
1219 // function : MakeCylinderAndDisplay()
1221 //=====================================================================================
1222 void GeometryGUI::MakeCylinderAndDisplay( const gp_Pnt BasePoint,
1224 const double Radius,
1225 const double aHeight )
1228 if( Radius <= Precision::Confusion() || aHeight <= Precision::Confusion() )
1230 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1231 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1232 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1234 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ;
1235 if ( result->_is_nil() ) {
1236 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1239 result->NameType(tr("GEOM_CYLINDER"));
1240 if ( Display( result, "") )
1241 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1243 catch (const SALOME::SALOME_Exception& S_ex) {
1244 QtCatchCorbaException(S_ex);
1250 //=====================================================================================
1251 // function : MakeTorusAndDisplay()
1253 //=====================================================================================
1254 void GeometryGUI::MakeTorusAndDisplay( const gp_Pnt BasePoint,
1256 const double Radius1,
1257 const double Radius2 )
1260 if( Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion() )
1263 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1264 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1265 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1267 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ;
1268 if ( result->_is_nil() ) {
1269 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1272 result->NameType(tr("GEOM_TORUS"));
1273 if ( Display( result, "") )
1274 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1276 catch (const SALOME::SALOME_Exception& S_ex) {
1277 QtCatchCorbaException(S_ex);
1283 //=====================================================================================
1284 // function : MakePipeAndDisplay()
1286 //=====================================================================================
1287 void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase )
1290 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase);
1291 if ( !result->_is_nil() && Display( result, "") ) {
1293 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1294 Standard_CString type;
1295 GetShapeTypeString(S,type);
1296 result->NameType( type );
1298 myDesktop->putInfo( tr("GEOM_PRP_DONE") );
1301 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1304 catch (const SALOME::SALOME_Exception& S_ex) {
1305 QtCatchCorbaException(S_ex);
1311 //=====================================================================================
1312 // function : MakeFillingAndDisplay()
1314 //=====================================================================================
1315 void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape,
1320 const short nbiter )
1323 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape,
1325 tol3d, tol2d, nbiter );
1326 if (result->_is_nil()) {
1327 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1331 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1332 Standard_CString type;
1333 GetShapeTypeString(S,type);
1334 result->NameType( type );
1336 if ( Display( result, "") )
1337 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1340 catch (const SALOME::SALOME_Exception& S_ex) {
1341 QtCatchCorbaException(S_ex);
1347 //=====================================================================================
1348 // function : MakeMirrorAndDisplay()
1350 //=====================================================================================
1351 void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 )
1354 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 );
1355 if (result->_is_nil()) {
1356 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1359 result->NameType( Shape1->NameType() );
1360 if ( Display( result, "") )
1361 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1363 catch (const SALOME::SALOME_Exception& S_ex) {
1364 QtCatchCorbaException(S_ex);
1370 //=====================================================================================
1371 // function : MakeSewingAndDisplay()
1373 //=====================================================================================
1374 void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1375 const Standard_Real precision )
1378 GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ;
1379 if( result->_is_nil() ) {
1380 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1384 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1385 Standard_CString type;
1386 GetShapeTypeString(S,type);
1387 result->NameType( type );
1389 if( Display( result, "") )
1390 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1393 catch (const SALOME::SALOME_Exception& S_ex) {
1394 QtCatchCorbaException(S_ex);
1399 //=====================================================================================
1400 // function : MakeCompoundAndDisplay()
1402 //=====================================================================================
1403 void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1406 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ;
1407 if( result->_is_nil() ) {
1408 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1411 result->NameType(tr("GEOM_COMPOUND"));
1412 if( Display( result, "" ))
1413 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1415 catch (const SALOME::SALOME_Exception& S_ex) {
1416 QtCatchCorbaException(S_ex);
1422 //=====================================================================================
1423 // function : MakeFaceAndDisplay()
1425 //=====================================================================================
1426 void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar )
1429 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ;
1430 if( result->_is_nil() ) {
1431 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1435 result->NameType(tr("GEOM_PLANE"));
1437 result->NameType(tr("GEOM_FACE"));
1438 if( Display( result, "") )
1439 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1441 catch (const SALOME::SALOME_Exception& S_ex) {
1442 QtCatchCorbaException(S_ex);
1449 //=====================================================================================
1450 // function : MakeLinearEdgeAndDisplay()
1452 //=====================================================================================
1453 void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1456 GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
1457 GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
1458 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ;
1459 if( result->_is_nil() ) {
1460 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1463 result->NameType(tr("GEOM_EDGE"));
1464 if( Display( result, "") )
1465 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1467 catch(const SALOME::SALOME_Exception& S_ex) {
1468 QtCatchCorbaException(S_ex);
1474 //=====================================================================================
1475 // function : MakeOrientationChangeAndDisplay()
1477 //=====================================================================================
1478 void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape )
1481 GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ;
1482 if( result->_is_nil() ) {
1483 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1486 result->NameType( Shape->NameType() );
1487 if ( Display( result, "" ))
1488 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1491 catch (const SALOME::SALOME_Exception& S_ex) {
1492 QtCatchCorbaException(S_ex);
1497 //=====================================================================================
1498 // function : MakeScaleAndDisplay()
1500 //=====================================================================================
1501 void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor )
1504 GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ;
1505 GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ;
1506 // result->NameType(tr("GEOM_SCALE"));
1507 result->NameType( Shape->NameType() );
1508 if ( Display( result, "") )
1509 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1511 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1513 catch (const SALOME::SALOME_Exception& S_ex) {
1514 QtCatchCorbaException(S_ex);
1520 //=======================================================================================
1521 // function : MakeRevolutionAndDisplay()
1523 //=======================================================================================
1524 void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle )
1527 GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1528 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ;
1529 if ( result->_is_nil() ) {
1530 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1534 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1535 Standard_CString type;
1536 GetShapeTypeString(S,type);
1537 result->NameType( type );
1539 if ( Display( result ) )
1540 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1542 catch (const SALOME::SALOME_Exception& S_ex) {
1543 QtCatchCorbaException(S_ex);
1549 //=======================================================================================
1550 // function : MakeRotationAndDisplay()
1552 //=======================================================================================
1553 void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape,
1556 const Standard_Real angle )
1559 const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1560 GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle);
1561 if ( result->_is_nil() ) {
1562 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1565 result->NameType( Shape->NameType() );
1566 if ( Display( result ) )
1567 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1569 catch (const SALOME::SALOME_Exception& S_ex) {
1570 QtCatchCorbaException(S_ex);
1576 //=================================================================================
1577 // function : MakeTranslationAndDisplay()
1578 // purpose : Translate a shape
1579 //=================================================================================
1580 void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V )
1583 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ;
1584 if ( result->_is_nil() ) {
1585 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1588 result->NameType( Shape->NameType() );
1589 if ( Display( result ) )
1590 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1592 catch (const SALOME::SALOME_Exception& S_ex) {
1593 QtCatchCorbaException(S_ex);
1598 //=================================================================================
1599 // function : MakeMultiTranslation1DAndDisplay()
1600 // purpose : Multi-Translate a shape
1601 //=================================================================================
1602 void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes )
1605 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1606 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1608 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes );
1609 if ( result->_is_nil() ) {
1610 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1613 result->NameType( tr("GEOM_COMPOUND") );
1614 if ( Display( result ) )
1615 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1617 catch (const SALOME::SALOME_Exception& S_ex) {
1618 QtCatchCorbaException(S_ex);
1624 //=================================================================================
1625 // function : MakeMultiTranslation2DAndDisplay()
1626 // purpose : Multi-Translate a shape
1627 //=================================================================================
1628 void GeometryGUI::MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1, const gp_Dir Dir2, const double Step2, const short NbTimes2 )
1631 GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ;
1632 GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ;
1633 GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ;
1634 GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ;
1636 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 );
1637 if ( result->_is_nil() ) {
1638 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1641 result->NameType( tr("GEOM_COMPOUND") );
1642 if ( Display( result ) )
1643 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1645 catch (const SALOME::SALOME_Exception& S_ex) {
1646 QtCatchCorbaException(S_ex);
1652 //=================================================================================
1653 // function : MakeMultiRotation1DAndDisplay()
1654 // purpose : Multi-Rotate a shape
1655 //=================================================================================
1656 void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes )
1659 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1660 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1661 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1663 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes );
1664 if ( result->_is_nil() ) {
1665 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1668 result->NameType( tr("GEOM_COMPOUND") );
1669 if ( Display( result ) )
1670 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1672 catch (const SALOME::SALOME_Exception& S_ex) {
1673 QtCatchCorbaException(S_ex);
1679 //=================================================================================
1680 // function : MakeMultiRotation2DAndDisplay()
1681 // purpose : Multi-Rotate a shape
1682 //=================================================================================
1683 void GeometryGUI::MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang, const short NbTimes1, const double Step, const short NbTimes2 )
1686 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1687 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1688 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1690 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 );
1691 if ( result->_is_nil() ) {
1692 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1695 result->NameType( tr("GEOM_COMPOUND") );
1696 if ( Display( result ) )
1697 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1699 catch (const SALOME::SALOME_Exception& S_ex) {
1700 QtCatchCorbaException(S_ex);
1707 //=======================================================================================
1708 // function : MakeArcAndDisplay()
1709 // purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
1710 //=======================================================================================
1711 void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint )
1713 gp_Vec v1( CirclePoint, InitPoint ) ;
1714 gp_Vec v2( CirclePoint, EndPoint ) ;
1715 if( v1.IsParallel(v2, Precision::Angular() ) )
1719 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() );
1720 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() );
1721 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() );
1722 GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ;
1723 if ( result->_is_nil() ) {
1724 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1727 result->NameType(tr("GEOM_ARC"));
1728 if ( Display( result ) )
1729 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1731 catch (const SALOME::SALOME_Exception& S_ex) {
1732 QtCatchCorbaException(S_ex);
1738 //=====================================================================================
1739 // function : MakeCircleAndDisplay()
1741 //=====================================================================================
1742 void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius )
1745 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1746 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1747 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1749 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ;
1750 if ( result->_is_nil() ) {
1751 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1754 result->NameType(tr("GEOM_CIRCLE"));
1755 if ( Display( result ) )
1756 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1758 catch (const SALOME::SALOME_Exception& S_ex) {
1759 QtCatchCorbaException(S_ex);
1766 //=====================================================================================
1767 // function : MakeWireAndDisplay()
1769 //=====================================================================================
1770 void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1773 GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ;
1774 if( result->_is_nil() ) {
1775 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1778 result->NameType(tr("GEOM_WIRE"));
1779 if( Display( result, "") )
1780 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1782 catch (const SALOME::SALOME_Exception& S_ex) {
1783 QtCatchCorbaException(S_ex);
1789 //=====================================================================================
1790 // function : MakePartitionAndDisplay()
1792 //=====================================================================================
1793 void GeometryGUI::MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1794 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
1795 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
1796 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
1797 const GEOM::shape_type limit)
1800 GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR,
1804 (CORBA::Short) limit);
1805 if( result->_is_nil() ) {
1806 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1809 result->NameType(tr("GEOM_PARTITION"));
1810 if( Display( result, "") )
1811 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1814 catch (const SALOME::SALOME_Exception& S_ex) {
1815 QtCatchCorbaException(S_ex);
1819 //=======================================================================
1820 // function : SetState()
1821 // purpose : Sets myState = aState a private field indicating which methode is active
1822 //=======================================================================
1823 void GeometryGUI::SetState(int aState )
1824 { this->myState = aState ; return ; }
1827 //=======================================================================
1828 // function : ResetState()
1829 // purpose : Sets myState = -1 a private field indicating which methode is active
1830 //=======================================================================
1831 void GeometryGUI::ResetState()
1832 { this->myState = -1 ; return ; }
1835 //=======================================================================
1836 // function : EmitSignalDeactivateDialog()
1837 // purpose : Emit a signal to deactivate the active dialog Box
1838 //=======================================================================
1839 void GeometryGUI::EmitSignalDeactivateDialog()
1841 emit this->SignalDeactivateActiveDialog() ;
1845 //=======================================================================
1846 // function : EmitSignalCloseAllDialogs()
1847 // purpose : Emit a signal to deactivate all non modal dialogs box
1848 //=======================================================================
1849 void GeometryGUI::EmitSignalCloseAllDialogs()
1851 emit this->SignalCloseAllDialogs() ;
1856 //=======================================================================
1857 // function : GetActiveDialogBox()
1859 //=======================================================================
1860 QDialog* GeometryGUI::GetActiveDialogBox()
1862 return this->myActiveDialogBox ;
1866 //=======================================================================
1867 // function : SetActiveDialogBox()
1869 //=======================================================================
1870 void GeometryGUI::SetActiveDialogBox(QDialog* aDlg)
1872 this->myActiveDialogBox = (QDialog*)aDlg ;
1877 //=======================================================================
1878 // function : GetActiveStudy()
1880 //=======================================================================
1881 QAD_Study* GeometryGUI::GetActiveStudy()
1883 return this->myActiveStudy ;
1887 //=======================================================================
1888 // function : GetActiveDesktop()
1890 //=======================================================================
1891 QAD_Desktop* GeometryGUI::GetDesktop()
1893 return this->myDesktop ;
1897 //=====================================================================================
1898 // function : OnSubShapeGetAll()
1899 // purpose : Explode a shape in all sub shapes with a SubShapeType
1900 //=====================================================================================
1901 bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
1903 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1904 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
1905 if ( theObj->_is_nil() ) {
1906 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
1910 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1911 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
1912 SALOMEDS::GenericAttribute_var anAttr;
1913 SALOMEDS::AttributeName_var aName;
1914 SALOMEDS::AttributeIOR_var anIOR;
1915 SALOMEDS::AttributePixMap_var aPixmap;
1917 /* We create a sub object for each sub shape as attribute of the main object */
1918 /* Each sub object contains list (length=1) containing its index in the main shape */
1919 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
1920 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
1921 GEOM::GEOM_Shape_var aResult ;
1924 listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType );
1925 if( listGeomShapes->length() < 1 ) {
1926 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1930 catch (const SALOME::SALOME_Exception& S_ex) {
1931 QtCatchCorbaException(S_ex);
1934 /* open transaction */
1935 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
1938 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
1939 TopoDS_Shape mainShape;
1942 if ( aShape->IsMainShape() ) {
1943 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
1946 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
1949 /* Loop on each sub shape created */
1950 /* int i = 1 ; /* index for the nameType */
1951 for( int j=0; j<listGeomShapes->length(); j++) {
1953 /* Get each sub shape extracted CORBA and OCC */
1954 aResult = listGeomShapes[j] ;
1955 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
1958 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1962 // NRI : Following lines are commented according to bugID SAL695 (see history)
1963 // BRepCheck_Analyzer anAnalyzer(S);
1964 // if(!anAnalyzer.IsValid()) {
1965 // myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1966 // MESSAGE("#### An exploded shape number "<< j << " is not valid");
1971 /* Set the nameType of sub shape */
1972 char* nameG = (char *)malloc(20);
1973 Standard_CString Type;
1974 if ( GetShapeTypeString(S, Type) ) {
1975 aResult->NameType( Type );
1976 sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) );
1979 aResult->NameType( tr("GEOM_SHAPE") );
1980 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
1982 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
1984 bool allreadyexist = false;
1986 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
1987 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
1988 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
1990 Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG );
1991 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
1993 MESSAGE ( "SO->_is_nil() " << SO->_is_nil() )
1995 if ( SO->_is_nil() ) {
1996 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
1997 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1998 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1999 aName->SetValue(nameG);
2000 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2001 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2002 anIOR->SetValue(aResult->Name());
2004 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2005 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2006 MESSAGE( " Type " << S.ShapeType() )
2007 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2008 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2009 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2010 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2011 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2012 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2013 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2014 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2015 } else if ( S.ShapeType() == TopAbs_FACE ) {
2016 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2017 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2018 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2019 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2020 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2021 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2022 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2025 MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() )
2027 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2028 aStudyBuilder->Addreference(newObj1, newObj);
2029 IO->setEntry(newObj->GetID());
2031 aResult->StudyShapeId( newObj->GetID() );
2033 allreadyexist = true;
2034 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2035 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2036 aStudyBuilder->Addreference(newObj1, SO);
2037 IO->setEntry(SO->GetID());
2038 aResult->StudyShapeId( SO->GetID() );
2042 result->setIO( IO );
2043 result->setName( nameG );
2044 if ( !allreadyexist )
2045 ic->Display(result);
2047 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2048 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
2050 int themode = myRenderInter->GetDisplayMode();
2051 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2052 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
2054 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM");
2056 if ( SO->_is_nil() ) {
2057 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2058 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2059 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2060 anIOR->SetValue(aResult->Name());
2061 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2062 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2063 aName->SetValue(nameG);
2065 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2066 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2067 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2068 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2069 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2070 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2071 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2072 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2073 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2074 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2075 } else if ( S.ShapeType() == TopAbs_FACE ) {
2076 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2077 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2078 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2079 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2080 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2081 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2082 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2085 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2086 aStudyBuilder->Addreference(newObj1, newObj);
2087 IO->setEntry(newObj->GetID());
2089 allreadyexist = true;
2090 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2091 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2092 aStudyBuilder->Addreference(newObj1, SO);
2093 IO->setEntry(SO->GetID());
2097 if ( !allreadyexist ) {
2098 vtkActorCollection* theActors =
2099 GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
2100 theActors->InitTraversal();
2101 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
2102 while(!(anActor==NULL)) {
2103 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
2104 GActor->setIO( IO );
2105 GActor->setName( nameG );
2106 theRenderer->AddActor(GActor);
2108 anActor = (vtkActor*)theActors->GetNextActor();
2114 /* commit transaction */
2117 myActiveStudy->updateObjBrowser();
2118 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2124 //=====================================================================================
2125 // function : GetIndexSubShapeSelected()
2126 // purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType
2127 // : Method used by Dialogs
2128 //=====================================================================================
2129 bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
2130 const int SubShapeType,
2131 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
2132 Standard_Integer& aLocalContextId,
2133 bool& myUseLocalContext )
2135 //* Test the type of viewer */
2136 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2140 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2141 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2144 int nbSelected = ic->NbSelected();
2145 ListOfID.length(nbSelected);
2148 //***************** DEFINE INDEX OF EACH SELECTION *********************//
2150 ic->InitSelected(); /* to restart */
2151 while( ic->MoreSelected() ) {
2153 /* Find index of sub shape into main shape */
2154 TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) );
2156 bool found = false ;
2157 while ( Exp.More() ) {
2158 if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) {
2166 /* Manage local context from DialogBox */
2167 ic->CloseLocalContext(aLocalContextId) ;
2168 myUseLocalContext = false ;
2171 ListOfID[i] = index ;
2175 //***************** END *********************//
2177 /* Manage local context from DialogBox */
2178 ic->CloseLocalContext(aLocalContextId) ;
2179 myUseLocalContext = false ;
2185 //=====================================================================================
2186 // function : OnSubShapeGetSelected()
2188 //=====================================================================================
2189 bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
2190 const char* ShapeTopoIOR,
2191 const int SubShapeType,
2192 Standard_Integer& aLocalContextId,
2193 bool& myUseLocalContext )
2195 //* Test the type of viewer */
2196 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2200 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2201 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2202 if ( theObj->_is_nil() ) {
2203 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2208 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2209 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2211 if( myUseLocalContext == false ) {
2212 /* local context is from DialogBox */
2213 MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
2217 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2218 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
2220 TopoDS_Shape mainShape;
2223 if ( aShape->IsMainShape() ) {
2224 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
2227 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2230 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2232 int nbSelected = ic->NbSelected();
2233 ListOfID->length(nbSelected);
2235 TopoDS_Compound compound;
2236 ic->InitSelected(); /* to init again */
2238 B.MakeCompound( compound );
2241 /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
2242 /* the compound is homogenous by selection */
2243 while(ic->MoreSelected()) {
2244 int index = GetIndex( ic->SelectedShape(), mainShape, SubShapeType );
2245 ListOfID[i] = index ;
2246 B.Add( compound, ic->SelectedShape() );
2251 /* Test if user has selected sub shapes */
2252 if( ListOfID->length() < 1 )
2255 GEOM::GEOM_Shape_var aResult ;
2257 aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID );
2259 catch (const SALOME::SALOME_Exception& S_ex) {
2260 QtCatchCorbaException(S_ex);
2263 /* local context from DialogBox */
2264 ic->CloseLocalContext(aLocalContextId) ;
2265 myUseLocalContext = false ;
2267 char* nameG = (char *)malloc(20);
2268 Standard_CString Type;
2270 Handle(GEOM_AISShape) result;
2271 Handle(GEOM_InteractiveObject) IO ;
2273 // if ( ! SObjectExist(theObj, aResult->Name()) ) {
2274 if ( nbSelected == 1 ) {
2275 TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) );
2277 if ( GetShapeTypeString(Exp.Current(),Type) ) {
2278 aResult->NameType( Type );
2279 sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) );
2281 aResult->NameType( tr("GEOM_SHAPE") );
2282 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2284 result = new GEOM_AISShape( Exp.Current(), nameG );
2285 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2289 if ( GetShapeTypeString(compound,Type) ) {
2290 aResult->NameType( Type );
2291 sprintf (nameG, "%s_%d", Type, this->myNbGeom++ );
2293 aResult->NameType( tr("GEOM_SHAPE") );
2294 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2296 result = new GEOM_AISShape( compound, nameG );
2297 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2300 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2302 /* open transaction */
2303 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
2306 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2307 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
2308 SALOMEDS::GenericAttribute_var anAttr;
2309 SALOMEDS::AttributeName_var aName;
2310 SALOMEDS::AttributeIOR_var anIOR;
2311 SALOMEDS::AttributePixMap_var aPixmap;
2313 bool allreadyexist = false;
2315 if ( SO->_is_nil() ) {
2316 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2317 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2318 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2319 anIOR->SetValue(aResult->Name());
2320 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2321 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2322 aName->SetValue(result->getName());
2324 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2325 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2326 if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) {
2327 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2328 } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) {
2329 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2330 } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) {
2331 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2332 } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) {
2333 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2334 } else if ( result->Shape().ShapeType() == TopAbs_FACE ) {
2335 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2336 } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) {
2337 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2338 } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) {
2339 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2340 } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) {
2341 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2344 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2345 aStudyBuilder->Addreference(newObj1, newObj);
2347 IO->setEntry(newObj->GetID());
2348 aResult->StudyShapeId(newObj->GetID());
2350 allreadyexist = true;
2351 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2352 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2353 aStudyBuilder->Addreference(newObj1, SO);
2355 IO->setEntry(SO->GetID());
2356 aResult->StudyShapeId(SO->GetID());
2360 /* commit transaction */
2363 result->setIO( IO );
2364 result->setName( nameG );
2366 if ( !allreadyexist )
2367 ic->Display(result);
2369 this->OnDisplayAll(true);
2370 myActiveStudy->updateObjBrowser();
2371 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2377 //=====================================================================================
2378 // function : OnSuppressFaces()
2379 // purpose : To suppress faces from a shape
2380 // : The result is one or more shells/faces as main shapes !
2381 //=====================================================================================
2382 bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
2383 const char* ShapeTopoIOR,
2384 const Standard_Integer& aLocalContextId,
2385 bool& myUseLocalContext )
2387 /* Test the type of viewer */
2388 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2392 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2393 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2394 if ( theObj->_is_nil() ) {
2395 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2399 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2400 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2402 if( myUseLocalContext == false ) {
2403 /* local context is from DialogBox */
2404 MESSAGE("Error : No local context opened for suppress faces method" << endl ) ;
2408 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2410 int nbSelected = ic->NbSelected();
2411 ListOfID->length(nbSelected);
2413 /* Create a list of indices of faces to be suppressed */
2415 const int SubShapeType = 4 ; /* GEOM::FACE type */
2416 ic->InitSelected(); /* to repositioning at beginning */
2417 while( ic->MoreSelected() ) {
2418 int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
2419 ListOfID[i] = index ;
2424 /* Close local context opened in DialogBox */
2425 ic->CloseLocalContext(aLocalContextId) ;
2426 myUseLocalContext = false ;
2428 /* Here is the main shape */
2429 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2430 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
2432 /* Call geom method that return a list of shells/faces as result of suppress */
2434 listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID );
2436 catch (const SALOME::SALOME_Exception& S_ex) {
2437 QtCatchCorbaException(S_ex);
2440 /* Test list of shells/faces */
2441 if( listGeomShapes->length() < 1 ) {
2445 /* Loop on each object created */
2446 for( int i=0; i<listGeomShapes->length(); i++ ) {
2448 GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ;
2449 TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace );
2455 char* nameG = (char *)malloc(20);
2456 Standard_CString Type;
2457 if ( GetShapeTypeString(S, Type) ) {
2458 aShellOrFace->NameType( Type );
2459 sprintf (nameG, "%s_%d", Type, this->myNbGeom++);
2462 aShellOrFace->NameType( tr("GEOM_SHAPE") );
2463 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2466 /* Display with name */
2467 if( !Display( aShellOrFace, nameG) ) {
2468 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
2473 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2478 //=====================================================================================
2479 // function : OnSuppressHole()
2480 // purpose : To suppress an hole on a shape 'ShapeTopo'.
2481 // : 'ListOfIdEndFace' may be an empty list.
2482 // : This means that hole do not traverse ShapeTopo.
2483 // : Warning : the hole to be suppressed must be defined by one or two single closed wires !
2484 //=====================================================================================
2485 bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR,
2486 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
2487 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
2488 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace )
2490 /* Test the type of viewer */
2491 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2496 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2497 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ;
2499 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2500 Standard_CString type;
2501 GetShapeTypeString(S,type);
2502 aResult->NameType( type );
2504 if ( Display( aResult, "" ) )
2505 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2507 catch (const SALOME::SALOME_Exception& S_ex) {
2508 QtCatchCorbaException(S_ex);
2514 //=====================================================================================
2515 // function : OnSuppressHolesInFaceOrShell()
2516 // purpose : To suppress one or more holes on a face
2517 // : 'ListOfIdWires' contains indices or wires/holes.
2518 //=====================================================================================
2519 bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
2520 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires )
2522 /* Test the type of viewer */
2523 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2528 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2529 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ;
2531 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2532 Standard_CString type;
2533 GetShapeTypeString(S,type);
2534 aResult->NameType( type );
2536 if ( Display( aResult, "") )
2537 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2539 catch (const SALOME::SALOME_Exception& S_ex) {
2540 QtCatchCorbaException(S_ex);
2547 //=======================================================================
2548 // function : activeStudyChanged()
2550 //=======================================================================
2551 void GeometryGUI::activeStudyChanged( QAD_Desktop* parent )
2553 MESSAGE ("GeometryGUI::activeStudyChanged init.")
2554 /* Create or retrieve an object GeomGUI */
2555 GeometryGUI::GetOrCreateGeometryGUI(parent);
2558 if (GeomGUI->myState == CURRENT_SKETCH) {
2559 GeomGUI->mySketcher.Clear();
2560 GeomGUI->ResetState();
2563 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2564 bool ViewOCC = false;
2565 if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
2568 Mb->setItemEnabled( 312, ViewOCC); //Sketch
2569 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
2570 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
2572 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2573 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2575 GeomGUI->EraseSimulationShape() ;
2576 GeomGUI->EmitSignalCloseAllDialogs() ;
2580 // GeomGUI->SetSettings( parent );
2581 // MESSAGE ("GeometryGUI::activeStudyChanged done.")
2586 //=======================================================================
2587 // function : DefineDlgPosition()
2588 // purpose : Define x and y the default position for a dialog box
2589 //=======================================================================
2590 bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
2592 /* Here the position is on the bottom right corner - 10 */
2593 QAD_Desktop* PP = QAD_Application::getDesktop() ;
2594 x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
2595 y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
2599 //=======================================================================
2600 // function : OnGUIEvent() [static]
2601 // purpose : manage all events on GUI
2602 //=======================================================================
2603 bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
2605 /* Create or retrieve an object GeomGUI */
2606 GeometryGUI::GetOrCreateGeometryGUI(parent);
2608 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
2609 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2611 OCCViewer_Viewer3d* v3d;
2612 Handle(AIS_InteractiveContext) ic;
2613 vtkRenderer* Renderer;
2615 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2617 bool ViewOCC = false;
2619 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2620 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2621 ic = v3d->getAISContext();
2623 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2624 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2625 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2627 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2628 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2630 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2631 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2633 // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER,
2634 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2635 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2636 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2638 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2639 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2644 if (GeomGUI->myState == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134)
2647 switch (theCommandID)
2650 GeomGUI->OnEditCopy();
2654 GeomGUI->OnEditDelete();
2659 GeomGUI->SetState(111);
2661 GeomGUI->ResetState();
2666 GeomGUI->SetState(112);
2668 GeomGUI->ResetState();
2671 case 113: // IMPORT STEP
2673 GeomGUI->SetState(113);
2675 GeomGUI->ResetState();
2679 case 121: // EXPORT BREP
2681 GeomGUI->SetState(121);
2683 GeomGUI->ResetState();
2687 case 122: // EXPORT IGES
2689 GeomGUI->SetState(122);
2691 GeomGUI->ResetState();
2695 case 123: // EXPORT STEP
2697 GeomGUI->SetState(123);
2699 GeomGUI->ResetState();
2703 case 303: // EXPLODE : use ic
2705 GeomGUI->EmitSignalDeactivateDialog() ;
2706 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2707 GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ;
2711 case 304: // GEOM::EDGE
2713 GeomGUI->EmitSignalDeactivateDialog() ;
2714 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2715 GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ;
2719 case 305: // GEOM::WIRE
2721 GeomGUI->EmitSignalDeactivateDialog() ;
2722 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2723 GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ;
2727 case 306: // GEOM::FACE
2729 GeomGUI->EmitSignalDeactivateDialog() ;
2730 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2731 GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ;
2735 case 308: // GEOM::COMPOUND
2737 GeomGUI->EmitSignalDeactivateDialog() ;
2738 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2739 GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ;
2743 case 309: // SUPPRESS FACES : use ic
2745 GeomGUI->EmitSignalDeactivateDialog() ;
2746 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2747 GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ;
2751 case 314: // SUPPRESS HOLES : use ic
2753 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2754 GeomGUI->EmitSignalDeactivateDialog() ;
2755 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2756 GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ;
2759 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
2765 GeomGUI->EmitSignalDeactivateDialog() ;
2766 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2767 GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ;
2771 case 502: // ORIENTATION
2773 GeomGUI->EmitSignalDeactivateDialog() ;
2774 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2775 GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ;
2779 case 601: // PROPERTIES (Length, surface, volume)
2781 GeomGUI->EmitSignalDeactivateDialog() ;
2782 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2783 GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ;
2787 case 604: // CDG : Center of mass
2789 GeomGUI->EmitSignalDeactivateDialog() ;
2790 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2791 GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ;
2795 case 605: // INERTIA
2797 GeomGUI->EmitSignalDeactivateDialog() ;
2798 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2799 GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ;
2803 case 607: // MAXTOLERANCE
2805 GeomGUI->EmitSignalDeactivateDialog() ;
2806 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2807 GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ;
2813 GeomGUI->EmitSignalDeactivateDialog() ;
2814 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2815 GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ;
2819 case 609: // CHECKSHAPE
2821 GeomGUI->EmitSignalDeactivateDialog() ;
2822 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2823 GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ;
2827 case 701: // SETTINGS - COPY
2830 QMenuItem* item = parent->menuBar()->findItem(701,&pp);
2831 bool check = !pp->isItemChecked(701);
2832 pp->setItemChecked(701,check);
2833 Settings_Copy = check;
2834 QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy );
2838 case 702: // SETTINGS - ADD IN STUDY
2841 QMenuItem* item = parent->menuBar()->findItem(702,&pp);
2842 bool check = !pp->isItemChecked(702);
2843 pp->setItemChecked(702,check);
2844 Settings_AddInStudy = check;
2846 QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy );
2850 case 703: // SETTINGS - SHADING COLOR
2852 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2855 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
2856 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
2857 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
2859 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) {
2860 color = QColor (SCr.toInt(),
2864 Quantity_Color Default = Quantity_Color();
2865 color = QColor ( (int)Default.Red() * 255.0,
2866 (int)Default.Green()* 255.0,
2867 (int)Default.Blue() * 255.0 );
2870 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
2871 if ( c.isValid() ) {
2872 GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0,
2877 AIS_ListOfInteractive List;
2878 ic->DisplayedObjects(List);
2879 AIS_ListOfInteractive List1;
2880 ic->ObjectsInCollector(List1);
2883 AIS_ListIteratorOfListOfInteractive ite(List);
2884 while (ite.More()) {
2885 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
2886 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
2887 aSh->SetShadingColor( GeomGUI->myShadingColor );
2888 ic->Redisplay( aSh, Standard_True, Standard_True);
2893 ic->UpdateCurrentViewer();
2895 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() );
2896 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() );
2897 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() );
2903 case 704: // SETTINGS - ISOS
2905 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2908 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
2909 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
2910 if ( !IsoU.isEmpty() )
2911 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
2914 if ( !IsoV.isEmpty() )
2915 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
2919 GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(),
2920 tr("GEOM_MEN_ISOS"), TRUE );
2921 int UIso = IsoU.toInt();
2922 int VIso = IsoV.toInt();
2924 NbIsosDlg->SpinBoxU->setValue(UIso) ;
2925 NbIsosDlg->SpinBoxV->setValue(VIso) ;
2927 if ( NbIsosDlg->exec() ) {
2928 UIso = NbIsosDlg->SpinBoxU->text().toInt() ;
2929 VIso = NbIsosDlg->SpinBoxV->text().toInt() ;
2931 ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
2932 ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
2933 QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */
2934 QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */
2937 AIS_ListOfInteractive List;
2938 ic->DisplayedObjects(List);
2939 AIS_ListOfInteractive List1;
2940 ic->ObjectsInCollector(List1);
2943 AIS_ListIteratorOfListOfInteractive ite(List);
2945 if ( ic-> NbCurrents() )
2946 while (ite.More()) {
2947 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
2949 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
2950 Handle (AIS_Drawer) CurDrawer;
2951 CurDrawer = ic->Current()->Attributes();
2952 CurDrawer->UIsoAspect()->SetNumber( UIso );
2953 CurDrawer->VIsoAspect()->SetNumber( VIso );
2954 ic->SetLocalAttributes(aSh, CurDrawer);
2959 ic->UpdateCurrentViewer();
2963 case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES
2965 //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2968 QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
2969 if( step.isEmpty() )
2972 Standard_Boolean res = false ;
2973 double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ;
2975 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ;
2977 /* Emit signal to GeometryGUI_SpinBoxes */
2978 GeomGUI->SignalDefaultStepValueChanged( dd ) ;
2981 parent->putInfo(tr("GEOM_PRP_ABORT"));
2986 case 801: // ADD IN STUDY - POPUP VIEWER
2988 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2989 const SALOME_ListIO& ListSelected = Sel->StoredIObjects();
2990 SALOME_ListIteratorOfListIO It( ListSelected );
2991 for ( ; It.More(); It.Next() ) {
2992 Handle(SALOME_InteractiveObject) IObject = It.Value();
2993 GeomGUI->AddInStudy(true, IObject);
2995 /* Is set on the dialog box */
2996 QApplication::restoreOverrideCursor();
3002 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3003 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3004 for ( ; It.More(); It.Next() ) {
3005 Handle(SALOME_InteractiveObject) IObject = It.Value();
3007 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3008 SALOMEDS::GenericAttribute_var anAttr;
3009 SALOMEDS::AttributeName_var aName;
3010 if ( !obj->_is_nil() ) {
3011 if (obj->FindAttribute(anAttr, "AttributeName")) {
3012 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3014 QString nm = QString( aName->Value() );
3015 nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
3016 if ( !nm.isEmpty() ) {
3017 QApplication::setOverrideCursor( Qt::waitCursor );
3018 GeomGUI->myActiveStudy->renameIObject( IObject, nm );
3019 QApplication::restoreOverrideCursor();
3027 case 903: // DISPLAY OBJECT BROWSER
3029 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3031 QApplication::setOverrideCursor( Qt::waitCursor );
3033 SALOMEDS::SObject_var fatherSF =
3034 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3036 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3037 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3039 for(;It.More();It.Next()) {
3040 Handle(SALOME_InteractiveObject) IObject = It.Value();
3041 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3043 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3045 SALOMEDS::GenericAttribute_var anAttr;
3046 SALOMEDS::AttributeName_var aName;
3047 SALOMEDS::AttributeIOR_var anIOR;
3049 if(myRenderInter->isInViewer(IObject)) {
3050 myRenderInter->Display(IObject);
3054 if ( !obj->_is_nil() ) {
3055 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3056 // this SObject may be GEOM module root SObject
3057 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3058 bool useSubItems = false;
3059 while (anIter->More() && !useSubItems) {
3060 SALOMEDS::SObject_var subobj = anIter->Value();
3061 SALOMEDS::GenericAttribute_var aTmpAttr;
3062 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3066 } else anIter->Next();
3069 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3070 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3071 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3072 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3074 if (obj->FindAttribute(anAttr, "AttributeName")) {
3075 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3077 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3078 vtkActorCollection* theAllActors = theRenderer->GetActors();
3079 theAllActors->InitTraversal();
3080 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3081 Handle(SALOME_InteractiveObject) anIObj;
3082 // don't create new study object if it already exists
3083 bool isDisplayed = false;
3084 while(!(actor==NULL)) {
3085 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3087 if (Gactor->hasIO()) {
3088 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3090 anIObj = Gactor->getIO();
3091 if (!anIObj.IsNull()) myRenderInter->Display(anIObj);
3095 actor=(vtkActor*)(theAllActors->GetNextActor());
3099 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3102 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3103 aStudyBuilder->Addreference(newObj1, obj);
3104 // commit transaction
3107 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
3108 int themode = myRenderInter->GetDisplayMode();
3110 vtkActorCollection* theActors =
3111 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
3112 theActors->InitTraversal();
3113 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
3114 while(!(anActor==NULL)) {
3115 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
3116 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
3117 IO->setEntry(obj->GetID());
3118 GActor->setIO( IO );
3119 GActor->setName( IObject->getName() );
3121 theRenderer->AddActor(GActor);
3123 anActor = (vtkActor*)theActors->GetNextActor();
3127 // next item iteration
3130 anAttr = SALOMEDS::GenericAttribute::_nil();
3131 while (anIter->More() && anAttr->_is_nil()) {
3132 SALOMEDS::SObject_var subobject = anIter->Value();
3133 SALOMEDS::GenericAttribute_var aTmpAttribute;
3134 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3135 anAttr = aTmpAttribute;
3137 } else anIter->Next();
3139 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3145 GeomGUI->myActiveStudy->updateObjBrowser( true );
3146 QApplication::restoreOverrideCursor();
3148 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3149 QApplication::setOverrideCursor( Qt::waitCursor );
3151 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3152 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3153 for(;It.More();It.Next()) {
3154 Handle(SALOME_InteractiveObject) IObject = It.Value();
3156 SALOMEDS::SObject_var fatherSF =
3157 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3158 SALOMEDS::GenericAttribute_var anAttr;
3159 SALOMEDS::AttributeName_var aName;
3160 SALOMEDS::AttributeIOR_var anIOR;
3162 if ( v3d->isInViewer( IObject, true ) ) {
3163 Standard_Boolean found;
3164 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3167 ic->AddOrRemoveCurrentObject(aSh, true);
3171 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3172 if ( !obj->_is_nil() ) {
3173 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3174 // this SObject may be GEOM module root SObject
3175 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3176 bool useSubItems = false;
3177 while (anIter->More() && !useSubItems) {
3178 SALOMEDS::SObject_var subobj = anIter->Value();
3179 SALOMEDS::GenericAttribute_var aTmpAttr;
3180 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3184 } else anIter->Next();
3186 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3187 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3188 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3189 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3190 if (obj->FindAttribute(anAttr, "AttributeName")) {
3191 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3192 // searchin for already displayed objects with the same shape
3193 AIS_ListOfInteractive aDisplayed;
3194 ic->DisplayedObjects(aDisplayed);
3195 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3196 Handle(AIS_Shape) anAISShape;
3197 for(;anIObjects.More();anIObjects.Next()) {
3198 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3199 if (!anAISShape.IsNull()) {
3200 if (anAISShape->Shape().IsSame(Shape)) break;
3201 anAISShape.Nullify();
3204 if (!anAISShape.IsNull()) {
3205 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape);
3209 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3212 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3213 aStudyBuilder->Addreference(newObj1, obj);
3214 // commit transaction
3218 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
3219 aSh->SetShadingColor( GeomGUI->myShadingColor );
3220 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
3223 IO->setEntry(obj->GetID());
3225 aSh->setName( aName->Value() );
3227 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true);
3230 // next item iteration
3233 anAttr=SALOMEDS::GenericAttribute::_nil();
3234 while (anIter->More() && anAttr->_is_nil()) {
3235 SALOMEDS::SObject_var subobject = anIter->Value();
3236 SALOMEDS::GenericAttribute_var aTmpAttribute;
3237 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3238 anAttr = aTmpAttribute;
3240 } else anIter->Next();
3242 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3248 GeomGUI->myActiveStudy->updateObjBrowser( true );
3249 QApplication::restoreOverrideCursor();
3256 GeomGUI->EmitSignalDeactivateDialog() ;
3257 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3258 GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ;
3264 GeomGUI->EmitSignalDeactivateDialog() ;
3265 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3266 GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ;
3270 case 3013: // CIRCLE
3272 GeomGUI->EmitSignalDeactivateDialog() ;
3273 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3274 GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ;
3280 GeomGUI->EmitSignalDeactivateDialog() ;
3281 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3282 GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ;
3286 case 3016: // VECTOR
3288 GeomGUI->EmitSignalDeactivateDialog() ;
3289 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3290 GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ;
3296 GeomGUI->EmitSignalDeactivateDialog() ;
3297 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3298 GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ;
3302 case 3018: // WORKING PLANE
3304 GeomGUI->EmitSignalDeactivateDialog() ;
3305 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3306 GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ;
3310 case 312: // SKETCHER
3312 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
3315 GeomGUI->EmitSignalDeactivateDialog() ;
3317 ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
3319 GeomGUI->mySketcher = Sketch( v3d->getViewer3d() );
3320 GeomGUI->SetState(CURRENT_SKETCH);
3322 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3325 QMenuItem* item = Mb->findItem(10010,&pp);
3326 GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
3327 item = Mb->findItem(10011,&pp);
3328 GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
3329 item = Mb->findItem(10012,&pp);
3330 GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
3331 item = Mb->findItem(10013,&pp);
3332 GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
3333 item = Mb->findItem(10014,&pp);
3334 GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
3336 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3337 item = Mb->findItem(3133,&pp);
3338 pp->setItemChecked(3133,false);
3339 item = Mb->findItem(3134,&pp);
3340 pp->setItemChecked(3134,false);
3346 GeomGUI->EmitSignalDeactivateDialog() ;
3347 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3348 GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ;
3352 case 3022: // CYLINDER
3354 GeomGUI->EmitSignalDeactivateDialog() ;
3355 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3356 GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ;
3360 case 3023: // SPHERE
3362 GeomGUI->EmitSignalDeactivateDialog() ;
3363 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3364 GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ;
3370 GeomGUI->EmitSignalDeactivateDialog() ;
3371 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3372 GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ;
3378 GeomGUI->EmitSignalDeactivateDialog() ;
3379 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3380 GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ;
3389 case 3133: // sketcher
3391 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3393 QMenuItem* item = Mb->findItem(3133,&pp);
3394 pp->setItemChecked(3133,!pp->isItemChecked(3133));
3395 if (pp->isItemChecked(3133) == true)
3396 GeomGUI->mySketcher.SetTransitionStatus(TANGENT);
3398 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3400 pp->setItemChecked(3134,false);
3404 case 3134: // sketcher
3406 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3408 QMenuItem* item = Mb->findItem(3134,&pp);
3409 pp->setItemChecked(3134,!pp->isItemChecked(3134));
3410 if (pp->isItemChecked(3134) == true)
3411 GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR);
3413 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3415 pp->setItemChecked(3133,false);
3421 GeomGUI->EmitSignalDeactivateDialog() ;
3422 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3423 GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ;
3427 case 4012: // COMMON
3429 GeomGUI->EmitSignalDeactivateDialog() ;
3430 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3431 GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ;
3437 GeomGUI->EmitSignalDeactivateDialog() ;
3438 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3439 GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ;
3443 case 4014: // SECTION
3445 GeomGUI->EmitSignalDeactivateDialog() ;
3446 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3447 GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ;
3451 case 4021: // TRANSLATION
3453 GeomGUI->EmitSignalDeactivateDialog() ;
3454 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3455 GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ;
3459 case 4022: // ROTATION
3461 GeomGUI->EmitSignalDeactivateDialog() ;
3462 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3463 GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ;
3467 case 4030: // MULTI TRANSLATION
3469 GeomGUI->EmitSignalDeactivateDialog() ;
3470 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3471 GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ;
3475 case 4040: // MULTI ROTATION
3477 GeomGUI->EmitSignalDeactivateDialog() ;
3478 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3479 GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ;
3483 case 4023: // MIRROR
3485 GeomGUI->EmitSignalDeactivateDialog() ;
3486 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3487 GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ;
3493 GeomGUI->EmitSignalDeactivateDialog() ;
3494 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3495 GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ;
3499 case 4025: // PARTITION
3501 GeomGUI->EmitSignalDeactivateDialog() ;
3502 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3503 GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ;
3507 case 4026: // ARCHIMEDE
3509 GeomGUI->EmitSignalDeactivateDialog() ;
3510 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3511 GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ;
3515 case 4027: // FILLET
3517 GeomGUI->EmitSignalDeactivateDialog() ;
3518 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3519 GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ;
3523 case 4028: // CHAMFER
3525 GeomGUI->EmitSignalDeactivateDialog() ;
3526 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3527 GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ;
3533 GeomGUI->EmitSignalDeactivateDialog() ;
3534 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3535 GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ;
3541 GeomGUI->EmitSignalDeactivateDialog() ;
3542 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3543 GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ;
3547 case 4033: // FILLING
3549 GeomGUI->EmitSignalDeactivateDialog() ;
3550 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3551 GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ;
3557 GeomGUI->EmitSignalDeactivateDialog() ;
3558 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3559 GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ;
3563 case 5001: // CHECK GEOMETRY
3565 QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor();
3566 PyEditor->setText("from GEOM_usinggeom import *\n");
3567 PyEditor->setText(">>> ");
3568 PyEditor->handleReturn();
3572 case 6021: // SHADING - WIREFRAME
3574 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3575 VTKViewer_RenderWindowInteractor* myRenderInter=
3576 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3578 QApplication::setOverrideCursor(waitCursor);
3580 int themode = myRenderInter->GetDisplayMode();
3582 myRenderInter->SetDisplayMode(1);
3583 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3585 myRenderInter->SetDisplayMode(0);
3586 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3589 QApplication::restoreOverrideCursor();
3591 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3592 AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode();
3593 QApplication::setOverrideCursor( Qt::waitCursor );
3594 AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
3596 AIS_ListOfInteractive List;
3597 ic->DisplayedObjects(List);
3598 AIS_ListOfInteractive List1;
3599 ic->ObjectsInCollector(List1);
3602 AIS_ListIteratorOfListOfInteractive ite(List);
3603 while (ite.More()) {
3604 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3605 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3606 ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
3611 ic->SetDisplayMode( newmode, Standard_False);
3613 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3615 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3617 QApplication::restoreOverrideCursor();
3622 case 6022: // DISPLAY ALL
3624 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3626 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll();
3627 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
3628 GeomGUI->OnDisplayAll();
3632 case 6023: // DISPLAY ONLY
3633 case 8023: // DISPLAY ONLY - POPUP VIEWER
3635 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3637 GeomGUI->OnVTKDisplayOnly();
3639 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
3640 GeomGUI->OnDisplayOnly();
3644 case 6024: // ERASE ALL
3646 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3648 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
3650 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3651 ic->EraseAll(Standard_True, Standard_False);
3652 ic->Display(v3d->getTrihedron());
3655 //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3656 //NRI Sel->ClearInteractiveObjects();
3660 case 6025 : // ERASE ONLY
3661 case 8022 : // ERASE - POPUP VIEWER
3663 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3664 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3666 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3667 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3668 Handle(SALOME_InteractiveObject) anIObject;
3669 for(;It.More();It.Next()) {
3670 anIObject = It.Value();
3671 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3673 if(myRenderInter->isInViewer(anIObject)) {
3674 myRenderInter->Erase(anIObject);
3676 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3677 SALOMEDS::GenericAttribute_var anAttr;
3678 SALOMEDS::AttributeIOR_var anIOR;
3679 if ( !obj->_is_nil() ) {
3680 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3681 // this SObject may be GEOM module root SObject
3682 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3683 bool useSubItems = false;
3684 while (anIter->More() && !useSubItems) {
3685 SALOMEDS::SObject_var subobj = anIter->Value();
3686 SALOMEDS::GenericAttribute_var aTmpAttr;
3687 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3691 } else anIter->Next();
3694 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3695 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3696 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3697 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3698 if (obj->FindAttribute(anAttr, "AttributeName")) {
3699 // searchin for already displayed objects with the same shape
3700 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3701 vtkActorCollection* theAllActors = theRenderer->GetActors();
3702 theAllActors->InitTraversal();
3703 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3704 Handle(SALOME_InteractiveObject) anIObj;
3705 // don't create new study object if it already exists
3706 bool isDisplayed = false;
3707 while(!(actor==NULL)) {
3708 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3710 if (Gactor->hasIO()) {
3711 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3713 anIObj = Gactor->getIO();
3714 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
3718 actor=(vtkActor*)(theAllActors->GetNextActor());
3723 anAttr=SALOMEDS::GenericAttribute::_nil();
3724 while (anIter->More() && anAttr->_is_nil()) {
3725 SALOMEDS::SObject_var subobject = anIter->Value();
3726 SALOMEDS::GenericAttribute_var aTmpAttribute;
3727 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3728 anAttr = aTmpAttribute;
3730 } else anIter->Next();
3732 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3738 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3739 // for(;It.More();It.Next()) {
3740 // Handle(SALOME_InteractiveObject) IOS = It.Value();
3741 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
3743 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3745 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3746 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3747 Handle(SALOME_InteractiveObject) anIObject;
3748 for(;It.More();It.Next()) {
3749 anIObject = It.Value();
3750 if ( v3d->isInViewer( anIObject, true ) ) {
3751 Standard_Boolean found;
3752 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
3755 ic->AddOrRemoveCurrentObject(aSh, true);
3758 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3759 SALOMEDS::GenericAttribute_var anAttr;
3760 SALOMEDS::AttributeIOR_var anIOR;
3761 if ( !obj->_is_nil() ) {
3762 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3763 // this SObject may be GEOM module root SObject
3764 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3765 bool useSubItems = false;
3766 while (anIter->More() && !useSubItems) {
3767 SALOMEDS::SObject_var subobj = anIter->Value();
3768 SALOMEDS::GenericAttribute_var aTmpAttr;
3769 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3773 } else anIter->Next();
3776 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3777 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3778 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3779 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3780 if (obj->FindAttribute(anAttr, "AttributeName")) {
3781 // searchin for already displayed objects with the same shape
3782 AIS_ListOfInteractive aDisplayed;
3783 ic->DisplayedObjects(aDisplayed);
3784 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3785 Handle(AIS_Shape) anAISShape;
3786 for(;anIObjects.More();anIObjects.Next()) {
3787 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3788 if (!anAISShape.IsNull()) {
3789 if (anAISShape->Shape().IsSame(Shape)) break;
3790 anAISShape.Nullify();
3793 if (!anAISShape.IsNull()) {
3794 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
3799 anAttr=SALOMEDS::GenericAttribute::_nil();
3800 while (anIter->More() && anAttr->_is_nil()) {
3801 SALOMEDS::SObject_var subobject = anIter->Value();
3802 SALOMEDS::GenericAttribute_var aTmpAttribute;
3803 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3804 anAttr = aTmpAttribute;
3806 } else anIter->Next();
3808 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3815 Sel->ClearIObjects();
3820 case 6060: // BOUNDING BOX
3822 GeomGUI->EmitSignalDeactivateDialog() ;
3823 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3824 GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ;
3828 case 6061: // MIN DISTANCE
3830 GeomGUI->EmitSignalDeactivateDialog() ;
3831 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3832 GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ;
3836 case 8021: // WIREFRAME-SHADING
3838 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3840 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3842 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3843 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3845 QApplication::setOverrideCursor( Qt::waitCursor );
3846 for(;It.More();It.Next()) {
3847 Handle(SALOME_InteractiveObject) IOS = It.Value();
3848 myRenderInter->SwitchRepresentation(IOS, false);
3850 myRenderInter->Render();
3851 QApplication::restoreOverrideCursor();
3853 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3854 QApplication::setOverrideCursor( Qt::waitCursor );
3855 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3856 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3857 for(;It.More();It.Next()) {
3858 Handle(SALOME_InteractiveObject) IObject = It.Value();
3859 Standard_Boolean found;
3860 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3861 if (!Shape.IsNull()) {
3862 AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode();
3864 mode = ( AIS_DisplayMode )ic->DisplayMode();
3866 QApplication::setOverrideCursor( Qt::waitCursor );
3867 ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
3869 QApplication::restoreOverrideCursor();
3871 ic->UpdateCurrentViewer();
3873 QApplication::restoreOverrideCursor();
3877 case 8031: // COLOR - POPUP VIEWER
3879 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3881 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3883 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3884 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3886 Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject();
3887 if(!FirstIOS.IsNull()) {
3889 QColor initcolor = myRenderInter->GetColor(FirstIOS);
3891 QColor c = QColorDialog::getColor( initcolor,
3892 QAD_Application::getDesktop() );
3894 if ( c.isValid() ) {
3895 QApplication::setOverrideCursor( Qt::waitCursor );
3896 for(;It.More();It.Next()) {
3897 Handle(SALOME_InteractiveObject) IOS = It.Value();
3898 myRenderInter->SetColor(IOS,c);
3901 QApplication::restoreOverrideCursor();
3904 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3905 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3906 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
3907 Standard_Boolean found;
3908 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true);
3910 Quantity_Color CSFColor;
3911 Shape->Color( CSFColor );
3913 QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0,
3914 CSFColor.Green()* 255.0,
3915 CSFColor.Blue() * 255.0 ),
3916 QAD_Application::getDesktop() );
3918 if ( c.isValid() ) {
3919 CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
3920 QApplication::setOverrideCursor( Qt::waitCursor );
3922 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3923 for(;It.More();It.Next()) {
3924 Handle(SALOME_InteractiveObject) IObject = It.Value();
3925 Standard_Boolean found;
3926 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
3928 Shape->SetColor ( CSFColor );
3929 Shape->SetShadingColor ( CSFColor );
3935 QApplication::restoreOverrideCursor();
3939 case 8032: // TRANSPARENCY - POPUP VIEWER
3941 GeomGUI->EmitSignalDeactivateDialog() ;
3942 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3943 GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ;
3947 case 8033: // ISOS - POPUP VIEWER
3949 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
3953 if ( ic->MoreCurrent() ) {
3954 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
3955 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
3956 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
3958 if ( !IsoU.isEmpty() )
3959 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
3962 if ( !IsoV.isEmpty() )
3963 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
3967 GeometryGUI_NbIsosDlg * NbIsosDlg =
3968 new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE );
3970 NbIsosDlg->SpinBoxU->setValue(IsoU.toInt());
3971 NbIsosDlg->SpinBoxV->setValue(IsoV.toInt());
3973 if ( NbIsosDlg->exec() ) {
3974 QApplication::setOverrideCursor( Qt::waitCursor );
3975 for ( ; ic->MoreCurrent (); ic->NextCurrent () ) {
3976 Handle (AIS_Drawer) CurDrawer;
3978 CurDrawer = ic->Current()->Attributes();
3979 CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() );
3980 CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() );
3982 ic->SetLocalAttributes(CurObject, CurDrawer);
3983 ic->Redisplay(CurObject);
3988 QApplication::restoreOverrideCursor();
3992 case 9022 : // ERASE - OBJBROSER POPUP
3994 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3995 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3997 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3998 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3999 Handle(SALOME_InteractiveObject) anIObject;
4000 for(;It.More();It.Next()) {
4001 anIObject = It.Value();
4002 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4004 // Handle(SALOME_InteractiveObject) IObject;
4005 if(myRenderInter->isInViewer(anIObject)) {
4006 myRenderInter->Erase(anIObject);
4008 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4009 SALOMEDS::GenericAttribute_var anAttr;
4010 SALOMEDS::AttributeIOR_var anIOR;
4011 if ( !obj->_is_nil() ) {
4012 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4013 // this SObject may be GEOM module root SObject
4014 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4015 bool useSubItems = false;
4016 while (anIter->More() && !useSubItems) {
4017 SALOMEDS::SObject_var subobj = anIter->Value();
4018 SALOMEDS::GenericAttribute_var aTmpAttr;
4019 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4023 } else anIter->Next();
4026 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4027 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4028 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4029 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4030 if (obj->FindAttribute(anAttr, "AttributeName")) {
4031 // searchin for already displayed objects with the same shape
4032 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4033 vtkActorCollection* theAllActors = theRenderer->GetActors();
4034 theAllActors->InitTraversal();
4035 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
4036 Handle(SALOME_InteractiveObject) anIObj;
4037 // don't create new study object if it already exists
4038 bool isDisplayed = false;
4039 while(!(actor==NULL)) {
4040 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
4042 if (Gactor->hasIO()) {
4043 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
4045 anIObj = Gactor->getIO();
4046 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
4050 actor=(vtkActor*)(theAllActors->GetNextActor());
4055 anAttr=SALOMEDS::GenericAttribute::_nil();
4056 while (anIter->More() && anAttr->_is_nil()) {
4057 SALOMEDS::SObject_var subobject = anIter->Value();
4058 SALOMEDS::GenericAttribute_var aTmpAttribute;
4059 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4060 anAttr = aTmpAttribute;
4062 } else anIter->Next();
4064 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4069 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4070 // for(;It.More();It.Next()) {
4071 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4072 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4074 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4075 // for(;It.More();It.Next()) {
4076 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4077 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4080 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
4082 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4083 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4084 Handle(SALOME_InteractiveObject) anIObject;
4085 for(;It.More();It.Next()) {
4086 anIObject = It.Value();
4087 if ( v3d->isInViewer( anIObject, true ) ) {
4088 Standard_Boolean found;
4089 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
4092 ic->AddOrRemoveCurrentObject(aSh, true);
4095 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4096 SALOMEDS::GenericAttribute_var anAttr;
4097 SALOMEDS::AttributeIOR_var anIOR;
4098 if ( !obj->_is_nil() ) {
4099 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4100 // this SObject may be GEOM module root SObject
4101 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4102 bool useSubItems = false;
4103 while (anIter->More() && !useSubItems) {
4104 SALOMEDS::SObject_var subobj = anIter->Value();
4105 SALOMEDS::GenericAttribute_var aTmpAttr;
4106 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4110 } else anIter->Next();
4113 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4114 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4115 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4116 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4117 if (obj->FindAttribute(anAttr, "AttributeName")) {
4118 // searchin for already displayed objects with the same shape
4119 AIS_ListOfInteractive aDisplayed;
4120 ic->DisplayedObjects(aDisplayed);
4121 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
4122 Handle(AIS_Shape) anAISShape;
4123 for(;anIObjects.More();anIObjects.Next()) {
4124 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
4125 if (!anAISShape.IsNull()) {
4126 if (anAISShape->Shape().IsSame(Shape)) break;
4127 anAISShape.Nullify();
4130 if (!anAISShape.IsNull()) {
4131 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
4136 anAttr=SALOMEDS::GenericAttribute::_nil();
4137 while (anIter->More() && anAttr->_is_nil()) {
4138 SALOMEDS::SObject_var subobject = anIter->Value();
4139 SALOMEDS::GenericAttribute_var aTmpAttribute;
4140 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4141 anAttr = aTmpAttribute;
4143 } else anIter->Next();
4145 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4151 // QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC();
4152 // Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4153 // myContext->EraseSelected();
4156 Sel->ClearIObjects();
4160 case 9023 : // DISPLAY ONLY - OBJBROSER POPUP
4162 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
4163 GeomGUI->OnVTKDisplayOnly();
4164 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
4165 GeomGUI->OnDisplayOnly();
4169 case 9024 : // OPEN - OBJBROSER POPUP
4171 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4172 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4173 Handle(SALOME_InteractiveObject) anIObject;
4174 for(;It.More();It.Next()) {
4175 anIObject = It.Value();
4176 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4177 SALOMEDS::AttributePersistentRef_var aPersist;
4178 SALOMEDS::AttributeIOR_var anIOR;
4179 if ( !obj->_is_nil() ) {
4180 // this SObject may be GEOM module root SObject
4181 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4182 SALOMEDS::GenericAttribute_var anAttr;
4183 bool useSubItems = false;
4184 while (anIter->More() && !useSubItems) {
4185 SALOMEDS::SObject_var subobj = anIter->Value();
4186 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
4190 else anIter->Next();
4192 obj->FindAttribute(anAttr, "AttributePersistentRef");
4194 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4195 if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
4196 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
4198 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","GEOM");
4199 if (!CORBA::is_nil(comp)) {
4200 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
4203 SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder();
4204 aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver);
4207 MESSAGE("Component is null");
4212 obj = anIter->Value();
4213 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4220 case 10000 : // SKETCH Segment
4222 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4224 GeomGUI->OnSketchSegment();
4227 case 10001 : // SKETCH Arc
4229 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4231 GeomGUI->OnSketchArc();
4234 case 10002 : // SKETCH Set Angle
4236 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4238 GeomGUI->OnSketchSetAngle();
4241 case 10003 : // SKETCH Set X
4243 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4245 GeomGUI->OnSketchSetx();
4248 case 10004 : // SKETCH Set Y
4250 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4252 GeomGUI->OnSketchSety();
4255 case 10006 : // SKETCH Delete
4257 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4259 GeomGUI->OnSketchDelete();
4262 case 10007 : // SKETCH End
4264 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4266 GeomGUI->OnSketchEnd();
4269 case 10008 : // SKETCH Close
4271 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4273 GeomGUI->OnSketchClose();
4276 case 10010 : // SKETCH OptionsOnofflengthdimension
4278 GeomGUI->OnSketchOptionsOnofflengthdimension();
4281 case 10011 : // SKETCH OptionsOnoffangledimension
4283 GeomGUI->OnSketchOptionsOnoffangledimension();
4286 case 10012 : // SKETCH OptionsOnoffradiusdimension
4288 GeomGUI->OnSketchOptionsOnoffradiusdimension();
4291 case 10013 : // SKETCH OptionsOnoffxdimension
4293 GeomGUI->OnSketchOptionsOnoffxdimension();
4296 case 10014 : // SKETCH OptionsOnoffydimension
4298 GeomGUI->OnSketchOptionsOnoffydimension();
4304 parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) );
4312 //=======================================================================
4313 // function : ConvertClickToPoint()
4314 // purpose : Returns the point clicked in 3D view
4315 //=======================================================================
4316 gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x,
4318 Handle(V3d_View) aView )
4320 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
4321 aView->Eye(XEye, YEye, ZEye);
4323 aView->At(XAt, YAt, ZAt);
4324 gp_Pnt EyePoint(XEye, YEye, ZEye);
4325 gp_Pnt AtPoint(XAt, YAt, ZAt);
4327 gp_Vec EyeVector(EyePoint, AtPoint);
4328 gp_Dir EyeDir(EyeVector);
4330 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
4331 Standard_Real X, Y, Z;
4332 aView->Convert(x, y, X, Y, Z);
4333 gp_Pnt ConvertedPoint(X, Y, Z);
4335 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint);
4336 gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
4337 ConvertedPointOnPlane.Y(),
4345 //==================================================================================
4346 // function : 0nMousePress()
4347 // purpose : [static] manage mouse events
4348 //==================================================================================
4349 bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4351 MESSAGE ( "GeometryGUI::OnMousePress")
4352 GeometryGUI::GetOrCreateGeometryGUI(parent);
4354 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4357 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4358 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4359 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4361 /* Get the clicked or selected point */
4364 if ( GeomGUI->myState == CURRENT_SKETCH) {
4365 GeomGUI->mySketcher.ValidateEdge();
4366 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
4367 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
4369 QMenuItem* item = Mb->findItem(313,&pp);
4370 pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS
4372 } else if( GeomGUI->myState == POINT_METHOD ) {
4374 GeomGUI->EraseSimulationShape() ;
4375 GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ;
4377 if ( DialogPt->UseLocalContext() ) {
4379 if ( pe->state() == Qt::ShiftButton )
4380 v3d->getAISSelector()->shiftSelect(); /* Append selection */
4382 v3d->getAISSelector()->select(); /* New selection */
4384 if ( ic->MoreSelected() ) {
4385 thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) );
4388 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4391 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4393 if( DialogPt != 0 ) {
4394 DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */
4397 // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ;
4398 GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
4406 //=======================================================================
4407 // function : OnMouseMove()
4408 // purpose : [static] manage mouse events
4409 //=======================================================================
4410 bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4412 GeometryGUI::GetOrCreateGeometryGUI(parent);
4414 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4417 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4418 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4419 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4421 if ( GeomGUI->myState == CURRENT_SKETCH)
4422 GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
4428 //================================================================================
4429 // function : SetDisplayedObjectList()
4431 //================================================================================
4432 void GeometryGUI::SetDisplayedObjectList()
4434 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4437 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4438 ListDisplayedObject.Clear();
4440 Handle (AIS_InteractiveContext) aContext = v3d->getAISContext();
4441 aContext->DisplayedObjects( ListDisplayedObject );
4446 //=====================================================================================
4447 // function : OnDisplayAll()
4449 //=====================================================================================
4450 void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
4452 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4455 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4456 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4458 myContext->Display(v3d->getTrihedron());
4460 if ( !onlyPreviousDisplayedObject ) {
4461 AIS_ListOfInteractive List1;
4462 myContext->ObjectsInCollector(List1);
4463 AIS_ListIteratorOfListOfInteractive ite1(List1);
4464 while (ite1.More()) {
4465 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4466 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4467 if ( aSh->hasIO() ) {
4468 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4469 if ( v3d->isInViewer(GIO, true) ) {
4470 myContext->Display(aSh);
4477 AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject);
4478 while (ite.More()) {
4479 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4480 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4481 if ( aSh->hasIO() ) {
4482 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4483 if ( v3d->isInViewer(GIO,true) ) {
4484 myContext->Display(aSh);
4496 //=====================================================================================
4497 // function : OnVTKDisplayOnly()
4499 //=====================================================================================
4500 void GeometryGUI::OnVTKDisplayOnly()
4503 // Erase all not selected actors
4505 QApplication::setOverrideCursor( Qt::waitCursor );
4507 vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4508 vtkActorCollection* theActors = aren->GetActors();
4509 theActors->InitTraversal();
4510 vtkActor *ac = theActors->GetNextActor();
4511 while(!(ac==NULL)) {
4512 if ( ac->IsA("SALOME_Actor") ) {
4513 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
4514 if(!anActor->isHighlighted()) anActor->VisibilityOff();
4516 ac = theActors->GetNextActor();
4519 // Display selection
4520 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4521 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4522 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
4523 SALOMEDS::GenericAttribute_var anAttr;
4524 SALOMEDS::AttributeName_var aName;
4525 SALOMEDS::AttributeIOR_var anIOR;
4527 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4528 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4530 for(;It.More();It.Next()) {
4531 Handle(SALOME_InteractiveObject) IObject = It.Value();
4532 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4534 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4536 if(myRenderInter->isInViewer(IObject)) {
4537 myRenderInter->Display(IObject);
4541 if ( !obj->_is_nil() ) {
4542 if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
4544 // If selected object contains displayable subobjects, then do nothing
4545 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4546 SALOMEDS::GenericAttribute_var aTmpAttr;
4548 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4549 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4550 if (CORBA::is_nil(aShape)) continue;
4551 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4553 if (obj->FindAttribute(anAttr, "AttributeName")) {
4554 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4556 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
4559 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4560 aStudyBuilder->Addreference(newObj1, obj);
4561 // commit transaction
4564 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4565 int themode = myRenderInter->GetDisplayMode();
4566 vtkActorCollection* theActors =
4567 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
4568 theActors->InitTraversal();
4569 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
4570 while(!(anActor==NULL)) {
4571 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
4572 GActor->setIO( IObject );
4573 GActor->setName( IObject->getName() );
4575 theRenderer->AddActor(GActor);
4576 vtkRenderWindow *renWin
4577 = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
4579 anActor = (vtkActor*)theActors->GetNextActor();
4585 GeomGUI->myActiveStudy->updateObjBrowser( true );
4586 QApplication::restoreOverrideCursor();
4591 //=====================================================================================
4592 // function : OnDisplayOnly()
4594 //=====================================================================================
4595 void GeometryGUI::OnDisplayOnly()
4597 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4600 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4601 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4602 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4604 AIS_ListOfInteractive List;
4605 ic->DisplayedObjects(List);
4606 AIS_ListIteratorOfListOfInteractive ite(List);
4607 while (ite.More()) {
4608 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4609 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4610 if (!ic->IsSelected( aSh )) {
4611 ic->Erase( aSh, Standard_True, Standard_True );
4617 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4618 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4620 SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
4621 for(;It1.More();It1.Next()) {
4622 Handle(SALOME_InteractiveObject) IObject = It1.Value();
4625 SALOMEDS::SObject_var fatherSF =
4626 aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
4627 if ( v3d->isInViewer( IObject, true ) ) {
4628 AIS_ListOfInteractive List1;
4629 ic->ObjectsInCollector(List1);
4630 AIS_ListIteratorOfListOfInteractive ite1(List1);
4631 while (ite1.More()) {
4632 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4633 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4634 if ( aSh->hasIO() ) {
4635 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4636 if ( IObject->isSame( GIO ) ) {
4638 ic->AddOrRemoveCurrentObject(aSh, true);
4646 if ( IObject->hasEntry() ) {
4647 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4648 SALOMEDS::GenericAttribute_var anAttr;
4649 SALOMEDS::AttributeName_var aName;
4650 SALOMEDS::AttributeIOR_var anIOR;
4651 if ( !obj->_is_nil() ) {
4652 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
4653 // this SObject may be GEOM module root SObject
4655 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4656 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
4657 if (CORBA::is_nil(aShape)) continue;
4658 TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape);
4660 if (obj->FindAttribute(anAttr, "AttributeName")) {
4661 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4663 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4666 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4667 aStudyBuilder->Addreference(newObj1, obj);
4668 // commit transaction
4672 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
4673 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
4675 IO->setEntry(obj->GetID());
4677 aSh->setName( aName->Value() );
4679 ic->AddOrRemoveCurrentObject(aSh, true);
4688 //===============================================================================
4689 // function : OnEditDelete()
4691 //===============================================================================
4692 void GeometryGUI::OnEditDelete()
4694 if ( QAD_MessageBox::warn2
4695 ( QAD_Application::getDesktop(),
4696 tr ("GEOM_WRN_WARNING"),
4697 tr ("GEOM_REALLY_DELETE"),
4698 tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 )
4701 int nbSf = myActiveStudy->getStudyFramesCount();
4703 Standard_Boolean found;
4704 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4705 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4706 SALOMEDS::GenericAttribute_var anAttr;
4707 SALOMEDS::AttributeIOR_var anIOR;
4709 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4710 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4711 for(;It.More();It.Next()) {
4712 Handle(SALOME_InteractiveObject) IObject = It.Value();
4713 if ( IObject->hasEntry() ) {
4714 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
4715 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
4717 /* Erase child graphical objects */
4718 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
4719 for (; it->More();it->Next()) {
4720 SALOMEDS::SObject_var CSO= it->Value();
4721 if (CSO->FindAttribute(anAttr, "AttributeIOR") ) {
4722 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4723 /* Delete child(s) shape in Client : */
4724 const TCollection_AsciiString ASCior(anIOR->Value()) ;
4725 ShapeReader.RemoveShapeFromBuffer( ASCior ) ;
4727 for ( int i = 0; i < nbSf; i++ ) {
4728 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4729 if ( sf->getTypeView() == VIEW_OCC ) {
4730 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4731 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4732 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found );
4734 myContext->Erase( Result, true, false );
4735 } else if ( sf->getTypeView() == VIEW_VTK ) {
4736 //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
4737 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4738 GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found );
4740 //Renderer->RemoveActor(ac);
4742 myRenderInter->Remove( ac->getIO() );
4749 /* Erase main graphical object */
4750 for ( int i = 0; i < nbSf; i++ ) {
4751 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4752 if ( sf->getTypeView() == VIEW_OCC ) {
4753 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4754 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4755 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found );
4757 myContext->Erase( Result, true, false );
4758 } else if ( sf->getTypeView() == VIEW_VTK ) {
4759 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4760 myRenderInter->Remove( IObject );
4764 /* Delete main shape in Client : */
4765 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
4766 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4767 const TCollection_AsciiString ASCIor(anIOR->Value()) ;
4768 ShapeReader.RemoveShapeFromBuffer( ASCIor ) ;
4771 /* Erase objects in Study */
4772 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4773 if ( !obj->_is_nil() ) {
4774 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4776 aStudyBuilder->RemoveObject(obj);
4780 } /* IObject->hasEntry() */
4783 /* Clear any previous selection */
4784 Sel->ClearIObjects() ;
4785 myActiveStudy->updateObjBrowser();
4789 //==============================================================================
4790 // function : OnEditCopy()
4792 //==============================================================================
4793 void GeometryGUI::OnEditCopy()
4795 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4796 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
4798 const SALOME_ListIO& List = Sel->StoredIObjects();
4800 GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR);
4802 Sel->ClearIObjects();
4804 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
4805 GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]);
4807 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ;
4808 result->NameType( aShapeInit->NameType() );
4809 this->Display(result);
4811 catch (const SALOME::SALOME_Exception& S_ex) {
4812 QtCatchCorbaException(S_ex);
4816 myDesktop->putInfo(tr("GEOM_PRP_READY"));
4821 //=====================================================================================
4822 // function : OnKeyPress()
4823 // purpose : [static]
4824 //=====================================================================================
4825 bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4827 GeometryGUI::GetOrCreateGeometryGUI(parent);
4829 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4837 //=====================================================================================
4838 // function : DisplaySimulationShape()
4839 // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
4840 //=====================================================================================
4841 void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S)
4846 //NRI DEBUG : 14/02/2002
4847 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4850 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4851 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4854 /* erase any previous */
4855 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4856 ic->ClearPrs( this->mySimulationShape );
4857 this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ;
4858 this->mySimulationShape->Set( S ) ;
4859 this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ;
4860 ic->Deactivate( this->mySimulationShape );
4861 ic->Display( this->mySimulationShape, Standard_False );
4862 ic->UpdateCurrentViewer();
4864 catch(Standard_Failure) {
4865 MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ;
4867 this->mySimulationShape->UnsetColor() ;
4873 //==================================================================================
4874 // function : EraseSimulationShape()
4875 // purpose : Clears the display of 'mySimulationShape' a pure graphical shape
4876 //==================================================================================
4877 void GeometryGUI::EraseSimulationShape()
4879 int count = myActiveStudy->getStudyFramesCount();
4880 for ( int i = 0; i < count; i++ ) {
4881 if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
4882 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
4883 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4884 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4885 ic->ClearPrs( this->mySimulationShape );
4886 ic->UpdateCurrentViewer();
4888 } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK
4891 // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " )
4896 //=====================================================================================
4897 // function : Import
4898 // purpose : BRep, Iges, Step
4899 //=====================================================================================
4900 bool GeometryGUI::Import( )
4902 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4903 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4905 GEOM::GEOM_Shape_var aShape;
4907 QStringList filtersList ;
4909 switch ( GeomGUI->myState )
4911 case 111 : // Import BREP
4913 filtersList.append( tr("GEOM_MEN_IMPORT_BREP") );
4914 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4916 file = QAD_FileDlg::getFileName(myDesktop,
4919 tr("GEOM_MEN_IMPORT"),
4921 if ( !file.isEmpty() ) {
4922 QApplication::setOverrideCursor( Qt::waitCursor );
4924 aShape = myComponentGeom->ImportBREP( file.latin1() );
4926 catch (const SALOME::SALOME_Exception& S_ex) {
4927 QtCatchCorbaException(S_ex);
4932 case 112 : // Import IGES
4934 filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ;
4935 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4937 file = QAD_FileDlg::getFileName(myDesktop,
4940 tr("GEOM_MEN_IMPORT"),
4942 if ( !file.isEmpty() ) {
4943 QApplication::setOverrideCursor( Qt::waitCursor );
4945 aShape = myComponentGeom->ImportIGES( file.latin1() );
4947 catch (const SALOME::SALOME_Exception& S_ex) {
4948 QtCatchCorbaException(S_ex);
4953 case 113 : // Import STEP
4955 filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ;
4956 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4958 file = QAD_FileDlg::getFileName(myDesktop,
4961 tr("GEOM_MEN_IMPORT"),
4963 if ( !file.isEmpty() ) {
4964 QApplication::setOverrideCursor( Qt::waitCursor );
4966 aShape = myComponentGeom->ImportSTEP( file.latin1() );
4968 catch (const SALOME::SALOME_Exception& S_ex) {
4969 QtCatchCorbaException(S_ex);
4976 if ( !file.isEmpty() ) {
4977 myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) );
4979 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
4980 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry());
4981 SALOMEDS::GenericAttribute_var anAttr;
4982 SALOMEDS::AttributeName_var aName;
4983 SALOMEDS::AttributePixMap_var aPixmap;
4984 int aLocked = false;
4985 if (father->_is_nil()) {
4986 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4988 aLocked = aStudy->GetProperties()->IsLocked();
4989 if (aLocked) aStudy->GetProperties()->SetLocked(false);
4990 father = aStudyBuilder->NewComponent("GEOM");
4991 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
4992 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4993 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
4994 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
4995 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
4996 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
4997 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
4998 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5001 // if (aLocked) return false;
5002 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5003 father->ComponentIOR( Fatherior );
5005 QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++);
5007 if ( Display ( aShape, strdup(nameShape.latin1())) ) {
5008 myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) );
5009 myDesktop->putInfo( tr("GEOM_PRP_READY"));
5012 QApplication::restoreOverrideCursor();
5017 //=====================================================================================
5018 // function : Export
5019 // purpose : BRep, Iges, Step
5020 //=====================================================================================
5021 bool GeometryGUI::Export( )
5023 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5024 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5026 GEOM::GEOM_Shape_var aShape;
5028 static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"),
5029 tr("GEOM_MEN_IMPORT_IGES"),
5030 tr("GEOM_MEN_IMPORT_STEP") };
5032 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
5033 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5035 switch ( GeomGUI->myState )
5039 for(;It.More();It.Next()) {
5040 QApplication::restoreOverrideCursor();
5041 Handle(SALOME_InteractiveObject) IObject = It.Value();
5042 Standard_Boolean found;
5043 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5044 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5046 QString file = QAD_FileDlg::getFileName(myDesktop,
5047 QString( IObject->getName() ) + ".brep",
5048 tr("GEOM_MEN_IMPORT_BREP"),
5049 tr("GEOM_MEN_EXPORT"),
5051 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5052 QApplication::setOverrideCursor( Qt::waitCursor );
5053 // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) );
5055 GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape);
5057 catch (const SALOME::SALOME_Exception& S_ex) {
5058 QtCatchCorbaException(S_ex);
5067 for(;It.More();It.Next()) {
5068 QApplication::restoreOverrideCursor();
5069 Handle(SALOME_InteractiveObject) IObject = It.Value();
5070 Standard_Boolean found;
5071 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5072 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5074 QString file = QAD_FileDlg::getFileName(myDesktop,
5075 QString( IObject->getName() ) + ".igs",
5076 tr("GEOM_MEN_IMPORT_IGES"),
5077 tr("GEOM_MEN_EXPORT"),
5079 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5080 QApplication::setOverrideCursor( Qt::waitCursor );
5082 GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape);
5084 catch (const SALOME::SALOME_Exception& S_ex) {
5085 QtCatchCorbaException(S_ex);
5087 // //VRV: OCC 4.0 migration
5088 // IGESControl_Controller::Init();
5089 // IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
5090 // Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
5091 // //VRV: OCC 4.0 migration
5093 // ICW.AddShape (Shape->Shape());
5094 // ICW.ComputeModel();
5095 // Standard_Boolean result = ICW.Write( strdup(file.latin1()) );
5104 // bool test = false ;
5105 // IFSelect_ReturnStatus status ;
5106 // //VRV: OCC 4.0 migration
5107 // STEPControl_Writer aWriter;
5108 // //VRV: OCC 4.0 migration
5111 for( ; It.More(); It.Next() ) {
5112 // GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5113 QApplication::restoreOverrideCursor();
5114 Handle(SALOME_InteractiveObject) IObject = It.Value();
5115 Standard_Boolean found;
5116 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5117 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5119 file = QAD_FileDlg::getFileName(myDesktop,
5120 QString( IObject->getName() ) + ".stp",
5121 tr("GEOM_MEN_IMPORT_STEP"),
5122 tr("GEOM_MEN_EXPORT"),
5124 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5126 QApplication::setOverrideCursor( Qt::waitCursor ) ;
5128 GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape);
5130 catch (const SALOME::SALOME_Exception& S_ex) {
5131 QtCatchCorbaException(S_ex);
5133 // //VRV: OCC 4.0 migration
5134 // status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ;
5135 // //VRV: OCC 4.0 migration
5137 // if ( status != IFSelect_RetDone ) {
5138 // QApplication::restoreOverrideCursor() ;
5145 // status = aWriter.Write( strdup(file.latin1()) ) ;
5146 // QApplication::restoreOverrideCursor() ;
5153 QApplication::restoreOverrideCursor() ;
5157 //=====================================================================================
5158 // function : Display()
5159 // purpose : Displays a CORBA shape
5160 //=====================================================================================
5161 bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
5162 Standard_CString name)
5164 // MESSAGE ( "GeometryGUI::Display init ")
5165 Handle(GEOM_InteractiveObject) IO;
5166 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5167 Sel->ClearIObjects();
5169 if( aShape->_is_nil() ) {
5170 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
5171 tr ("GEOM_WRN_WARNING"),
5172 tr ("GEOM_PRP_ABORT"),
5173 tr ("GEOM_BUT_OK") );
5177 TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape);
5179 if ( shape.IsNull() )
5182 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5183 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5184 SALOMEDS::GenericAttribute_var anAttr;
5185 SALOMEDS::AttributeName_var aName;
5186 SALOMEDS::AttributePixMap_var aPixmap;
5188 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5189 int aLocked = false;
5190 if (father->_is_nil()) {
5191 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5193 aLocked = aStudy->GetProperties()->IsLocked();
5194 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5195 father = aStudyBuilder->NewComponent("GEOM");
5196 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5197 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5198 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5199 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5200 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5201 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5202 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5203 myActiveStudy->updateObjBrowser();
5204 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5207 // if (aLocked) return false;
5209 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5210 father->ComponentIOR( Fatherior );
5212 TCollection_AsciiString nameG("");
5213 Standard_CString Type;
5214 if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) {
5215 if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) {
5216 Standard_CString type;
5217 GetShapeTypeString(shape,type);
5218 aShape->NameType( type );
5219 nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") +
5220 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5222 nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") +
5223 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5225 nameG = TCollection_AsciiString(name);
5228 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5229 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5231 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5232 int themode = myRenderInter->GetDisplayMode();
5234 vtkActorCollection* theActors =
5235 GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True);
5236 theActors->InitTraversal();
5237 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
5239 IO = new GEOM_InteractiveObject(aShape->Name(),
5242 while(!(anActor==NULL)) {
5243 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
5244 GActor->setIO( IO );
5245 GActor->setName( nameG.ToCString() );
5247 theRenderer->AddActor(GActor);
5248 anActor = (vtkActor*)theActors->GetNextActor();
5252 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5253 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5254 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5255 Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() );
5256 theResult->SetShadingColor( myShadingColor );
5257 IO = new GEOM_InteractiveObject(aShape->Name(),
5260 theResult->setIO( IO );
5261 theResult->setName( nameG.ToCString() );
5263 /* Precaution : close any local context to permit the display */
5264 if ( ic->HasOpenedContext() ) {
5265 ic->CloseAllContexts();
5269 // theResult->SetInfiniteState() ;
5271 ic->Display(theResult);
5274 Sel->AddIObject( IO, false );
5275 myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
5276 if ( Settings_AddInStudy )
5277 GeomGUI->AddInStudy( false, IO );
5283 //=====================================================================================
5284 // function : AddInStudy()
5285 // purpose : anIOShape or a selected shape
5286 //=====================================================================================
5287 bool GeometryGUI::AddInStudy( bool selection,
5288 const Handle(SALOME_InteractiveObject)& anIO)
5290 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5291 if ( !( !Settings_AddInStudy || selection ) ) {
5292 Sel->ClearIObjects();
5295 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5296 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5297 SALOMEDS::GenericAttribute_var anAttr;
5298 SALOMEDS::AttributeName_var aName;
5299 SALOMEDS::AttributePixMap_var aPixmap;
5300 SALOMEDS::AttributeIOR_var anIOR;
5301 SALOMEDS::AttributeSelectable_var aSelAttr;
5303 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5304 int aLocked = false;
5305 if (father->_is_nil()) {
5306 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5308 aLocked = aStudy->GetProperties()->IsLocked();
5309 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5310 father = aStudyBuilder->NewComponent("GEOM");
5311 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5312 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5313 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5314 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5315 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5316 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5317 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5318 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5321 // if (aLocked) return false;
5323 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5324 father->ComponentIOR( Fatherior );
5326 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
5328 Handle(GEOM_AISShape) GAISShape;
5330 Handle(GEOM_InteractiveObject) GIO;
5334 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5335 vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5337 vtkActorCollection* theActors = Renderer->GetActors();
5338 theActors->InitTraversal();
5339 vtkActor *ac = theActors->GetNextActor();
5340 while(!(ac==NULL)) {
5341 if ( ac->IsA("GEOM_Actor") ) {
5342 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
5343 if ( anActor->hasIO() ) {
5344 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
5345 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5346 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5347 if ( anIO->isSame( GIO ) ) {
5355 ac = theActors->GetNextActor();
5362 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5363 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5364 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5366 AIS_ListOfInteractive List;
5367 ic->DisplayedObjects(List);
5368 AIS_ListIteratorOfListOfInteractive ite(List);
5369 while (ite.More()) {
5370 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
5371 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
5372 if ( aSh->hasIO() ) {
5373 Handle(SALOME_InteractiveObject) IO = aSh->getIO();
5374 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5375 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5376 if ( anIO->isSame( GIO ) ) {
5391 if ( !Settings_AddInStudy || selection ) {
5392 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() );
5393 if ( !Name.isEmpty() ) {
5395 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5396 GActor->setName( strdup(Name.latin1()) );
5399 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5400 GAISShape->setName( strdup(Name.latin1()) );
5408 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5411 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father);
5413 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() );
5415 /* For the shape inserted into the study we set its field 'studyshapeid' */
5416 /* so the shape will contain its corresponding entry in the study Ocaf doc. */
5417 aShape->StudyShapeId(newObj->GetID()) ;
5419 GIO->setEntry(newObj->GetID());
5421 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
5422 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5423 anIOR->SetValue(aShape->Name());
5425 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
5426 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5428 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
5429 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5430 if ( aShape->ShapeType() == GEOM::COMPOUND ) {
5431 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
5432 } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
5433 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
5434 } else if ( aShape->ShapeType() == GEOM::SOLID ) {
5435 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
5436 } else if ( aShape->ShapeType() == GEOM::SHELL ) {
5437 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
5438 } else if ( aShape->ShapeType() == GEOM::FACE ) {
5439 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
5440 } else if ( aShape->ShapeType() == GEOM::WIRE ) {
5441 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
5442 } else if ( aShape->ShapeType() == GEOM::EDGE ) {
5443 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
5444 } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
5445 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
5449 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5450 GActor->setIO( GIO );
5451 aName->SetValue(GActor->getName());
5454 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5455 GAISShape->setIO( GIO );
5456 aName->SetValue(GAISShape->getName());
5459 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
5460 aStudyBuilder->Addreference(newObj1,newObj);
5462 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
5463 listIOR = myComponentGeom->GetReferencedObjects(aShape);
5465 if (listIOR->length()>0) {
5466 SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj);
5467 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName");
5468 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5469 aName->SetValue(tr("GEOM_ARGUMENTS"));
5470 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable");
5471 aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
5472 aSelAttr->SetSelectable(false);
5474 bool ObjectReferenced = false;
5475 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
5476 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]);
5478 if ( !theObj->_is_nil() ) {
5479 SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments);
5480 aStudyBuilder->Addreference(RefObject, theObj);
5481 ObjectReferenced = true;
5485 if ( !ObjectReferenced )
5486 aStudyBuilder->RemoveObject(Arguments);
5492 if ( !Settings_AddInStudy || selection ) {
5493 myActiveStudy->updateObjBrowser();
5495 myActiveStudy->updateObjBrowser(false);
5496 Sel->AddIObject( GIO );
5499 // MESSAGE ( " highlihght done" )
5505 //=====================================================================================
5506 // function : GetShapeFromIOR()
5507 // purpose : exist also as static method !
5508 //=====================================================================================
5509 TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR )
5511 TopoDS_Shape result;
5512 if( IOR.stripWhiteSpace().isEmpty() )
5514 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
5515 CORBA::ORB_var& _orb = init.orb() ;
5516 CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) );
5517 if ( CORBA::is_nil( obj ) )
5519 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR );
5520 if (!aShape->_is_nil()) {
5521 result = ShapeReader.GetShape( myComponentGeom, aShape );
5527 //=====================================================================================
5528 // function : SetSettings()
5529 // purpose : [static]
5530 //=====================================================================================
5531 bool GeometryGUI::SetSettings( QAD_Desktop* parent )
5533 /* Create or retrieve an object GeomGUI */
5534 GeometryGUI::GetOrCreateGeometryGUI(parent);
5536 //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING
5537 //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS
5538 //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY
5539 parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS
5540 parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN
5543 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
5544 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
5545 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
5546 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
5547 GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255.,
5550 /* Wireframe or Shading */
5551 int DisplayMode = 0;
5552 if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5553 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5554 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
5555 DisplayMode = ic->DisplayMode();
5556 } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5557 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5558 DisplayMode = myRenderInter->GetDisplayMode();
5561 if ( DisplayMode == 1 )
5562 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
5564 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
5567 // QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy");
5568 // if ( !Copy.isEmpty() ) {
5569 // Settings_Copy = Copy.toInt();
5571 // parent->menuBar()->findItem(701,&pp);
5572 // pp->setItemChecked(701, Settings_Copy);
5575 if ( parent->menuBar()->findItem(701,&pp) )
5576 pp->removeItem(701);
5579 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
5580 if ( !AddInStudy.isEmpty() )
5581 Settings_AddInStudy = AddInStudy.toInt();
5583 Settings_AddInStudy = 1;
5584 parent->menuBar()->findItem(702,&pp);
5585 pp->setItemChecked(702, Settings_AddInStudy);
5588 QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
5590 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" );
5593 QAD_Study* ActiveStudy = parent->getActiveStudy();
5594 int count = ActiveStudy->getStudyFramesCount();
5596 bool ViewOCC = false;
5597 for ( int i = 0; i < count; i++ ) {
5598 if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
5599 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
5600 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5602 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
5603 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
5604 if ( !IsoU.isEmpty() )
5605 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
5606 if ( !IsoV.isEmpty() )
5607 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
5613 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
5615 Mb->setItemEnabled( 312, ViewOCC); //Sketch
5616 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
5617 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
5619 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
5620 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
5626 //=====================================================================================
5627 // function : DefinePopup()
5628 // purpose : [static]
5629 //=====================================================================================
5630 void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
5632 /* Create or retrieve an object GeomGUI */
5633 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
5634 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5637 if ( Sel->IObjectCount() == 1 )
5639 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
5642 SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
5643 if (!sobj->_is_nil())
5645 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
5646 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
5648 // component is selected
5649 theObject = "Component";
5655 if ( ( theParent.compare("Viewer")==0 ) )
5657 if ( GeomGUI->myState == CURRENT_SKETCH )
5658 theContext = "Sketch";
5661 if ( Sel->IObjectCount() > 0 )
5664 theContext = "NothingSelected";
5672 //=====================================================================================
5673 // function : CustomPopup()
5674 // purpose : [static]
5675 //=====================================================================================
5676 bool GeometryGUI::CustomPopup( QAD_Desktop* parent,
5678 const QString& theContext,
5679 const QString& theParent,
5680 const QString& theObject )
5682 /* Create or retrieve an object GeomGUI */
5683 GeometryGUI::GetOrCreateGeometryGUI(parent);
5685 /* Deactivate any non modal dialog box to get the neutral point */
5686 GeomGUI->EmitSignalDeactivateDialog() ;
5688 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5689 int nbSel = Sel->IObjectCount();
5691 if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) )
5695 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
5697 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->
5698 getRightFrame()->getViewFrame())->getViewer();
5699 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5700 if ( theParent.compare("Viewer")==0 )
5702 if ( theContext.compare("Sketch")==0 )
5704 SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus();
5705 popup->setCheckable(TRUE);
5708 popup->setItemChecked(10000,true);
5709 popup->setItemChecked(10001,false);
5711 else if (myCS==ARC_CHORD)
5713 popup->setItemChecked(10000,false);
5714 popup->setItemChecked(10001,true);
5720 if (theObject.compare("Component") == 0)
5722 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5727 QFont f = QApplication::font();
5731 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5732 popup->removeItem(QAD_TopLabel_Popup_ID);
5733 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5734 if ( IObject->hasEntry() )
5735 popup->setItemEnabled( 801, false );
5737 popup->setItemEnabled( 801, true );
5739 if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)))
5741 Standard_Boolean found;
5742 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
5746 if ( Result->DisplayMode() == 1 )
5747 popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") );
5749 popup->changeItem(8021, tr("GEOM_MEN_SHADING") );
5753 if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) )
5754 popup->removeItem(QAD_Erase_Popup_ID);
5756 popup->removeItem(QAD_Display_Popup_ID);
5761 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5762 popup->removeItem(QAD_TopLabel_Popup_ID);
5763 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ),
5764 QAD_TopLabel_Popup_ID, 0 );
5765 popup->setItemEnabled( 801, false );
5771 if ( theParent.compare("ObjectBrowser")==0 )
5773 popup->removeItem(QAD_TopLabel_Popup_ID);
5774 int id = popup->idAt(0); // separator
5775 if (id < 0) popup->removeItem(id);
5777 // checking for GEOM label in the selected list
5778 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5779 Handle(SALOME_InteractiveObject) anIObject;
5781 bool useSubItems = false;
5782 bool needOpen = false;
5783 bool needDisplay = false;
5784 bool needErase = false;
5785 SALOMEDS::GenericAttribute_var aTmpAttr;
5786 for(;It.More();It.Next())
5788 anIObject = It.Value();
5789 if (!anIObject->hasEntry())
5792 if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject))
5796 SALOMEDS::SObject_var obj =
5797 GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
5798 if (!obj->_is_nil())
5800 GEOM::GEOM_Shape_var aShape;
5801 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) {
5802 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5803 if (str && strlen(str))
5804 aShape = GeomGUI->myComponentGeom-> GetIORFromString(str);
5807 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5809 if (aShape->_is_nil())
5811 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->
5812 getStudyDocument()->NewChildIterator(obj);
5813 while (anIter->More())
5815 SALOMEDS::SObject_var subobj = anIter->Value();
5816 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
5823 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5833 // remove useless popup items
5834 if (nbSel != 1) popup->removeItem(901); // rename
5835 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5838 int index = popup->indexOf(9024);
5839 popup->removeItem(9024); // open
5840 popup->removeItemAt(index); // separator under Open
5842 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
5843 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
5844 if (!needDisplay && !needErase)
5846 int id = popup->idAt(popup->count()-1); // last item
5847 popup->removeItem(id); // separator
5852 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5853 popup->removeItem(QAD_Display_Popup_ID);
5854 popup->removeItem(QAD_Erase_Popup_ID);
5857 int id = popup->idAt(popup->count()-1); // last item
5858 popup->removeItem(id); // separator
5863 // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ")
5866 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
5868 // MESSAGE ( " CUSTOM POPUP VIEWER VTK ")
5869 if ( ( theParent.compare("Viewer")==0 ) )
5872 popup->setItemEnabled( 8033, false );
5873 if (theObject.compare("Component") == 0)
5875 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5879 //int id = popup->idAt(0);
5880 QFont f = QApplication::font();
5885 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5886 popup->removeItem(QAD_TopLabel_Popup_ID);
5887 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5888 if ( IObject->hasEntry() )
5890 popup->setItemEnabled( 801, false );
5891 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
5892 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
5893 SALOMEDS::GenericAttribute_var anAttr;
5894 SALOMEDS::AttributeIOR_var anIOR;
5895 if ( !SO->_is_nil() )
5897 if (SO->FindAttribute(anAttr, "AttributeIOR") )
5899 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5900 Standard_Boolean found;
5901 GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true);
5904 if ( Result->getDisplayMode() == 1 )
5905 popup->changeItem(8021, "Wireframe" );
5907 popup->changeItem(8021, "Shading" );
5909 if ( !Result->GetVisibility() )
5910 popup->removeItem(QAD_Erase_Popup_ID);
5912 popup->removeItem(QAD_Display_Popup_ID);
5915 popup->removeItem(QAD_Erase_Popup_ID);
5920 popup->setItemEnabled( 801, true );
5924 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5925 popup->removeItem(QAD_TopLabel_Popup_ID);
5926 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 );
5927 popup->setItemEnabled( 801, false );
5932 if ( theParent.compare("ObjectBrowser")==0 )
5934 popup->removeItem(QAD_TopLabel_Popup_ID);
5935 int id = popup->idAt(0); // separator
5936 if (id < 0) popup->removeItem(id);
5938 // checking for GEOM label in the selected list
5939 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5940 Handle(SALOME_InteractiveObject) anIObject;
5942 bool useSubItems = false;
5943 bool needOpen = false;
5944 bool needDisplay = false;
5945 bool needErase = false;
5946 SALOMEDS::GenericAttribute_var aTmpAttr;
5947 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->
5948 getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5949 for(;It.More();It.Next())
5951 anIObject = It.Value();
5952 if ( !anIObject->hasEntry() )
5955 if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject))
5960 SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument()
5961 ->FindObjectID( anIObject->getEntry() );
5962 if (!obj->_is_nil()) {
5963 GEOM::GEOM_Shape_var aShape;
5964 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){
5965 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5966 if (str && strlen(str))
5967 aShape = GeomGUI->myComponentGeom->GetIORFromString(str);
5970 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5972 if (aShape->_is_nil())
5974 SALOMEDS::ChildIterator_var anIter =
5975 GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
5976 while (anIter->More())
5978 SALOMEDS::SObject_var subobj = anIter->Value();
5979 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
5986 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5996 // remove useless popup items
5997 if (nbSel != 1) popup->removeItem(901); // rename
5998 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6001 int index = popup->indexOf(9024);
6002 popup->removeItem(9024); // open
6003 popup->removeItemAt(index); // separator under Open
6005 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
6006 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
6007 if (!needDisplay && !needErase)
6009 int id = popup->idAt(popup->count()-1); // last item
6010 popup->removeItem(id); // separator
6015 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6016 popup->removeItem(QAD_Display_Popup_ID);
6017 popup->removeItem(QAD_Erase_Popup_ID);
6020 int id = popup->idAt(popup->count()-1); // last item
6021 popup->removeItem(id); // separator
6025 // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.")
6028 { // other viewer types not supported.
6031 int id = popup->idAt(0);
6032 if (id <= QAD_TopLabel_Popup_ID && id != -1)
6033 popup->removeItemAt(0);
6037 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6038 popup->removeItem(QAD_Display_Popup_ID);
6039 popup->removeItem(QAD_Erase_Popup_ID);
6040 int id = popup->idAt(popup->count()-1); // last item
6041 if (id < 0 && id != -1) popup->removeItem(id); // separator
6047 void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
6049 /* Create or retrieve an object GeomGUI */
6050 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
6052 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6053 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
6055 OCCViewer_Viewer3d* v3d;
6056 Handle(AIS_InteractiveContext) ic;
6057 vtkRenderer* Renderer;
6059 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6060 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6061 ic = v3d->getAISContext();
6062 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6063 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6068 MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
6070 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6073 SALOMEDS::SObject_var fatherSF =
6074 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6076 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6078 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6080 SALOMEDS::GenericAttribute_var anAttr;
6081 SALOMEDS::AttributeName_var aName;
6082 SALOMEDS::AttributeIOR_var anIOR;
6084 if(myRenderInter->isInViewer(theIO)) {
6085 myRenderInter->Display(theIO, false);
6089 if ( !obj->_is_nil() ) {
6090 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6091 // this SObject may be GEOM module root SObject
6093 bool useSubItems = false;
6094 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6095 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6096 while (anIter->More() && !useSubItems) {
6097 SALOMEDS::SObject_var subobj = anIter->Value();
6098 SALOMEDS::GenericAttribute_var aTmpAttr;
6099 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6100 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6104 } else anIter->Next();
6105 } else anIter->Next();
6109 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6110 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6111 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6112 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6114 if (obj->FindAttribute(anAttr, "AttributeName")) {
6115 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6117 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6118 vtkActorCollection* theAllActors = theRenderer->GetActors();
6119 theAllActors->InitTraversal();
6120 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
6121 Handle(SALOME_InteractiveObject) anIObj;
6122 // don't create new study object if it already exists
6123 bool isDisplayed = false;
6124 while(!(actor==NULL)) {
6125 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
6127 if (Gactor->hasIO()) {
6128 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
6130 anIObj = Gactor->getIO();
6131 if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
6135 actor=(vtkActor*)(theAllActors->GetNextActor());
6139 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6142 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6143 aStudyBuilder->Addreference(newObj1, obj);
6144 // commit transaction
6147 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6148 int themode = myRenderInter->GetDisplayMode();
6150 vtkActorCollection* theActors =
6151 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
6152 theActors->InitTraversal();
6153 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
6154 while(!(anActor==NULL)) {
6155 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
6156 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
6157 IO->setEntry(obj->GetID());
6158 GActor->setIO( IO );
6159 GActor->setName( theIO->getName() );
6161 theRenderer->AddActor(GActor);
6162 // renWin->Render();
6163 anActor = (vtkActor*)theActors->GetNextActor();
6167 // next item iteration
6170 anAttr = SALOMEDS::GenericAttribute::_nil();
6171 while (anIter->More() && anAttr->_is_nil()) {
6172 SALOMEDS::SObject_var subobject = anIter->Value();
6173 SALOMEDS::GenericAttribute_var aTmpAttribute;
6174 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6175 anAttr = aTmpAttribute;
6177 } else anIter->Next();
6179 } else anAttr = SALOMEDS::GenericAttribute::_nil();
6184 // No viewer update should be done here!
6185 //myRenderInter->Render();
6186 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6187 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6188 SALOMEDS::SObject_var fatherSF =
6189 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6190 SALOMEDS::GenericAttribute_var anAttr;
6191 SALOMEDS::AttributeName_var aName;
6192 SALOMEDS::AttributeIOR_var anIOR;
6194 if ( v3d->isInViewer( theIO, true ) ) {
6195 Standard_Boolean found;
6196 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true );
6198 ic->Display(aSh, false);
6199 ic->AddOrRemoveCurrentObject(aSh, false);
6203 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6204 if ( !obj->_is_nil() ) {
6205 MESSAGE("BuildPresentation(): SObject not null")
6206 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6207 MESSAGE("BuildPresentation(): SObject has IOR")
6208 // this SObject may be GEOM module root SObject
6210 bool useSubItems = false;
6211 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6212 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6213 while (anIter->More() && !useSubItems) {
6214 SALOMEDS::SObject_var subobj = anIter->Value();
6215 SALOMEDS::GenericAttribute_var aTmpAttr;
6216 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6217 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6221 } else anIter->Next();
6222 } else anIter->Next();
6226 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6227 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6228 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6229 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6231 MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
6232 if (obj->FindAttribute(anAttr, "AttributeName")) {
6233 MESSAGE("BuildPresentation(): SObject has Name")
6234 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6235 // searchin for already displayed objects with the same shape
6236 AIS_ListOfInteractive aDisplayed;
6237 ic->DisplayedObjects(aDisplayed);
6238 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
6239 Handle(AIS_Shape) anAISShape;
6240 for(;anIObjects.More();anIObjects.Next()) {
6241 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
6242 if (!anAISShape.IsNull()) {
6243 if (anAISShape->Shape().IsSame(Shape)) break;
6244 anAISShape.Nullify();
6247 if (!anAISShape.IsNull()) {
6248 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false);
6252 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6254 if (fatherSF->_is_nil())
6255 MESSAGE("BuildPresentation(): fatherSF is nil!")
6256 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6257 aStudyBuilder->Addreference(newObj1, obj);
6258 // commit transaction
6261 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
6262 aSh->SetShadingColor( GeomGUI->myShadingColor );
6263 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
6266 IO->setEntry(obj->GetID());
6268 aSh->setName( aName->Value() );
6269 ic->Display (aSh, false);
6270 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false);
6273 // next item iteration
6276 anAttr=SALOMEDS::GenericAttribute::_nil();
6277 while (anIter->More() && anAttr->_is_nil()) {
6278 SALOMEDS::SObject_var subobject = anIter->Value();
6279 SALOMEDS::GenericAttribute_var aTmpAttribute;
6280 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6281 anAttr = aTmpAttribute;
6283 } else anIter->Next();
6286 anAttr = SALOMEDS::GenericAttribute::_nil();
6291 // No viewer update should be done here!
6292 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6293 //ic->UpdateCurrentViewer();
6297 //=======================================================================
6298 // function : Parameter()
6299 // purpose : return a parameter (float) from a dialog box
6301 // avalue1 : is a float or integer used as a default value displayed
6302 // aTitle1 : is the title for aValue1
6303 // aTitle : is the main title
6304 // bottom : maximum value to be entered
6305 // top : minimum value to be entered
6306 // decimals : number of decimals
6307 //=======================================================================
6308 double GeometryGUI::Parameter( Standard_Boolean& res,
6309 const char* aValue1,
6310 const char* aTitle1,
6312 const double bottom,
6314 const int decimals )
6316 GeometryGUI_aParameterDlg * Dialog =
6317 new GeometryGUI_aParameterDlg(aValue1,
6319 QAD_Application::getDesktop(),
6326 int r = Dialog->exec() ;
6328 if ( r == QDialog::Accepted ) {
6329 res = Standard_True;
6330 X = Dialog->getValue();
6332 res = Standard_False;
6338 //=======================================================================
6339 // function : OnSketchSegment()
6341 //=======================================================================
6342 void GeometryGUI::OnSketchSegment()
6344 this->mySketcher.ChangeMode(SEGMENT);
6348 //=======================================================================
6349 // function : OnSketchArc()
6351 //=======================================================================
6352 void GeometryGUI::OnSketchArc()
6354 this->mySketcher.ChangeMode(ARC_CHORD);
6357 //=======================================================================
6358 // function : OnSketchSetAngle()
6360 //=======================================================================
6361 void GeometryGUI::OnSketchSetAngle()
6363 Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180;
6364 Sketch::fitInResol(anAngle);
6365 Standard_Boolean res = false ;
6366 QString Value = QString("%1").arg( anAngle );
6367 anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ;
6370 this->mySketcher.SetSegmentAngle(anAngle);
6371 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6373 QMenuItem* item = Mb->findItem(3133,&pp);
6374 pp->setItemChecked(3133,false);
6375 item = Mb->findItem(3134,&pp);
6376 pp->setItemChecked(3134,false);
6382 //=======================================================================
6383 // function : OnSketchSetx()
6385 //=======================================================================
6386 void GeometryGUI::OnSketchSetx()
6388 Standard_Boolean res = false;
6389 double X = Parameter( res,
6392 tr("GEOM_MEN_SKETCHER_X"),
6393 2.0 * Precision::Confusion(),
6397 this->mySketcher.SetXDimension(X);
6398 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6400 QMenuItem* item = Mb->findItem(3133,&pp);
6401 pp->setItemChecked(3133,false);
6402 item = Mb->findItem(3134,&pp);
6403 pp->setItemChecked(3134,false);
6406 //=======================================================================
6407 // function : OnSketchSety()
6409 //=======================================================================
6410 void GeometryGUI::OnSketchSety()
6412 Standard_Boolean res = false;
6413 double Y = Parameter( res,
6416 tr("GEOM_MEN_SKETCHER_Y"),
6417 2.0 * Precision::Confusion(),
6421 this->mySketcher.SetYDimension(Y);
6422 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6424 QMenuItem* item = Mb->findItem(3133,&pp);
6425 pp->setItemChecked(3133,false);
6426 item = Mb->findItem(3134,&pp);
6427 pp->setItemChecked(3134,false);
6431 //=======================================================================
6432 // function : OnSketchDelete()
6434 //=======================================================================
6435 void GeometryGUI::OnSketchDelete()
6437 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
6438 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
6440 QMenuItem* item = Mb->findItem(313,&pp);
6441 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6442 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6445 if (this->mySketcher.Delete())
6446 GeomGUI->ResetState();
6450 //=======================================================================
6451 // function : OnSketchClose()
6453 //=======================================================================
6454 void GeometryGUI::OnSketchClose()
6456 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6457 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6459 TopoDS_Wire W = this->mySketcher.Close();
6460 if ( !W.IsNull() ) {
6462 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6463 listShapes->length(0);
6466 BRepTools_WireExplorer Ex(W);
6467 while ( Ex.More() ) {
6468 TopoDS_Edge E = Ex.Current();
6471 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6472 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6475 Handle(Geom_Curve) Curve;
6476 Handle(Geom_Circle) Circle;
6478 Standard_Real First,Last;
6480 Curve = BRep_Tool::Curve(E,First,Last);
6481 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6482 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6483 Circ = Circle->Circ(); // gp_Circ
6485 Curve->D0( (First + Last) / 2. , CenterPoint );
6487 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6488 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6489 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6491 GEOM::GEOM_Shape_var arc;
6494 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6496 catch (const SALOME::SALOME_Exception& S_ex) {
6497 QtCatchCorbaException(S_ex);
6500 listShapes->length(i+1);
6501 listShapes[i] = strdup(arc->Name());
6504 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6505 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6506 GEOM::GEOM_Shape_var segment;
6509 segment = myComponentGeom->MakeEdge(pI,pE) ;
6511 catch (const SALOME::SALOME_Exception& S_ex) {
6512 QtCatchCorbaException(S_ex);
6515 listShapes->length(i+1);
6516 listShapes[i] = strdup(segment->Name());
6521 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6522 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6523 Standard_CString type;
6524 GetShapeTypeString(S,type);
6525 Wire->NameType( type );
6527 if ( Display(Wire, "" )) {
6528 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6531 GeomGUI->ResetState();
6532 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6534 QMenuItem* item = Mb->findItem(313,&pp);
6535 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6536 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6541 //=======================================================================
6542 // function : OnSketchEnd()
6544 //=======================================================================
6545 void GeometryGUI::OnSketchEnd()
6547 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6548 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6550 TopoDS_Wire W = this->mySketcher.End();
6553 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6554 listShapes->length(0);
6557 BRepTools_WireExplorer Ex(W);
6558 while ( Ex.More() ) {
6559 TopoDS_Edge E = TopoDS::Edge( Ex.Current() );
6562 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6563 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6566 Handle(Geom_Curve) Curve;
6567 Handle(Geom_Circle) Circle;
6569 Standard_Real First,Last;
6571 Curve = BRep_Tool::Curve(E,First,Last);
6572 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6573 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6574 Circ = Circle->Circ(); // gp_Circ
6576 Curve->D0( (First + Last) / 2. , CenterPoint );
6578 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6579 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6580 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6582 GEOM::GEOM_Shape_var arc;
6585 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6587 catch (const SALOME::SALOME_Exception& S_ex) {
6588 QtCatchCorbaException(S_ex);
6591 listShapes->length(i+1);
6592 listShapes[i] = strdup(arc->Name());
6595 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6596 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6597 GEOM::GEOM_Shape_var segment;
6600 segment = myComponentGeom->MakeEdge(pI,pE) ;
6602 catch (const SALOME::SALOME_Exception& S_ex) {
6603 QtCatchCorbaException(S_ex);
6606 listShapes->length(i+1);
6607 listShapes[i] = strdup(segment->Name());
6613 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6614 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6615 Standard_CString type;
6616 GetShapeTypeString(S,type);
6617 Wire->NameType( type );
6619 if ( Display(Wire, "") ) {
6620 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6623 GeomGUI->ResetState();
6624 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6626 QMenuItem* item = Mb->findItem(313,&pp);
6627 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6628 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6631 //=======================================================================
6632 // function : OnSettingsNoconstraint()
6634 //=======================================================================
6635 void GeometryGUI::OnSettingsNoconstraint()
6637 this->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6640 //=======================================================================
6641 // function : OnSettingsPerpendicular()
6643 //=======================================================================
6644 void GeometryGUI::OnSettingsPerpendicular()
6646 this->mySketcher.SetTransitionStatus(PERPENDICULAR);
6649 //=======================================================================
6650 // function : OnSettingsTangent()
6652 //=======================================================================
6653 void GeometryGUI::OnSettingsTangent()
6655 this->mySketcher.SetTransitionStatus(TANGENT);
6658 //=======================================================================
6659 // function : OnSketchOptionsOnoffangledimension()
6661 //=======================================================================
6662 void GeometryGUI::OnSketchOptionsOnoffangledimension()
6664 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6666 QMenuItem* item = Mb->findItem(10011,&pp);
6667 pp->setItemChecked(10011,!pp->isItemChecked(10011));
6668 this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
6671 //=======================================================================
6672 // function : OnSketchOptionsOnofflengthdimension()
6674 //=======================================================================
6675 void GeometryGUI::OnSketchOptionsOnofflengthdimension()
6677 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6679 QMenuItem* item = Mb->findItem(10010,&pp);
6680 pp->setItemChecked(10010,!pp->isItemChecked(10010));
6681 this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
6684 //=======================================================================
6685 // function : OnSketchOptionsOnoffradiusdimension()
6687 //=======================================================================
6688 void GeometryGUI::OnSketchOptionsOnoffradiusdimension()
6690 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6692 QMenuItem* item = Mb->findItem(10012,&pp);
6693 pp->setItemChecked(10012,!pp->isItemChecked(10012));
6694 this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
6698 //=======================================================================
6699 // function : OnSketchOptionsOnoffxdimension()
6701 //=======================================================================
6702 void GeometryGUI::OnSketchOptionsOnoffxdimension()
6704 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6706 QMenuItem* item = Mb->findItem(10013,&pp);
6707 pp->setItemChecked(10013,!pp->isItemChecked(10013));
6708 this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
6711 //=======================================================================
6712 // function : OnSketchOptionsOnoffydimension()
6714 //=======================================================================
6715 void GeometryGUI::OnSketchOptionsOnoffydimension()
6717 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6719 QMenuItem* item = Mb->findItem(10014,&pp);
6720 pp->setItemChecked(10014,!pp->isItemChecked(10014));
6721 this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
6725 //=======================================================================
6726 // function : Archimede()
6728 //=======================================================================
6729 void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO,
6730 const double aWeight,
6731 const double aWaterDensity,
6732 const double aMeshingDeflection )
6735 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
6736 Handle(GEOM_InteractiveObject) GIO =
6737 Handle(GEOM_InteractiveObject)::DownCast( IO );
6738 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() );
6740 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6741 Result->NameType(tr("GEOM_PLANE"));
6742 if ( Display(Result, "") ) {
6743 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6747 if ( IO->hasEntry() ) {
6748 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6749 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
6750 SALOMEDS::GenericAttribute_var anAttr;
6751 SALOMEDS::AttributeIOR_var anIOR;
6752 if ( !obj->_is_nil() ) {
6753 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
6754 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6755 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() );
6756 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6757 Result->NameType(tr("GEOM_PLANE"));
6758 if ( Display(Result, "") ) {
6759 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6766 catch (const SALOME::SALOME_Exception& S_ex) {
6767 QtCatchCorbaException(S_ex);
6772 //=====================================================================================
6774 //=====================================================================================
6777 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
6779 return GeometryGUI::OnGUIEvent(theCommandID, parent);
6782 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6784 return GeometryGUI::OnKeyPress (pe, parent, studyFrame);
6787 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6789 return GeometryGUI::OnMousePress (pe, parent, studyFrame);
6792 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6794 return GeometryGUI::OnMouseMove (pe, parent, studyFrame);
6797 bool SetSettings ( QAD_Desktop* parent )
6799 return GeometryGUI::SetSettings( parent );
6802 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
6803 const QString & theParent, const QString & theObject )
6805 return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
6808 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
6810 GeometryGUI::DefinePopup( theContext, theParent, theObject );
6813 bool activeStudyChanged ( QAD_Desktop* parent )
6815 GeometryGUI::activeStudyChanged( parent );
6818 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
6820 GeometryGUI::BuildPresentation(theIO);
6823 void supportedViewType(int* buffer, int bufferSize)
6825 if (!buffer || !bufferSize) return;
6826 buffer[0] = (int)VIEW_OCC;
6827 if (--bufferSize) buffer[1] = (int)VIEW_VTK;
6831 //=====================================================================================
6832 // function : OnFilletGetAll()
6834 //=====================================================================================
6835 bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR)
6837 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6838 ListOfID->length(0);
6840 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6841 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6842 if ( theObj->_is_nil() ) {
6843 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6848 if( Radius <= Precision::Confusion() )
6851 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6852 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ;
6853 if ( result->_is_nil() ) {
6854 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6857 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
6858 Standard_CString type;
6859 GetShapeTypeString(S,type);
6860 result->NameType( type );
6862 if ( Display( result, "" ))
6863 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6865 catch (const SALOME::SALOME_Exception& S_ex) {
6866 QtCatchCorbaException(S_ex);
6871 //=====================================================================================
6872 // function : OnFilletGetSelected()
6874 //=====================================================================================
6875 bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
6876 const char* ShapeTopoIOR,
6877 const double Radius,
6878 const int SubShapeType,
6879 Standard_Integer& aLocalContextId,
6880 bool& myUseLocalContext )
6882 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
6886 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6887 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
6889 if( myUseLocalContext == false ) {
6890 /* No local context opened for fillet method */
6891 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6895 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6897 int nbSelected = ic->NbSelected();
6901 while(ic->MoreSelected()) {
6902 TopoDS_Shape s = ic->SelectedShape();
6903 if ( s.ShapeType() == TopAbs_FACE ) {
6904 TopExp_Explorer Exp( s, TopAbs_EDGE );
6905 TopTools_MapOfShape M ;
6906 while ( Exp.More() ) {
6907 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
6908 ListOfID->length( i + 1 );
6909 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
6916 ListOfID->length( i + 1 );
6917 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
6923 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6924 GEOM::GEOM_Shape_var aResult ;
6926 aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID );
6928 /* local context from DialogBox */
6929 ic->CloseLocalContext(aLocalContextId) ;
6930 myUseLocalContext = false ;
6932 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
6933 Standard_CString type;
6934 GetShapeTypeString(S,type);
6935 aResult->NameType( type );
6937 if ( Display( aResult, "") )
6938 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6940 catch (const SALOME::SALOME_Exception& S_ex) {
6941 QtCatchCorbaException(S_ex);
6944 if ( myUseLocalContext ) {
6945 /* local context from DialogBox */
6946 ic->CloseLocalContext(aLocalContextId) ;
6947 myUseLocalContext = false ;
6950 this->OnDisplayAll(true);
6951 myActiveStudy->updateObjBrowser();
6952 myDesktop->putInfo (tr("GEOM_PRP_READY"));
6957 //=====================================================================================
6958 // function : OnChamferGetAll()
6960 //=====================================================================================
6961 bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR)
6963 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6964 ListOfID->length(0);
6966 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6967 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6968 if ( theObj->_is_nil() ) {
6969 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6974 if( D1 <= Precision::Confusion() )
6976 if( D2 <= Precision::Confusion() )
6979 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6980 GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ;
6981 if ( result->_is_nil() ) {
6982 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6986 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
6987 Standard_CString type;
6988 GetShapeTypeString(S,type);
6989 result->NameType( type );
6991 if ( Display( result, "") )
6992 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6994 catch (const SALOME::SALOME_Exception& S_ex) {
6995 QtCatchCorbaException(S_ex);
7000 //=====================================================================================
7001 // function : OnChamferGetSelected()
7003 //=====================================================================================
7004 bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
7005 const char* ShapeTopoIOR,
7006 const double D1, const double D2, const int SubShapeType,
7007 Standard_Integer& aLocalContextId,
7008 bool& myUseLocalContext)
7010 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
7014 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
7015 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
7017 if( myUseLocalContext == false ) {
7018 /* No local context opened for chamfer method */
7019 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7023 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7025 int nbSelected = ic->NbSelected();
7029 while(ic->MoreSelected()) {
7030 TopoDS_Shape s = ic->SelectedShape();
7031 if ( s.ShapeType() == TopAbs_FACE ) {
7032 TopExp_Explorer Exp( s, TopAbs_EDGE );
7033 TopTools_MapOfShape M ;
7034 while ( Exp.More() ) {
7035 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
7036 ListOfID->length( i + 1 );
7037 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
7044 ListOfID->length( i + 1 );
7045 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ;
7051 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7052 GEOM::GEOM_Shape_var aResult ;
7054 aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID );
7056 /* local context from DialogBox */
7057 ic->CloseLocalContext(aLocalContextId) ;
7058 myUseLocalContext = false ;
7060 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
7061 Standard_CString type;
7062 GetShapeTypeString(S,type);
7063 aResult->NameType( type );
7065 if ( Display( aResult, "") )
7066 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7068 catch (const SALOME::SALOME_Exception& S_ex) {
7069 QtCatchCorbaException(S_ex);
7072 if ( myUseLocalContext ) {
7073 /* local context from DialogBox */
7074 ic->CloseLocalContext(aLocalContextId) ;
7075 myUseLocalContext = false ;
7078 this->OnDisplayAll(true);
7079 myActiveStudy->updateObjBrowser();
7080 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7085 //=====================================================================================
7086 // function : MakeCDGAndDisplay()
7088 //=====================================================================================
7089 void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
7092 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape );
7093 if ( result->_is_nil() ) {
7094 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
7097 result->NameType( tr("GEOM_POINT") );
7098 if ( Display( result ) )
7099 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7101 catch (const SALOME::SALOME_Exception& S_ex) {
7102 QtCatchCorbaException(S_ex);
7107 bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) {
7108 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
7109 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
7110 SALOMEDS::SObject_var RefSO;
7111 SALOMEDS::GenericAttribute_var anAttr;
7112 SALOMEDS::AttributeIOR_var anIOR;
7113 for (; it->More();it->Next()) {
7114 SALOMEDS::SObject_var SO= it->Value();
7115 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
7116 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7117 if ( strcmp( anIOR->Value(), IOR ) == 0 )
7120 if ( SO->ReferencedObject( RefSO ) ) {
7121 if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) {
7122 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7123 if ( strcmp( anIOR->Value(), IOR ) == 0 )