1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI.h"
33 # include "Utils_ORB_INIT.hxx"
34 # include "Utils_SINGLETON.hxx"
37 #include "QAD_Tools.h"
38 #include "QAD_Config.h"
39 #include "QAD_Settings.h"
40 #include "QAD_RightFrame.h"
41 #include "QAD_MessageBox.h"
42 #include "QAD_Resource.h"
43 #include "QAD_FileDlg.h"
45 #include "OCCViewer_ViewPort.h"
46 #include "OCCViewer_ViewPort3d.h"
47 #include "OCCViewer_Viewer3d.h"
49 #include "SALOME_NamingService.hxx"
50 #include "SALOME_ListIteratorOfListIO.hxx"
51 #include "SALOME_InteractiveObject.hxx"
53 #include "SALOMEGUI_ImportOperation.h"
54 #include "SALOMEGUI_QtCatchCorbaException.hxx"
55 #include "SALOMEGUI_NameDlg.h"
56 #include "utilities.h"
58 // Open CASCADE Includes
59 #include <AIS_Shape.hxx>
60 #include <AIS_InteractiveContext.hxx>
61 #include <AIS_ListIteratorOfListOfInteractive.hxx>
62 #include <AIS_Drawer.hxx>
63 #include <AIS_Trihedron.hxx>
64 #include <Prs3d_Drawer.hxx>
65 #include <Prs3d_IsoAspect.hxx>
66 #include <Prs3d_ShadingAspect.hxx>
68 #include <BRep_Builder.hxx>
69 #include <BRepAdaptor_Surface.hxx>
70 #include <BRepAdaptor_Curve.hxx>
71 #include <BRep_Tool.hxx>
72 #include <BRepGProp.hxx>
73 #include <BRepExtrema_DistShapeShape.hxx>
74 #include <GProp_GProps.hxx>
75 #include <GProp_PrincipalProps.hxx>
77 #include <BRepAlgoAPI_Fuse.hxx>
78 #include <BRepAlgoAPI_Cut.hxx>
79 #include <BRepAlgoAPI_Section.hxx>
80 #include <BRepAlgoAPI_Common.hxx>
81 #include <BRepPrimAPI_MakeBox.hxx>
82 #include <BRepPrimAPI_MakeCylinder.hxx>
83 #include <BRepPrimAPI_MakePrism.hxx>
84 #include <BRepPrimAPI_MakeSphere.hxx>
85 #include <BRepPrimAPI_MakeRevol.hxx>
86 #include <BRepPrimAPI_MakeTorus.hxx>
87 #include <BRepPrimAPI_MakeCone.hxx>
88 #include <BRepBuilderAPI_MakeVertex.hxx>
89 #include <BRepBuilderAPI_MakeEdge.hxx>
90 #include <BRepBuilderAPI_MakeWire.hxx>
91 #include <BRepBuilderAPI_MakeFace.hxx>
92 #include <BRepBuilderAPI_Transform.hxx>
94 #include <BRepTools.hxx>
95 #include <BRepTools_WireExplorer.hxx>
96 #include <BRepCheck_Analyzer.hxx>
98 #include <Geom_Circle.hxx>
99 #include <Geom_Line.hxx>
100 #include <Geom_Plane.hxx>
101 #include <Geom_Surface.hxx>
102 #include <Geom_Axis2Placement.hxx>
103 #include <Geom_TrimmedCurve.hxx>
105 #include <GeomAPI_ProjectPointOnCurve.hxx>
106 #include <GC_MakeArcOfCircle.hxx>
107 #include <gp_Pnt.hxx>
108 #include <gp_Circ.hxx>
109 #include <gp_Pln.hxx>
110 #include <gp_Mat.hxx>
112 #include <TopTools_MapOfShape.hxx>
113 #include <TopTools_MapIteratorOfMapOfShape.hxx>
114 #include <TopTools_ListIteratorOfListOfShape.hxx>
115 #include <TopoDS_Iterator.hxx>
117 //VRV: OCC 4.0 migration
118 #include <IGESControl_Writer.hxx>
119 #include <IGESControl_Controller.hxx>
120 #include <STEPControl_Writer.hxx>
121 //#include <STEPControlStd_StepModelType.hxx>
122 //VRV: OCC 4.0 migration
124 #include <TopoDS.hxx>
125 #include <TopoDS_Wire.hxx>
126 #include <TopoDS_Shape.hxx>
127 #include <TopoDS_Compound.hxx>
128 #include <TopAbs.hxx>
129 #include <TopExp.hxx>
130 #include <TopExp_Explorer.hxx>
132 #include <Precision.hxx>
133 #include <ProjLib.hxx>
134 #include <ElSLib.hxx>
136 #include <IFSelect_ReturnStatus.hxx>
137 #include <Interface_Static.hxx>
140 #define INCLUDE_MENUITEM_DEF
141 // #include <qapplication.h>
142 // #include <qmenudata.h>
143 // #include <qmenubar.h>
144 // #include <qpopupmenu.h>
145 // #include <qfont.h>
146 // #include <qstring.h>
147 // #include <qcheckbox.h>
148 #include <qcolordialog.h>
149 #include <qmessagebox.h>
150 #include <qspinbox.h>
151 // #include <qlist.h>
152 // #include <qwidget.h>
153 // #include <qevent.h>
154 // #include <qlineedit.h>
156 #include "VTKViewer_RenderWindowInteractor.h"
157 #include "VTKViewer_ViewFrame.h"
158 #include "GEOM_Actor.h"
159 #include "GEOM_Client.hxx"
160 #include "GEOM_AISShape.hxx"
161 #include "GEOM_AssemblyBuilder.h"
162 #include "GEOM_InteractiveObject.hxx"
165 #include "GeometryGUI_aParameterDlg.h"
167 #include "GeometryGUI_PointDlg.h" // Method POINT
168 #include "GeometryGUI_BoxDlg.h" // Method BOX
169 #include "GeometryGUI_VectorDlg.h" // Method VECTOR
170 #include "GeometryGUI_PlaneDlg.h" // Method PLANE
171 #include "GeometryGUI_PrismDlg.h" // Method PRISM
172 #include "GeometryGUI_FuseDlg.h" // Method FUSE
173 #include "GeometryGUI_CommonDlg.h" // Method COMMON
174 #include "GeometryGUI_CutDlg.h" // Method CUT
175 #include "GeometryGUI_SectionDlg.h" // Method SECTION
177 #include "GeometryGUI_LineDlg.h" // Method LINE
178 #include "GeometryGUI_ScaleDlg.h" // Method SCALE
179 #include "GeometryGUI_MirrorDlg.h" // Method MIRROR
180 #include "GeometryGUI_SphereDlg.h" // Method SPHERE
181 #include "GeometryGUI_CircleDlg.h" // Method CIRCLE
182 #include "GeometryGUI_EllipseDlg.h" // Method ELLIPSE
183 #include "GeometryGUI_RevolDlg.h" // Method REVOL
184 #include "GeometryGUI_RotationDlg.h" // Method ROTATION
185 #include "GeometryGUI_TranslationDlg.h" // Method TRANSLATION
186 #include "GeometryGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
187 #include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION
188 #include "GeometryGUI_ArcDlg.h" // Method ARC
189 #include "GeometryGUI_PipeDlg.h" // Method PIPE
190 #include "GeometryGUI_CylinderDlg.h" // Method CYLINDER
191 #include "GeometryGUI_ConeDlg.h" // Method CONE
192 #include "GeometryGUI_TorusDlg.h" // Method TORUS
193 #include "GeometryGUI_FillingDlg.h" // Method FILLING
194 #include "GeometryGUI_SewingDlg.h" // Method SEWING
195 #include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND
196 #include "GeometryGUI_EdgeDlg.h" // Method GEOM::EDGE
197 #include "GeometryGUI_OrientationDlg.h" // Method ORIENTATION
198 #include "GeometryGUI_PartitionDlg.h" // Method PARTITION
199 #include "GeometryGUI_SubShapeDlg.h" // Method EXPLODE
200 #include "GeometryGUI_WireDlg.h" // Method GEOM::WIRE
201 #include "GeometryGUI_WorkingPlaneDlg.h" // Method WORKING PLANE
202 #include "GeometryGUI_PropertiesDlg.h" // Method PROPERTIES
203 #include "GeometryGUI_CenterMassDlg.h" // Method CENTER MASS
204 #include "GeometryGUI_InertiaDlg.h" // Method INERTIA
205 #include "GeometryGUI_FaceDlg.h" // Method GEOM::FACE
206 #include "GeometryGUI_ShellDlg.h" // Method GEOM::SHELL
207 #include "GeometryGUI_SolidDlg.h" // Method GEOM::SOLID
208 #include "GeometryGUI_FilletDlg.h" // Method FILLET
209 #include "GeometryGUI_ChamferDlg.h" // Method CHAMFER
210 #include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE
211 #include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES
212 #include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE
213 #include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE
214 #include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement
215 #include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement
216 #include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX
217 #include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
218 #include "GeometryGUI_WhatisDlg.h" // Method WHATIS
219 #include "GeometryGUI_DistanceDlg.h" // Method DISTANCE
220 #include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE
223 static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape());
224 static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), "");
226 static AIS_ListOfInteractive ListDisplayedObject;
228 static bool Settings_AddInStudy = false;
229 static bool Settings_Copy = false;
230 static Standard_CString Fatherior = "";
231 static GEOM_Client ShapeReader;
233 /* The object itself created in the static method 'GetOrCreateGeometryGUI()' */
234 static GeometryGUI* GeomGUI = 0;
238 //=======================================================================
239 // class : CustomItem
240 // purpose : Set Font to a text.
241 //=======================================================================
242 class CustomItem : public QCustomMenuItem
245 CustomItem( const QString& s, const QFont& f )
246 : string( s ), font( f ){};
249 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
252 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
257 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
267 //=======================================================================
268 // function : GeometryGUI()
269 // purpose : Constructor
270 //=======================================================================
271 GeometryGUI::GeometryGUI() :
276 //=======================================================================
277 // function : ~GeometryGUI()
278 // purpose : Destructor
279 //=======================================================================
280 GeometryGUI::~GeometryGUI()
285 //=======================================================================
286 // function : GetGeometryGUI() static
287 // purpose : Returns current 'GeomGUI' a static pointer
288 //=======================================================================
289 GeometryGUI* GeometryGUI::GetGeometryGUI( )
295 //=====================================================================================
296 // function : GetIndex()
297 // purpose : Get the index of a sub shape in a main shape : index start at 1
298 //=====================================================================================
299 int GeometryGUI::GetIndex(const TopoDS_Shape& subshape,
300 const TopoDS_Shape& shape,
303 if( shape.IsNull() || subshape.IsNull() )
307 if (subshape.ShapeType() == TopAbs_COMPOUND)
310 TopTools_ListOfShape CL;
312 TopTools_ListIteratorOfListOfShape itC;
313 for (itC.Initialize( CL ); itC.More(); itC.Next())
315 for (it.Initialize( itC.Value() ); it.More(); it.Next())
317 if ( it.Value().ShapeType() == TopAbs_COMPOUND)
319 if (it.Value().IsSame(subshape))
323 CL.Append( it.Value() );
330 TopExp_Explorer Exp ( shape, subshape.ShapeType() );
331 TopTools_MapOfShape M;
334 if ( M.Add(Exp.Current()) )
336 if ( Exp.Current().IsSame(subshape) )
346 //=======================================================================
347 // function : GetOrCreateGeometryGUI()
348 // purpose : Gets or create an object 'GeometryGUI' with initialisations
349 // : Returns 'GeomGUI' as a pointer
350 //=======================================================================
351 GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
354 GeomGUI = new GeometryGUI;
355 GeomGUI->myActiveDialogBox = 0 ;
356 GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape());
357 GeomGUI->myState = -1 ;
358 GeomGUI->myDesktop = desktop ;
359 GeomGUI->myActiveStudy = desktop->getActiveStudy();
360 GeomGUI->mySimulationActor = vtkActorCollection::New() ;
362 GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
364 Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
365 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
367 /* GetCurrentStudy */
368 int studyId = GeomGUI->myActiveStudy->getStudyId();
369 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
371 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
373 /* study may have changed */
374 GeomGUI->myActiveStudy = desktop->getActiveStudy();
380 //=================================================================================
381 // function : VertexToPoint()
382 // purpose : If S can be converted in a gp_Pnt returns true and the result is P
383 //=================================================================================
384 bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P )
386 if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX )
388 P = BRep_Tool::Pnt(TopoDS::Vertex( S ));
393 //=================================================================================
394 // function : LinearEdgeExtremities()
395 // purpose : If S can be converted in a linear edge and if initial an final points
396 // : distance is sufficient, returns true else returns false.
397 // : Resulting points are respectively P1 and P2
398 //=================================================================================
399 bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 )
401 if( S.IsNull() || S.ShapeType() != TopAbs_EDGE )
403 BRepAdaptor_Curve curv(TopoDS::Edge(S));
404 if (curv.GetType() != GeomAbs_Line)
407 curv.D0( curv.FirstParameter(), P1 );
408 curv.D0( curv.LastParameter(), P2 );
410 if( P1.Distance(P2) <= Precision::Confusion() )
416 //=================================================================================
417 // function : GetBipointDxDyDz()
419 //=================================================================================
420 void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz )
422 dx = P2.X() - P1.X() ;
423 dy = P2.Y() - P1.Y() ;
424 dz = P2.Z() - P1.Z() ;
428 //=======================================================================
429 // function : GetTopoFromSelection()
430 // purpose : Define tds from a single selection and retuen true
431 //=======================================================================
432 bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
434 if(Sel->IObjectCount() != 1)
437 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
439 if ( IO->hasEntry() ) {
440 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
441 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
442 SALOMEDS::GenericAttribute_var anAttr;
443 SALOMEDS::AttributeIOR_var anIOR;
444 if ( !obj->_is_nil() ) {
445 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
446 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
447 tds = this->GetShapeFromIOR(anIOR->Value());
456 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
457 Standard_CString ior = "";
458 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
459 ior = GIObject->getIOR();
460 tds = this->GetShapeFromIOR(ior);
472 //=====================================================================================
473 // function : PrepareSubShapeSelection()
474 // purpose : ( localContextId of the method is opened and defined here)
475 //=====================================================================================
476 bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
478 //* Test the type of viewer */
479 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
482 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
483 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
485 /* local context opening */
486 SetDisplayedObjectList() ;
489 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
490 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
491 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
492 for(;It.More();It.Next()) {
493 Handle(SALOME_InteractiveObject) IObject = It.Value();
494 Standard_Boolean found;
495 Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found);
496 if ( found && SubShapeType >= Shape->Shape().ShapeType()) {
497 ic->Load(Shape, (8 - SubShapeType), Standard_True);
498 ic->HilightWithColor(Shape, Quantity_NOC_RED);
501 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
507 //=====================================================================================
508 // function : PrepareSubShapeSelectionArgumentShape()
509 // purpose : ( localContextId of the method is opened and defined here )
510 //=====================================================================================
511 bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
512 const int SubShapeType,
513 Standard_Integer& returnLocalContextId )
515 //* Test the type of viewer */
516 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
519 if( aShape.IsNull() )
522 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
523 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
525 /* local context opening */
526 SetDisplayedObjectList() ;
529 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
531 Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ;
532 ic->Display(Shape, 0, (8 - SubShapeType));
534 // Not Load(...) but Display(...)
535 // ic->Load(Shape, (8 - SubShapeType), Standard_True);
536 ic->HilightWithColor(Shape, Quantity_NOC_RED);
538 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
544 //=======================================================================
545 // function : GetNameOfSelectedIObjects()
546 // purpose : Define the name geom++ or other name of mono or multi sel.
547 //=======================================================================
548 int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel,
551 int nbSel = Sel->IObjectCount() ;
553 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
554 aName = IObject->getName();
556 aName = tr( "%1_objects" ).arg( nbSel );
562 //=======================================================================
563 // function : ConvertIOinGEOMAISShape()
565 //=======================================================================
566 Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
567 Standard_Boolean& testResult,
568 bool onlyInActiveView )
570 Handle(GEOM_AISShape) res;
571 int nbSf = myActiveStudy->getStudyFramesCount();
572 for ( int i = 0; i < nbSf; i++ ) {
573 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
574 if ( sf->getTypeView() == VIEW_OCC ) {
575 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
576 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
578 AIS_ListOfInteractive List;
579 ic->DisplayedObjects(List);
580 AIS_ListOfInteractive List1;
581 ic->ObjectsInCollector(List1);
584 AIS_ListIteratorOfListOfInteractive ite(List);
586 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
587 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
588 if ( aSh->hasIO() ) {
589 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
590 if ( GIO->isSame( IO ) ) {
591 if ( onlyInActiveView ) {
592 if ( sf == myActiveStudy->getActiveStudyFrame() ) {
611 //=======================================================================
612 // function : ConvertIORinGEOMAISShape()
614 //=======================================================================
615 Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR,
616 Standard_Boolean& testResult,
617 bool onlyInActiveView )
619 Handle(GEOM_AISShape) resultShape;
621 int nbSf = myActiveStudy->getStudyFramesCount();
622 for ( int i = 0; i < nbSf; i++ )
624 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
625 if ( sf->getTypeView() == VIEW_OCC )
627 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
628 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
630 AIS_ListOfInteractive List;
631 ic->DisplayedObjects(List);
632 AIS_ListOfInteractive List1;
633 ic->ObjectsInCollector(List1);
636 AIS_ListIteratorOfListOfInteractive ite(List);
639 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
641 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
644 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
645 Standard_CString theIOR = GIO->getIOR();
646 if ( strcmp( IOR, theIOR ) == 0 )
648 if ( onlyInActiveView )
650 if ( sf == myActiveStudy->getActiveStudyFrame() )
672 //=======================================================================
673 // function : ConvertIORinGEOMActor()
675 //=======================================================================
676 GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
677 Standard_Boolean& testResult,
678 bool onlyInActiveView )
680 int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount();
681 for ( int i = 0; i < nbSf; i++ ) {
682 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
683 if ( sf->getTypeView() == VIEW_VTK ) {
684 vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
685 vtkActorCollection* theActors = Renderer->GetActors();
686 theActors->InitTraversal();
687 vtkActor *ac = theActors->GetNextActor();
689 if ( ac->IsA("GEOM_Actor") ) {
690 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
691 if ( anActor->hasIO() ) {
692 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO());
693 Standard_CString theIOR = GIO->getIOR();
694 if ( strcmp( IOR, theIOR ) == 0 ) {
695 if ( onlyInActiveView ) {
696 if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) {
707 ac = theActors->GetNextActor();
712 return GEOM_Actor::New();
715 //=======================================================================
716 // function : ConvertIOinGEOMShape()
718 //=======================================================================
719 GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
720 Standard_Boolean& testResult )
722 GEOM::GEOM_Shape_ptr aShape ;
726 if ( IO->hasEntry() ) {
727 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
728 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
729 SALOMEDS::GenericAttribute_var anAttr;
730 SALOMEDS::AttributeIOR_var anIOR;
731 if ( !obj->_is_nil() ) {
732 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
733 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
734 aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
740 /* case Graphical Object */
741 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
742 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
743 Standard_CString ior = GIObject->getIOR();
745 aShape = myComponentGeom->GetIORFromString(ior) ;
752 //=======================================================================
753 // function : ConvertListOfIOInListOfIOR()
755 //=======================================================================
756 void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
757 GEOM::GEOM_Gen::ListOfIOR& listIOR )
759 int nbSel = aList.Extent();
760 listIOR.length(nbSel) ;
762 SALOME_ListIteratorOfListIO It( aList );
763 for ( int i=0; It.More(); It.Next(), i++ )
765 Handle(SALOME_InteractiveObject) IObject = It.Value();
767 if ( IObject->hasEntry() )
769 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
770 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
771 SALOMEDS::GenericAttribute_var anAttr;
772 SALOMEDS::AttributeIOR_var anIOR;
773 if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") )
775 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
776 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
777 CORBA::ORB_var& _orb = init.orb() ;
778 CORBA::String_var theValue = anIOR->Value();
779 CORBA::Object_var theObj = _orb->string_to_object(theValue);
780 if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0"))
782 listIOR[j] = strdup(theValue) ;
787 else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
788 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject );
789 Standard_CString ior = GIObject->getIOR();
790 listIOR[j] = strdup(ior) ;
798 //=================================================================================
799 // function : GetShapeTypeString()
800 // purpose : for a single shape
801 //=================================================================================
802 bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString )
804 if( aShape.IsNull() ) {
805 aTypeString = "aNullShape" ;
808 switch (aShape.ShapeType() )
810 case TopAbs_COMPOUND:
811 { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; }
812 case TopAbs_COMPSOLID:
813 { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; }
815 { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; }
817 { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; }
820 BRepAdaptor_Surface surf(TopoDS::Face(aShape));
821 if ( surf.GetType() == GeomAbs_Plane ) {
822 aTypeString = strdup(tr("GEOM_PLANE")) ;
824 } else if ( surf.GetType() == GeomAbs_Cylinder ) {
825 aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ;
827 } else if ( surf.GetType() == GeomAbs_Sphere ) {
828 aTypeString = strdup(tr("GEOM_SURFSPHERE")) ;
830 } else if ( surf.GetType() == GeomAbs_Torus ) {
831 aTypeString = strdup(tr("GEOM_SURFTORUS")) ;
833 } else if ( surf.GetType() == GeomAbs_Cone ) {
834 aTypeString = strdup(tr("GEOM_SURFCONE")) ;
837 aTypeString = strdup(tr("GEOM_FACE")) ;
842 { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; }
845 BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
846 if ( curv.GetType() == GeomAbs_Line ) {
847 if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
848 (Abs(curv.LastParameter()) >= 1E6 )) {
849 aTypeString = strdup(tr("GEOM_LINE")) ;
851 aTypeString = strdup(tr("GEOM_EDGE")) ;
853 } else if ( curv.GetType() == GeomAbs_Circle ) {
854 if ( curv.IsClosed() )
855 aTypeString = strdup(tr("GEOM_CIRCLE")) ;
857 aTypeString = strdup(tr("GEOM_ARC")) ;
860 aTypeString = strdup(tr("GEOM_EDGE")) ;
865 { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; }
867 { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; }
873 //=================================================================================
874 // function : CreateArrowForLinearEdge()
875 // purpose : Create a cone topology to be used to display an arrow in the middle
876 // : of an edge showing its orientation. (For simulation and Viewer OCC only)
877 //=================================================================================
878 bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone )
880 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE )
883 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
884 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
885 Standard_Real Width, Height ;
886 view3d->Size(Width, Height) ;
887 const Standard_Real aHeight = (Width + Height) / 50.0 ;
890 Standard_Real first, last ;
891 Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
895 const Standard_Real param = (first+last) / 2.0 ;
896 gp_Pnt middleParamPoint ;
898 curv->D1( param, middleParamPoint, V1) ;
899 if ( V1.Magnitude() < Precision::Confusion() )
902 /* Topology orientation not geom orientation */
903 if( tds.Orientation() == TopAbs_REVERSED )
906 gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ;
907 const Standard_Real radius1 = aHeight / 5.0 ;
908 if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) {
909 ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ;
913 catch(Standard_Failure) {
914 // OCC failures are hard to catch in GUI.
915 // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
916 // in SALOME environment : compilation error !
922 //=======================================================================
923 // function : SelectionByNameInDialogs()
924 // purpose : Called when user has entered a name of object in a LineEdit.
925 // : The selection is changed. Dialog box will receive the
926 // : corresponding signal to manage this event.
927 //=======================================================================
928 bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel )
931 /* Find SObject with name in component GEOM */
932 SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ;
933 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
934 listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ;
936 if ( listSO->length() < 1 ) {
937 const QString caption = tr("GEOM_WRN_WARNING") ;
938 const QString text = tr("GEOM_NAME_INCORRECT") ;
939 const QString button0 = tr("GEOM_BUT_OK") ;
940 QMessageBox::warning( aWidget, caption, text, button0 ) ;
943 /* More than one object with same name */
944 if ( listSO->length() > 1 ) {
945 const QString caption = tr("GEOM_WRN_WARNING") ;
946 const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ;
947 const QString button0 = tr("GEOM_BUT_OK") ;
948 QMessageBox::warning( aWidget, caption, text, button0 ) ;
952 SALOMEDS::SObject_var theObj = listSO[0] ;
953 /* Create a SALOME_InteractiveObject with a SALOME::SObject */
954 Standard_CString anEntry = theObj->GetID() ;
955 Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ;
957 /* Add as a selected object */
958 /* Clear any previous selection : */
959 /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
960 Sel->ClearIObjects() ;
961 Sel->AddIObject( SI ) ;
966 //=======================================================================
967 // function : MakePointAndDisplay
969 //=======================================================================
970 void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z )
973 GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z );
974 P->NameType( tr("GEOM_VERTEX") );
975 if ( Display( P, "") )
976 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
978 catch (const SALOME::SALOME_Exception& S_ex) {
979 QtCatchCorbaException(S_ex);
986 //=======================================================================
987 // function : MakeVectorAndDisplay()
989 //=======================================================================
990 void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
993 GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
994 GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
995 GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 );
996 Vector->NameType(tr("GEOM_VECTOR"));
997 if ( Display( Vector, "") )
998 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1000 catch (const SALOME::SALOME_Exception& S_ex) {
1001 QtCatchCorbaException(S_ex);
1006 //=======================================================================
1007 // function : MakeBoxAndDisplay()
1009 //=======================================================================
1010 void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1013 GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() );
1014 box->NameType(tr("GEOM_BOX"));
1015 if ( Display( box, "") ) {
1016 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1019 catch (const SALOME::SALOME_Exception& S_ex) {
1020 QtCatchCorbaException(S_ex);
1027 //=======================================================================
1028 // function : MakePlaneAndDisplay()
1029 // purpose : Plane point is P1 and dx, dy, dz define a normal vector
1030 //=======================================================================
1031 void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
1032 const Standard_Real dy, const Standard_Real dz,
1033 const Standard_Real TrimSize )
1037 aDirection.SetCoord(dx, dy, dz) ;
1038 gp_Ax2 Axis( P1, aDirection );
1040 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1041 GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ;
1042 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1043 GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ;
1044 plane->NameType(tr("GEOM_PLANE"));
1045 if ( Display( plane, "") )
1046 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1048 catch (const SALOME::SALOME_Exception& S_ex) {
1049 QtCatchCorbaException(S_ex);
1054 //=======================================================================
1055 // function : MakeWorkingPlane()
1056 // purpose : Change the point of view3d
1057 //=======================================================================
1058 void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D)
1060 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
1061 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
1064 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
1065 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
1066 view3d->SetAt( P.X(), P.Y(), P.Z() );
1067 view3d->SetProj( D.X(), D.Y(), D.Z() );
1068 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1072 //=======================================================================
1073 // function : MakePrismAndDisplay()
1074 // purpose : P1 and P2 is to define a vector for prism
1075 //=======================================================================
1076 void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 )
1079 GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1080 GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ;
1081 if( BaseShape->_is_nil() ) {
1082 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1086 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ;
1087 if (result->_is_nil()) {
1088 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1092 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1093 Standard_CString type;
1094 GetShapeTypeString(S,type);
1095 result->NameType( type );
1097 if ( Display( result, "") )
1098 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1100 catch (const SALOME::SALOME_Exception& S_ex) {
1101 QtCatchCorbaException(S_ex);
1107 //=====================================================================================
1108 // function : MakeLineAndDisplay()
1109 // purpose : Create an infinite oriented line (linear edge in fact)
1110 //=====================================================================================
1111 void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint )
1115 GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ;
1116 Standard_Real length = InitPoint.Distance(LastPoint) ;
1117 if( length <= Precision::Confusion() ) {
1118 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1122 Standard_Real coeff = 1E6 / length ;
1124 /* To create a line with length = 1E6 */
1125 /* Precision::Infinite() is 1E100 in OCC */
1126 P1.SetX( InitPoint.X() - (coeff * dx) ) ;
1127 P1.SetY( InitPoint.Y() - (coeff * dy) ) ;
1128 P1.SetZ( InitPoint.Z() - (coeff * dz) ) ;
1130 P2.SetX( LastPoint.X() + (coeff * dx) ) ;
1131 P2.SetY( LastPoint.Y() + (coeff * dy) ) ;
1132 P2.SetZ( LastPoint.Z() + (coeff * dz) ) ;
1135 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ;
1136 GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ;
1137 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1139 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ;
1140 if(result->_is_nil()) {
1141 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1144 result->NameType(tr("GEOM_LINE"));
1146 if ( Display( result, "") )
1147 myDesktop->putInfo(tr("GEOM_PRP_READY"));
1149 catch (const SALOME::SALOME_Exception& S_ex) {
1150 QtCatchCorbaException(S_ex);
1157 //=======================================================================
1158 // function : MakeBooleanAndDisplay()
1160 //=======================================================================
1161 void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation )
1164 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ;
1165 if (result->_is_nil()) {
1166 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1170 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1171 Standard_CString type;
1172 GetShapeTypeString(S,type);
1173 result->NameType( type );
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 : MakeSphere()
1188 //=====================================================================================
1189 void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius )
1192 if( aRadius <= Precision::Confusion() ) {
1193 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"),
1194 tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") );
1197 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius);
1198 result->NameType(tr("GEOM_SPHERE"));
1199 if ( Display( result, "") )
1200 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1202 catch (const SALOME::SALOME_Exception& S_ex) {
1203 QtCatchCorbaException(S_ex);
1209 //=====================================================================================
1210 // function : MakeConeAndDisplay()
1212 //=====================================================================================
1213 void GeometryGUI::MakeConeAndDisplay( const gp_Pnt BasePoint,
1215 const double Radius1,
1216 const double Radius2,
1217 const double aHeight )
1220 if( ( Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion() ) || aHeight <= Precision::Confusion() )
1222 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1223 GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1224 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1226 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ;
1227 if ( result->_is_nil() ) {
1228 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1231 result->NameType(tr("GEOM_CONE"));
1232 if ( Display( result, "") )
1233 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1235 catch (const SALOME::SALOME_Exception& S_ex) {
1236 QtCatchCorbaException(S_ex);
1242 //=====================================================================================
1243 // function : MakeCylinderAndDisplay()
1245 //=====================================================================================
1246 void GeometryGUI::MakeCylinderAndDisplay( const gp_Pnt BasePoint,
1248 const double Radius,
1249 const double aHeight )
1252 if( Radius <= Precision::Confusion() || aHeight <= Precision::Confusion() )
1254 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1255 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1256 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1258 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ;
1259 if ( result->_is_nil() ) {
1260 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1263 result->NameType(tr("GEOM_CYLINDER"));
1264 if ( Display( result, "") )
1265 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1267 catch (const SALOME::SALOME_Exception& S_ex) {
1268 QtCatchCorbaException(S_ex);
1274 //=====================================================================================
1275 // function : MakeTorusAndDisplay()
1277 //=====================================================================================
1278 void GeometryGUI::MakeTorusAndDisplay( const gp_Pnt BasePoint,
1280 const double Radius1,
1281 const double Radius2 )
1284 if( Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion() )
1287 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1288 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1289 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1291 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ;
1292 if ( result->_is_nil() ) {
1293 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1296 result->NameType(tr("GEOM_TORUS"));
1297 if ( Display( result, "") )
1298 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1300 catch (const SALOME::SALOME_Exception& S_ex) {
1301 QtCatchCorbaException(S_ex);
1307 //=====================================================================================
1308 // function : MakePipeAndDisplay()
1310 //=====================================================================================
1311 void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase )
1314 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase);
1315 if ( !result->_is_nil() && Display( result, "") ) {
1317 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1318 Standard_CString type;
1319 GetShapeTypeString(S,type);
1320 result->NameType( type );
1322 myDesktop->putInfo( tr("GEOM_PRP_DONE") );
1325 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1328 catch (const SALOME::SALOME_Exception& S_ex) {
1329 QtCatchCorbaException(S_ex);
1335 //=====================================================================================
1336 // function : MakeFillingAndDisplay()
1338 //=====================================================================================
1339 void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape,
1344 const short nbiter )
1347 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape,
1349 tol3d, tol2d, nbiter );
1350 if (result->_is_nil()) {
1351 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1355 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1356 Standard_CString type;
1357 GetShapeTypeString(S,type);
1358 result->NameType( type );
1360 if ( Display( result, "") )
1361 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1364 catch (const SALOME::SALOME_Exception& S_ex) {
1365 QtCatchCorbaException(S_ex);
1371 //=====================================================================================
1372 // function : MakeMirrorAndDisplay()
1374 //=====================================================================================
1375 void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 )
1378 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 );
1379 if (result->_is_nil()) {
1380 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1383 result->NameType( Shape1->NameType() );
1384 if ( Display( result, "") )
1385 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1387 catch (const SALOME::SALOME_Exception& S_ex) {
1388 QtCatchCorbaException(S_ex);
1394 //=====================================================================================
1395 // function : MakeSewingAndDisplay()
1397 //=====================================================================================
1398 void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1399 const Standard_Real precision )
1402 GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ;
1403 if( result->_is_nil() ) {
1404 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1408 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1409 Standard_CString type;
1410 GetShapeTypeString(S,type);
1411 result->NameType( type );
1413 if( Display( result, "") )
1414 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1417 catch (const SALOME::SALOME_Exception& S_ex) {
1418 QtCatchCorbaException(S_ex);
1423 //=====================================================================================
1424 // function : MakeCompoundAndDisplay()
1426 //=====================================================================================
1427 void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1430 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ;
1431 if( result->_is_nil() ) {
1432 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1435 result->NameType(tr("GEOM_COMPOUND"));
1436 if( Display( result, "" ))
1437 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1439 catch (const SALOME::SALOME_Exception& S_ex) {
1440 QtCatchCorbaException(S_ex);
1446 //=====================================================================================
1447 // function : MakeFaceAndDisplay()
1449 //=====================================================================================
1450 void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar )
1453 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ;
1454 if( result->_is_nil() ) {
1455 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1459 result->NameType(tr("GEOM_PLANE"));
1461 result->NameType(tr("GEOM_FACE"));
1462 if( Display( result, "") )
1463 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1465 catch (const SALOME::SALOME_Exception& S_ex) {
1466 QtCatchCorbaException(S_ex);
1472 //=====================================================================================
1473 // function : MakeShellAndDisplay()
1475 //=====================================================================================
1476 void GeometryGUI::MakeShellAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1479 GEOM::GEOM_Shape_var result = myComponentGeom->MakeShell(listShapesIOR) ;
1480 if( result->_is_nil() ) {
1481 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1484 result->NameType(tr("GEOM_SHELL"));
1485 if( Display( result, "" ))
1486 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1488 catch (const SALOME::SALOME_Exception& S_ex) {
1489 QtCatchCorbaException(S_ex);
1495 //=====================================================================================
1496 // function : MakeSolidAndDisplay()
1498 //=====================================================================================
1499 void GeometryGUI::MakeSolidAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1502 GEOM::GEOM_Shape_var result = myComponentGeom->MakeSolid(listShapesIOR) ;
1503 if( result->_is_nil() ) {
1504 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1507 result->NameType(tr("GEOM_SOLID"));
1508 if( Display( result, "" ))
1509 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1511 catch (const SALOME::SALOME_Exception& S_ex) {
1512 QtCatchCorbaException(S_ex);
1518 //=====================================================================================
1519 // function : MakeLinearEdgeAndDisplay()
1521 //=====================================================================================
1522 void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1525 GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
1526 GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
1527 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ;
1528 if( result->_is_nil() ) {
1529 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1532 result->NameType(tr("GEOM_EDGE"));
1533 if( Display( result, "") )
1534 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1536 catch(const SALOME::SALOME_Exception& S_ex) {
1537 QtCatchCorbaException(S_ex);
1543 //=====================================================================================
1544 // function : MakeOrientationChangeAndDisplay()
1546 //=====================================================================================
1547 void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape )
1550 GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ;
1551 if( result->_is_nil() ) {
1552 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1555 result->NameType( Shape->NameType() );
1556 if ( Display( result, "" ))
1557 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1560 catch (const SALOME::SALOME_Exception& S_ex) {
1561 QtCatchCorbaException(S_ex);
1566 //=====================================================================================
1567 // function : MakeScaleAndDisplay()
1569 //=====================================================================================
1570 void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor )
1573 GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ;
1574 GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ;
1575 // result->NameType(tr("GEOM_SCALE"));
1576 result->NameType( Shape->NameType() );
1577 if ( Display( result, "") )
1578 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1580 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1582 catch (const SALOME::SALOME_Exception& S_ex) {
1583 QtCatchCorbaException(S_ex);
1589 //=======================================================================================
1590 // function : MakeRevolutionAndDisplay()
1592 //=======================================================================================
1593 void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle )
1596 GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1597 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ;
1598 if ( result->_is_nil() ) {
1599 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1603 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1604 Standard_CString type;
1605 GetShapeTypeString(S,type);
1606 result->NameType( type );
1608 if ( Display( result ) )
1609 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1611 catch (const SALOME::SALOME_Exception& S_ex) {
1612 QtCatchCorbaException(S_ex);
1618 //=======================================================================================
1619 // function : MakeRotationAndDisplay()
1621 //=======================================================================================
1622 void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape,
1625 const Standard_Real angle )
1628 const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1629 GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle);
1630 if ( result->_is_nil() ) {
1631 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1634 result->NameType( Shape->NameType() );
1635 if ( Display( result ) )
1636 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1638 catch (const SALOME::SALOME_Exception& S_ex) {
1639 QtCatchCorbaException(S_ex);
1645 //=================================================================================
1646 // function : MakeTranslationAndDisplay()
1647 // purpose : Translate a shape
1648 //=================================================================================
1649 void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V )
1652 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ;
1653 if ( result->_is_nil() ) {
1654 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1657 result->NameType( Shape->NameType() );
1658 if ( Display( result ) )
1659 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1661 catch (const SALOME::SALOME_Exception& S_ex) {
1662 QtCatchCorbaException(S_ex);
1667 //=================================================================================
1668 // function : MakeMultiTranslation1DAndDisplay()
1669 // purpose : Multi-Translate a shape
1670 //=================================================================================
1671 void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes )
1674 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1675 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1677 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes );
1678 if ( result->_is_nil() ) {
1679 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1682 result->NameType( tr("GEOM_COMPOUND") );
1683 if ( Display( result ) )
1684 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1686 catch (const SALOME::SALOME_Exception& S_ex) {
1687 QtCatchCorbaException(S_ex);
1693 //=================================================================================
1694 // function : MakeMultiTranslation2DAndDisplay()
1695 // purpose : Multi-Translate a shape
1696 //=================================================================================
1697 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 )
1700 GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ;
1701 GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ;
1702 GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ;
1703 GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ;
1705 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 );
1706 if ( result->_is_nil() ) {
1707 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1710 result->NameType( tr("GEOM_COMPOUND") );
1711 if ( Display( result ) )
1712 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1714 catch (const SALOME::SALOME_Exception& S_ex) {
1715 QtCatchCorbaException(S_ex);
1721 //=================================================================================
1722 // function : MakeMultiRotation1DAndDisplay()
1723 // purpose : Multi-Rotate a shape
1724 //=================================================================================
1725 void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes )
1728 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1729 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1730 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1732 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes );
1733 if ( result->_is_nil() ) {
1734 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1737 result->NameType( tr("GEOM_COMPOUND") );
1738 if ( Display( result ) )
1739 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1741 catch (const SALOME::SALOME_Exception& S_ex) {
1742 QtCatchCorbaException(S_ex);
1748 //=================================================================================
1749 // function : MakeMultiRotation2DAndDisplay()
1750 // purpose : Multi-Rotate a shape
1751 //=================================================================================
1752 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 )
1755 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1756 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1757 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1759 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 );
1760 if ( result->_is_nil() ) {
1761 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1764 result->NameType( tr("GEOM_COMPOUND") );
1765 if ( Display( result ) )
1766 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1768 catch (const SALOME::SALOME_Exception& S_ex) {
1769 QtCatchCorbaException(S_ex);
1776 //=======================================================================================
1777 // function : MakeArcAndDisplay()
1778 // purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
1779 //=======================================================================================
1780 void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint )
1782 gp_Vec v1( CirclePoint, InitPoint ) ;
1783 gp_Vec v2( CirclePoint, EndPoint ) ;
1784 if( v1.IsParallel(v2, Precision::Angular() ) )
1788 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() );
1789 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() );
1790 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() );
1791 GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ;
1792 if ( result->_is_nil() ) {
1793 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1796 result->NameType(tr("GEOM_ARC"));
1797 if ( Display( result ) )
1798 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1800 catch (const SALOME::SALOME_Exception& S_ex) {
1801 QtCatchCorbaException(S_ex);
1807 //=====================================================================================
1808 // function : MakeCircleAndDisplay()
1810 //=====================================================================================
1811 void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius )
1814 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1815 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1816 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1818 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ;
1819 if ( result->_is_nil() ) {
1820 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1823 result->NameType(tr("GEOM_CIRCLE"));
1824 if ( Display( result ) )
1825 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1827 catch (const SALOME::SALOME_Exception& S_ex) {
1828 QtCatchCorbaException(S_ex);
1834 //=====================================================================================
1835 // function : MakeEllipseAndDisplay()
1837 //=====================================================================================
1838 void GeometryGUI::MakeEllipseAndDisplay( const gp_Pnt CenterPoint,
1840 const Standard_Real Major_Radius,
1841 const Standard_Real Minor_Radius )
1844 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1845 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1846 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1848 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius) ;
1849 if ( result->_is_nil() ) {
1850 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1853 result->NameType(tr("GEOM_ELLIPSE"));
1854 if ( Display( result ) )
1855 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1857 catch (const SALOME::SALOME_Exception& S_ex) {
1858 QtCatchCorbaException(S_ex);
1864 //=====================================================================================
1865 // function : MakeWireAndDisplay()
1867 //=====================================================================================
1868 void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1871 GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ;
1872 if( result->_is_nil() ) {
1873 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1876 result->NameType(tr("GEOM_WIRE"));
1877 if( Display( result, "") )
1878 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1880 catch (const SALOME::SALOME_Exception& S_ex) {
1881 QtCatchCorbaException(S_ex);
1887 //=====================================================================================
1888 // function : MakePartitionAndDisplay()
1890 //=====================================================================================
1891 void GeometryGUI::MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1892 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
1893 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
1894 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
1895 const GEOM::shape_type limit)
1898 GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR,
1902 (CORBA::Short) limit);
1903 if( result->_is_nil() ) {
1904 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1907 result->NameType(tr("GEOM_PARTITION"));
1908 if( Display( result, "") )
1909 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1912 catch (const SALOME::SALOME_Exception& S_ex) {
1913 QtCatchCorbaException(S_ex);
1917 //=======================================================================
1918 // function : SetState()
1919 // purpose : Sets myState = aState a private field indicating which methode is active
1920 //=======================================================================
1921 void GeometryGUI::SetState(int aState )
1922 { this->myState = aState ; return ; }
1925 //=======================================================================
1926 // function : ResetState()
1927 // purpose : Sets myState = -1 a private field indicating which methode is active
1928 //=======================================================================
1929 void GeometryGUI::ResetState()
1930 { this->myState = -1 ; return ; }
1933 //=======================================================================
1934 // function : EmitSignalDeactivateDialog()
1935 // purpose : Emit a signal to deactivate the active dialog Box
1936 //=======================================================================
1937 void GeometryGUI::EmitSignalDeactivateDialog()
1939 emit this->SignalDeactivateActiveDialog() ;
1943 //=======================================================================
1944 // function : EmitSignalCloseAllDialogs()
1945 // purpose : Emit a signal to deactivate all non modal dialogs box
1946 //=======================================================================
1947 void GeometryGUI::EmitSignalCloseAllDialogs()
1949 emit this->SignalCloseAllDialogs() ;
1954 //=======================================================================
1955 // function : GetActiveDialogBox()
1957 //=======================================================================
1958 QDialog* GeometryGUI::GetActiveDialogBox()
1960 return this->myActiveDialogBox ;
1964 //=======================================================================
1965 // function : SetActiveDialogBox()
1967 //=======================================================================
1968 void GeometryGUI::SetActiveDialogBox(QDialog* aDlg)
1970 this->myActiveDialogBox = (QDialog*)aDlg ;
1975 //=======================================================================
1976 // function : GetActiveStudy()
1978 //=======================================================================
1979 QAD_Study* GeometryGUI::GetActiveStudy()
1981 return this->myActiveStudy ;
1985 //=======================================================================
1986 // function : GetActiveDesktop()
1988 //=======================================================================
1989 QAD_Desktop* GeometryGUI::GetDesktop()
1991 return this->myDesktop ;
1995 //=====================================================================================
1996 // function : OnSubShapeGetAll()
1997 // purpose : Explode a shape in all sub shapes with a SubShapeType
1998 //=====================================================================================
1999 bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
2001 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2002 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2003 if ( theObj->_is_nil() ) {
2004 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2008 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2009 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
2010 SALOMEDS::GenericAttribute_var anAttr;
2011 SALOMEDS::AttributeName_var aName;
2012 SALOMEDS::AttributeIOR_var anIOR;
2013 SALOMEDS::AttributePixMap_var aPixmap;
2015 /* We create a sub object for each sub shape as attribute of the main object */
2016 /* Each sub object contains list (length=1) containing its index in the main shape */
2017 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2018 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
2019 GEOM::GEOM_Shape_var aResult ;
2022 listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType );
2023 if( listGeomShapes->length() < 1 ) {
2024 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
2028 catch (const SALOME::SALOME_Exception& S_ex) {
2029 QtCatchCorbaException(S_ex);
2032 /* open transaction */
2033 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
2036 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
2037 TopoDS_Shape mainShape;
2040 if ( aShape->IsMainShape() ) {
2041 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
2044 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2047 /* Loop on each sub shape created */
2048 /* int i = 1 ; /* index for the nameType */
2049 for( int j=0; j<listGeomShapes->length(); j++) {
2051 /* Get each sub shape extracted CORBA and OCC */
2052 aResult = listGeomShapes[j] ;
2053 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2056 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
2060 // NRI : Following lines are commented according to bugID SAL695 (see history)
2061 // BRepCheck_Analyzer anAnalyzer(S);
2062 // if(!anAnalyzer.IsValid()) {
2063 // myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
2064 // MESSAGE("#### An exploded shape number "<< j << " is not valid");
2069 /* Set the nameType of sub shape */
2070 char* nameG = (char *)malloc(20);
2071 Standard_CString Type;
2072 if ( GetShapeTypeString(S, Type) ) {
2073 aResult->NameType( Type );
2074 sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) );
2077 aResult->NameType( tr("GEOM_SHAPE") );
2078 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2080 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2082 bool allreadyexist = false;
2084 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2085 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2086 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2088 Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG );
2089 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2091 MESSAGE ( "SO->_is_nil() " << SO->_is_nil() )
2093 if ( SO->_is_nil() ) {
2094 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2095 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2096 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2097 aName->SetValue(nameG);
2098 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2099 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2100 anIOR->SetValue(aResult->Name());
2102 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2103 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2104 MESSAGE( " Type " << S.ShapeType() )
2105 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2106 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2107 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2108 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2109 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2110 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2111 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2112 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2113 } else if ( S.ShapeType() == TopAbs_FACE ) {
2114 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2115 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2116 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2117 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2118 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2119 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2120 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2123 MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() )
2125 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2126 aStudyBuilder->Addreference(newObj1, newObj);
2127 IO->setEntry(newObj->GetID());
2129 aResult->StudyShapeId( newObj->GetID() );
2131 allreadyexist = true;
2132 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2133 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2134 aStudyBuilder->Addreference(newObj1, SO);
2135 IO->setEntry(SO->GetID());
2136 aResult->StudyShapeId( SO->GetID() );
2140 result->setIO( IO );
2141 result->setName( nameG );
2142 if ( !allreadyexist )
2143 ic->Display(result);
2145 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2146 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
2148 int themode = myRenderInter->GetDisplayMode();
2149 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2150 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
2152 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM");
2154 if ( SO->_is_nil() ) {
2155 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2156 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2157 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2158 anIOR->SetValue(aResult->Name());
2159 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2160 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2161 aName->SetValue(nameG);
2163 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2164 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2165 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2166 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2167 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2168 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2169 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2170 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2171 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2172 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2173 } else if ( S.ShapeType() == TopAbs_FACE ) {
2174 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2175 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2176 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2177 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2178 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2179 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2180 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2183 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2184 aStudyBuilder->Addreference(newObj1, newObj);
2185 IO->setEntry(newObj->GetID());
2187 allreadyexist = true;
2188 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2189 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2190 aStudyBuilder->Addreference(newObj1, SO);
2191 IO->setEntry(SO->GetID());
2195 if ( !allreadyexist ) {
2196 vtkActorCollection* theActors =
2197 GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
2198 theActors->InitTraversal();
2199 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
2200 while(!(anActor==NULL)) {
2201 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
2202 GActor->setIO( IO );
2203 GActor->setName( nameG );
2204 theRenderer->AddActor(GActor);
2206 anActor = (vtkActor*)theActors->GetNextActor();
2212 /* commit transaction */
2215 myActiveStudy->updateObjBrowser();
2216 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2222 //=====================================================================================
2223 // function : GetIndexSubShapeSelected()
2224 // purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType
2225 // : Method used by Dialogs
2226 //=====================================================================================
2227 bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
2228 const int SubShapeType,
2229 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
2230 Standard_Integer& aLocalContextId,
2231 bool& myUseLocalContext )
2233 //* Test the type of viewer */
2234 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2238 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2239 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2242 int nbSelected = ic->NbSelected();
2243 ListOfID.length(nbSelected);
2246 //***************** DEFINE INDEX OF EACH SELECTION *********************//
2248 ic->InitSelected(); /* to restart */
2249 while( ic->MoreSelected() ) {
2251 /* Find index of sub shape into main shape */
2252 TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) );
2254 bool found = false ;
2255 while ( Exp.More() ) {
2256 if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) {
2264 /* Manage local context from DialogBox */
2265 ic->CloseLocalContext(aLocalContextId) ;
2266 myUseLocalContext = false ;
2269 ListOfID[i] = index ;
2273 //***************** END *********************//
2275 /* Manage local context from DialogBox */
2276 ic->CloseLocalContext(aLocalContextId) ;
2277 myUseLocalContext = false ;
2283 //=====================================================================================
2284 // function : OnSubShapeGetSelected()
2286 //=====================================================================================
2287 bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
2288 const char* ShapeTopoIOR,
2289 const int SubShapeType,
2290 Standard_Integer& aLocalContextId,
2291 bool& myUseLocalContext )
2293 //* Test the type of viewer */
2294 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2298 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2299 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2300 if ( theObj->_is_nil() ) {
2301 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2306 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2307 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2309 if( myUseLocalContext == false ) {
2310 /* local context is from DialogBox */
2311 MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
2315 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2316 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
2318 TopoDS_Shape mainShape;
2321 if ( aShape->IsMainShape() ) {
2322 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
2325 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2328 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2330 int nbSelected = ic->NbSelected();
2331 ListOfID->length(nbSelected);
2333 TopoDS_Compound compound;
2334 ic->InitSelected(); /* to init again */
2336 B.MakeCompound( compound );
2339 /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
2340 /* the compound is homogenous by selection */
2341 while(ic->MoreSelected()) {
2342 int index = GetIndex( ic->SelectedShape(), mainShape, SubShapeType );
2343 ListOfID[i] = index ;
2344 B.Add( compound, ic->SelectedShape() );
2349 /* Test if user has selected sub shapes */
2350 if( ListOfID->length() < 1 )
2353 GEOM::GEOM_Shape_var aResult ;
2355 aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID );
2357 catch (const SALOME::SALOME_Exception& S_ex) {
2358 QtCatchCorbaException(S_ex);
2361 /* local context from DialogBox */
2362 ic->CloseLocalContext(aLocalContextId) ;
2363 myUseLocalContext = false ;
2365 char* nameG = (char *)malloc(20);
2366 Standard_CString Type;
2368 Handle(GEOM_AISShape) result;
2369 Handle(GEOM_InteractiveObject) IO ;
2371 // if ( ! SObjectExist(theObj, aResult->Name()) ) {
2372 if ( nbSelected == 1 ) {
2373 TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) );
2375 if ( GetShapeTypeString(Exp.Current(),Type) ) {
2376 aResult->NameType( Type );
2377 sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) );
2379 aResult->NameType( tr("GEOM_SHAPE") );
2380 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2382 result = new GEOM_AISShape( Exp.Current(), nameG );
2383 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2387 if ( GetShapeTypeString(compound,Type) ) {
2388 aResult->NameType( Type );
2389 sprintf (nameG, "%s_%d", Type, this->myNbGeom++ );
2391 aResult->NameType( tr("GEOM_SHAPE") );
2392 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2394 result = new GEOM_AISShape( compound, nameG );
2395 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2398 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2400 /* open transaction */
2401 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
2404 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2405 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
2406 SALOMEDS::GenericAttribute_var anAttr;
2407 SALOMEDS::AttributeName_var aName;
2408 SALOMEDS::AttributeIOR_var anIOR;
2409 SALOMEDS::AttributePixMap_var aPixmap;
2411 bool allreadyexist = false;
2413 if ( SO->_is_nil() ) {
2414 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2415 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2416 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2417 anIOR->SetValue(aResult->Name());
2418 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2419 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2420 aName->SetValue(result->getName());
2422 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2423 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2424 if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) {
2425 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2426 } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) {
2427 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2428 } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) {
2429 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2430 } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) {
2431 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2432 } else if ( result->Shape().ShapeType() == TopAbs_FACE ) {
2433 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2434 } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) {
2435 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2436 } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) {
2437 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2438 } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) {
2439 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2442 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2443 aStudyBuilder->Addreference(newObj1, newObj);
2445 IO->setEntry(newObj->GetID());
2446 aResult->StudyShapeId(newObj->GetID());
2448 allreadyexist = true;
2449 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2450 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2451 aStudyBuilder->Addreference(newObj1, SO);
2453 IO->setEntry(SO->GetID());
2454 aResult->StudyShapeId(SO->GetID());
2458 /* commit transaction */
2461 result->setIO( IO );
2462 result->setName( nameG );
2464 if ( !allreadyexist )
2465 ic->Display(result);
2467 this->OnDisplayAll(true);
2468 myActiveStudy->updateObjBrowser();
2469 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2475 //=====================================================================================
2476 // function : OnSuppressFaces()
2477 // purpose : To suppress faces from a shape
2478 // : The result is one or more shells/faces as main shapes !
2479 //=====================================================================================
2480 bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
2481 const char* ShapeTopoIOR,
2482 const Standard_Integer& aLocalContextId,
2483 bool& myUseLocalContext )
2485 /* Test the type of viewer */
2486 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2490 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2491 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2492 if ( theObj->_is_nil() ) {
2493 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2497 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2498 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2500 if( myUseLocalContext == false ) {
2501 /* local context is from DialogBox */
2502 MESSAGE("Error : No local context opened for suppress faces method" << endl ) ;
2506 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2508 int nbSelected = ic->NbSelected();
2509 ListOfID->length(nbSelected);
2511 /* Create a list of indices of faces to be suppressed */
2513 const int SubShapeType = 4 ; /* GEOM::FACE type */
2514 ic->InitSelected(); /* to repositioning at beginning */
2515 while( ic->MoreSelected() ) {
2516 int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
2517 ListOfID[i] = index ;
2522 /* Close local context opened in DialogBox */
2523 ic->CloseLocalContext(aLocalContextId) ;
2524 myUseLocalContext = false ;
2526 /* Here is the main shape */
2527 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2528 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
2530 /* Call geom method that return a list of shells/faces as result of suppress */
2532 listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID );
2534 catch (const SALOME::SALOME_Exception& S_ex) {
2535 QtCatchCorbaException(S_ex);
2538 /* Test list of shells/faces */
2539 if( listGeomShapes->length() < 1 ) {
2543 /* Loop on each object created */
2544 for( int i=0; i<listGeomShapes->length(); i++ ) {
2546 GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ;
2547 TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace );
2553 char* nameG = (char *)malloc(20);
2554 Standard_CString Type;
2555 if ( GetShapeTypeString(S, Type) ) {
2556 aShellOrFace->NameType( Type );
2557 sprintf (nameG, "%s_%d", Type, this->myNbGeom++);
2560 aShellOrFace->NameType( tr("GEOM_SHAPE") );
2561 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2564 /* Display with name */
2565 if( !Display( aShellOrFace, nameG) ) {
2566 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
2571 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2576 //=====================================================================================
2577 // function : OnSuppressHole()
2578 // purpose : To suppress an hole on a shape 'ShapeTopo'.
2579 // : 'ListOfIdEndFace' may be an empty list.
2580 // : This means that hole do not traverse ShapeTopo.
2581 // : Warning : the hole to be suppressed must be defined by one or two single closed wires !
2582 //=====================================================================================
2583 bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR,
2584 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
2585 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
2586 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace )
2588 /* Test the type of viewer */
2589 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2594 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2595 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ;
2597 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2598 Standard_CString type;
2599 GetShapeTypeString(S,type);
2600 aResult->NameType( type );
2602 if ( Display( aResult, "" ) )
2603 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2605 catch (const SALOME::SALOME_Exception& S_ex) {
2606 QtCatchCorbaException(S_ex);
2612 //=====================================================================================
2613 // function : OnSuppressHolesInFaceOrShell()
2614 // purpose : To suppress one or more holes on a face
2615 // : 'ListOfIdWires' contains indices or wires/holes.
2616 //=====================================================================================
2617 bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
2618 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires )
2620 /* Test the type of viewer */
2621 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2626 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2627 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ;
2629 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2630 Standard_CString type;
2631 GetShapeTypeString(S,type);
2632 aResult->NameType( type );
2634 if ( Display( aResult, "") )
2635 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2637 catch (const SALOME::SALOME_Exception& S_ex) {
2638 QtCatchCorbaException(S_ex);
2645 //=======================================================================
2646 // function : activeStudyChanged()
2648 //=======================================================================
2649 void GeometryGUI::activeStudyChanged( QAD_Desktop* parent )
2651 MESSAGE ("GeometryGUI::activeStudyChanged init.")
2652 /* Create or retrieve an object GeomGUI */
2653 GeometryGUI::GetOrCreateGeometryGUI(parent);
2656 if (GeomGUI->myState == CURRENT_SKETCH) {
2657 GeomGUI->mySketcher.Clear();
2658 GeomGUI->ResetState();
2661 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2662 bool ViewOCC = false;
2663 if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
2666 Mb->setItemEnabled( 312, ViewOCC); //Sketch
2667 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
2668 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
2670 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2671 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2673 GeomGUI->EraseSimulationShape() ;
2674 GeomGUI->EmitSignalCloseAllDialogs() ;
2678 // GeomGUI->SetSettings( parent );
2679 // MESSAGE ("GeometryGUI::activeStudyChanged done.")
2684 //=======================================================================
2685 // function : DefineDlgPosition()
2686 // purpose : Define x and y the default position for a dialog box
2687 //=======================================================================
2688 bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
2690 /* Here the position is on the bottom right corner - 10 */
2691 QAD_Desktop* PP = QAD_Application::getDesktop() ;
2692 x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
2693 y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
2697 //=======================================================================
2698 // function : OnGUIEvent() [static]
2699 // purpose : manage all events on GUI
2700 //=======================================================================
2701 bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
2703 /* Create or retrieve an object GeomGUI */
2704 GeometryGUI::GetOrCreateGeometryGUI(parent);
2706 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
2707 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2709 OCCViewer_Viewer3d* v3d;
2710 Handle(AIS_InteractiveContext) ic;
2711 vtkRenderer* Renderer;
2713 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2715 bool ViewOCC = false;
2717 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2718 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2719 ic = v3d->getAISContext();
2721 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2722 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2723 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2725 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2726 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2728 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2729 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2731 // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER,
2732 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2733 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2734 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2736 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2737 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2742 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)
2745 switch (theCommandID)
2748 GeomGUI->OnEditCopy();
2752 GeomGUI->OnEditDelete();
2757 GeomGUI->SetState(111);
2759 GeomGUI->ResetState();
2764 GeomGUI->SetState(112);
2766 GeomGUI->ResetState();
2769 case 113: // IMPORT STEP
2771 GeomGUI->SetState(113);
2773 GeomGUI->ResetState();
2777 case 121: // EXPORT BREP
2779 GeomGUI->SetState(121);
2781 GeomGUI->ResetState();
2785 case 122: // EXPORT IGES
2787 GeomGUI->SetState(122);
2789 GeomGUI->ResetState();
2793 case 123: // EXPORT STEP
2795 GeomGUI->SetState(123);
2797 GeomGUI->ResetState();
2801 case 303: // EXPLODE : use ic
2803 GeomGUI->EmitSignalDeactivateDialog() ;
2804 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2805 GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ;
2809 case 304: // GEOM::EDGE
2811 GeomGUI->EmitSignalDeactivateDialog() ;
2812 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2813 GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ;
2817 case 305: // GEOM::WIRE
2819 GeomGUI->EmitSignalDeactivateDialog() ;
2820 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2821 GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ;
2825 case 306: // GEOM::FACE
2827 GeomGUI->EmitSignalDeactivateDialog() ;
2828 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2829 GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ;
2833 case 315: // GEOM::SHELL
2835 GeomGUI->EmitSignalDeactivateDialog() ;
2836 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2837 GeometryGUI_ShellDlg *aDlg = new GeometryGUI_ShellDlg ( parent, "", Sel ) ;
2841 case 316: // GEOM::SOLID
2843 GeomGUI->EmitSignalDeactivateDialog() ;
2844 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2845 GeometryGUI_SolidDlg *aDlg = new GeometryGUI_SolidDlg ( parent, "", Sel ) ;
2849 case 308: // GEOM::COMPOUND
2851 GeomGUI->EmitSignalDeactivateDialog() ;
2852 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2853 GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ;
2857 case 309: // SUPPRESS FACES : use ic
2859 GeomGUI->EmitSignalDeactivateDialog() ;
2860 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2861 GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ;
2865 case 314: // SUPPRESS HOLES : use ic
2867 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2868 GeomGUI->EmitSignalDeactivateDialog() ;
2869 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2870 GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ;
2873 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
2879 GeomGUI->EmitSignalDeactivateDialog() ;
2880 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2881 GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ;
2885 case 502: // ORIENTATION
2887 GeomGUI->EmitSignalDeactivateDialog() ;
2888 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2889 GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ;
2893 case 601: // PROPERTIES (Length, surface, volume)
2895 GeomGUI->EmitSignalDeactivateDialog() ;
2896 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2897 GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ;
2901 case 604: // CDG : Center of mass
2903 GeomGUI->EmitSignalDeactivateDialog() ;
2904 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2905 GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ;
2909 case 605: // INERTIA
2911 GeomGUI->EmitSignalDeactivateDialog() ;
2912 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2913 GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ;
2917 case 607: // MAXTOLERANCE
2919 GeomGUI->EmitSignalDeactivateDialog() ;
2920 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2921 GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ;
2927 GeomGUI->EmitSignalDeactivateDialog() ;
2928 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2929 GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ;
2933 case 609: // CHECKSHAPE
2935 GeomGUI->EmitSignalDeactivateDialog() ;
2936 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2937 GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ;
2941 case 701: // SETTINGS - COPY
2944 QMenuItem* item = parent->menuBar()->findItem(701,&pp);
2945 bool check = !pp->isItemChecked(701);
2946 pp->setItemChecked(701,check);
2947 Settings_Copy = check;
2948 QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy );
2952 case 702: // SETTINGS - ADD IN STUDY
2955 QMenuItem* item = parent->menuBar()->findItem(702,&pp);
2956 bool check = !pp->isItemChecked(702);
2957 pp->setItemChecked(702,check);
2958 Settings_AddInStudy = check;
2960 QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy );
2964 case 703: // SETTINGS - SHADING COLOR
2966 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2969 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
2970 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
2971 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
2973 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) {
2974 color = QColor (SCr.toInt(),
2978 Quantity_Color Default = Quantity_Color();
2979 color = QColor ( (int)Default.Red() * 255.0,
2980 (int)Default.Green()* 255.0,
2981 (int)Default.Blue() * 255.0 );
2984 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
2985 if ( c.isValid() ) {
2986 GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0,
2991 AIS_ListOfInteractive List;
2992 ic->DisplayedObjects(List);
2993 AIS_ListOfInteractive List1;
2994 ic->ObjectsInCollector(List1);
2997 AIS_ListIteratorOfListOfInteractive ite(List);
2998 while (ite.More()) {
2999 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3000 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3001 aSh->SetShadingColor( GeomGUI->myShadingColor );
3002 ic->Redisplay( aSh, Standard_True, Standard_True);
3007 ic->UpdateCurrentViewer();
3009 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() );
3010 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() );
3011 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() );
3017 case 704: // SETTINGS - ISOS
3019 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
3022 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
3023 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
3024 if ( !IsoU.isEmpty() )
3025 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
3028 if ( !IsoV.isEmpty() )
3029 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
3033 GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(),
3034 tr("GEOM_MEN_ISOS"), TRUE );
3035 int UIso = IsoU.toInt();
3036 int VIso = IsoV.toInt();
3038 NbIsosDlg->SpinBoxU->setValue(UIso) ;
3039 NbIsosDlg->SpinBoxV->setValue(VIso) ;
3041 if ( NbIsosDlg->exec() ) {
3042 UIso = NbIsosDlg->SpinBoxU->text().toInt() ;
3043 VIso = NbIsosDlg->SpinBoxV->text().toInt() ;
3045 ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
3046 ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
3047 QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */
3048 QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */
3051 AIS_ListOfInteractive List;
3052 ic->DisplayedObjects(List);
3053 AIS_ListOfInteractive List1;
3054 ic->ObjectsInCollector(List1);
3057 AIS_ListIteratorOfListOfInteractive ite(List);
3059 if ( ic->NbCurrents() )
3060 while (ite.More()) {
3061 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3063 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3064 Handle (AIS_Drawer) CurDrawer;
3065 CurDrawer = aSh->Attributes();
3066 CurDrawer->UIsoAspect()->SetNumber( UIso );
3067 CurDrawer->VIsoAspect()->SetNumber( VIso );
3068 ic->SetLocalAttributes(aSh, CurDrawer);
3073 ic->UpdateCurrentViewer();
3077 case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES
3079 //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
3082 QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
3083 if( step.isEmpty() )
3086 Standard_Boolean res = false ;
3087 double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ;
3089 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ;
3091 /* Emit signal to GeometryGUI_SpinBoxes */
3092 GeomGUI->SignalDefaultStepValueChanged( dd ) ;
3095 parent->putInfo(tr("GEOM_PRP_ABORT"));
3100 case 801: // ADD IN STUDY - POPUP VIEWER
3102 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3103 const SALOME_ListIO& ListSelected = Sel->StoredIObjects();
3104 SALOME_ListIteratorOfListIO It( ListSelected );
3105 for ( ; It.More(); It.Next() ) {
3106 Handle(SALOME_InteractiveObject) IObject = It.Value();
3107 GeomGUI->AddInStudy(true, IObject);
3109 /* Is set on the dialog box */
3110 QApplication::restoreOverrideCursor();
3116 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3117 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3118 for ( ; It.More(); It.Next() ) {
3119 Handle(SALOME_InteractiveObject) IObject = It.Value();
3121 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3122 SALOMEDS::GenericAttribute_var anAttr;
3123 SALOMEDS::AttributeName_var aName;
3124 if ( !obj->_is_nil() ) {
3125 if (obj->FindAttribute(anAttr, "AttributeName")) {
3126 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3128 QString nm = QString( aName->Value() );
3129 nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
3130 if ( !nm.isEmpty() ) {
3131 QApplication::setOverrideCursor( Qt::waitCursor );
3132 GeomGUI->myActiveStudy->renameIObject( IObject, nm );
3133 QApplication::restoreOverrideCursor();
3141 case 903: // DISPLAY OBJECT BROWSER
3143 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3145 QApplication::setOverrideCursor( Qt::waitCursor );
3147 SALOMEDS::SObject_var fatherSF =
3148 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3150 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3151 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3153 for(;It.More();It.Next()) {
3154 Handle(SALOME_InteractiveObject) IObject = It.Value();
3155 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3157 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3159 SALOMEDS::GenericAttribute_var anAttr;
3160 SALOMEDS::AttributeName_var aName;
3161 SALOMEDS::AttributeIOR_var anIOR;
3163 if(myRenderInter->isInViewer(IObject)) {
3164 myRenderInter->Display(IObject);
3168 if ( !obj->_is_nil() ) {
3169 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3170 // this SObject may be GEOM module root SObject
3171 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3172 bool useSubItems = false;
3173 while (anIter->More() && !useSubItems) {
3174 SALOMEDS::SObject_var subobj = anIter->Value();
3175 SALOMEDS::GenericAttribute_var aTmpAttr;
3176 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3180 } else anIter->Next();
3183 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3184 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3185 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3186 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3188 if (obj->FindAttribute(anAttr, "AttributeName")) {
3189 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3191 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3192 vtkActorCollection* theAllActors = theRenderer->GetActors();
3193 theAllActors->InitTraversal();
3194 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3195 Handle(SALOME_InteractiveObject) anIObj;
3196 // don't create new study object if it already exists
3197 bool isDisplayed = false;
3198 while(!(actor==NULL)) {
3199 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3201 if (Gactor->hasIO()) {
3202 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3204 anIObj = Gactor->getIO();
3205 if (!anIObj.IsNull()) myRenderInter->Display(anIObj);
3209 actor=(vtkActor*)(theAllActors->GetNextActor());
3213 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3216 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3217 aStudyBuilder->Addreference(newObj1, obj);
3218 // commit transaction
3221 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
3222 int themode = myRenderInter->GetDisplayMode();
3224 vtkActorCollection* theActors =
3225 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
3226 theActors->InitTraversal();
3227 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
3228 while(!(anActor==NULL)) {
3229 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
3230 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
3231 IO->setEntry(obj->GetID());
3232 GActor->setIO( IO );
3233 GActor->setName( IObject->getName() );
3235 theRenderer->AddActor(GActor);
3237 anActor = (vtkActor*)theActors->GetNextActor();
3241 // next item iteration
3244 anAttr = SALOMEDS::GenericAttribute::_nil();
3245 while (anIter->More() && anAttr->_is_nil()) {
3246 SALOMEDS::SObject_var subobject = anIter->Value();
3247 SALOMEDS::GenericAttribute_var aTmpAttribute;
3248 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3249 anAttr = aTmpAttribute;
3251 } else anIter->Next();
3253 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3259 GeomGUI->myActiveStudy->updateObjBrowser( true );
3260 QApplication::restoreOverrideCursor();
3262 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3263 QApplication::setOverrideCursor( Qt::waitCursor );
3265 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3266 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3267 for(;It.More();It.Next()) {
3268 Handle(SALOME_InteractiveObject) IObject = It.Value();
3270 SALOMEDS::SObject_var fatherSF =
3271 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3272 SALOMEDS::GenericAttribute_var anAttr;
3273 SALOMEDS::AttributeName_var aName;
3274 SALOMEDS::AttributeIOR_var anIOR;
3276 if ( v3d->isInViewer( IObject, true ) ) {
3277 Standard_Boolean found;
3278 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3281 ic->AddOrRemoveCurrentObject(aSh, true);
3285 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3286 if ( !obj->_is_nil() ) {
3287 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3288 // this SObject may be GEOM module root SObject
3289 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3290 bool useSubItems = false;
3291 while (anIter->More() && !useSubItems) {
3292 SALOMEDS::SObject_var subobj = anIter->Value();
3293 SALOMEDS::GenericAttribute_var aTmpAttr;
3294 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3298 } else anIter->Next();
3300 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3301 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3302 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3303 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3304 if (obj->FindAttribute(anAttr, "AttributeName")) {
3305 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3306 // searchin for already displayed objects with the same shape
3307 AIS_ListOfInteractive aDisplayed;
3308 ic->DisplayedObjects(aDisplayed);
3309 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3310 Handle(AIS_Shape) anAISShape;
3311 for(;anIObjects.More();anIObjects.Next()) {
3312 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3313 if (!anAISShape.IsNull()) {
3314 if (anAISShape->Shape().IsSame(Shape)) break;
3315 anAISShape.Nullify();
3318 if (!anAISShape.IsNull()) {
3319 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape);
3323 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3326 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3327 aStudyBuilder->Addreference(newObj1, obj);
3328 // commit transaction
3332 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
3333 aSh->SetShadingColor( GeomGUI->myShadingColor );
3334 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
3337 IO->setEntry(obj->GetID());
3339 aSh->setName( aName->Value() );
3341 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true);
3344 // next item iteration
3347 anAttr=SALOMEDS::GenericAttribute::_nil();
3348 while (anIter->More() && anAttr->_is_nil()) {
3349 SALOMEDS::SObject_var subobject = anIter->Value();
3350 SALOMEDS::GenericAttribute_var aTmpAttribute;
3351 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3352 anAttr = aTmpAttribute;
3354 } else anIter->Next();
3356 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3362 GeomGUI->myActiveStudy->updateObjBrowser( true );
3363 QApplication::restoreOverrideCursor();
3370 GeomGUI->EmitSignalDeactivateDialog() ;
3371 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3372 GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ;
3378 GeomGUI->EmitSignalDeactivateDialog() ;
3379 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3380 GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ;
3384 case 3013: // CIRCLE
3386 GeomGUI->EmitSignalDeactivateDialog() ;
3387 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3388 GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ;
3392 case 3014: // ELLIPSE
3394 GeomGUI->EmitSignalDeactivateDialog() ;
3395 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3396 GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ;
3402 GeomGUI->EmitSignalDeactivateDialog() ;
3403 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3404 GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ;
3408 case 3016: // VECTOR
3410 GeomGUI->EmitSignalDeactivateDialog() ;
3411 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3412 GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ;
3418 GeomGUI->EmitSignalDeactivateDialog() ;
3419 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3420 GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ;
3424 case 3018: // WORKING PLANE
3426 GeomGUI->EmitSignalDeactivateDialog() ;
3427 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3428 GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ;
3432 case 312: // SKETCHER
3434 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
3437 GeomGUI->EmitSignalDeactivateDialog() ;
3439 ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
3441 GeomGUI->mySketcher = Sketch( v3d->getViewer3d() );
3442 GeomGUI->SetState(CURRENT_SKETCH);
3444 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3447 QMenuItem* item = Mb->findItem(10010,&pp);
3448 GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
3449 item = Mb->findItem(10011,&pp);
3450 GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
3451 item = Mb->findItem(10012,&pp);
3452 GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
3453 item = Mb->findItem(10013,&pp);
3454 GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
3455 item = Mb->findItem(10014,&pp);
3456 GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
3458 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3459 item = Mb->findItem(3133,&pp);
3460 pp->setItemChecked(3133,false);
3461 item = Mb->findItem(3134,&pp);
3462 pp->setItemChecked(3134,false);
3468 GeomGUI->EmitSignalDeactivateDialog() ;
3469 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3470 GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ;
3474 case 3022: // CYLINDER
3476 GeomGUI->EmitSignalDeactivateDialog() ;
3477 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3478 GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ;
3482 case 3023: // SPHERE
3484 GeomGUI->EmitSignalDeactivateDialog() ;
3485 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3486 GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ;
3492 GeomGUI->EmitSignalDeactivateDialog() ;
3493 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3494 GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ;
3500 GeomGUI->EmitSignalDeactivateDialog() ;
3501 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3502 GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ;
3511 case 3133: // sketcher
3513 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3515 QMenuItem* item = Mb->findItem(3133,&pp);
3516 pp->setItemChecked(3133,!pp->isItemChecked(3133));
3517 if (pp->isItemChecked(3133) == true)
3518 GeomGUI->mySketcher.SetTransitionStatus(TANGENT);
3520 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3522 pp->setItemChecked(3134,false);
3526 case 3134: // sketcher
3528 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3530 QMenuItem* item = Mb->findItem(3134,&pp);
3531 pp->setItemChecked(3134,!pp->isItemChecked(3134));
3532 if (pp->isItemChecked(3134) == true)
3533 GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR);
3535 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3537 pp->setItemChecked(3133,false);
3543 GeomGUI->EmitSignalDeactivateDialog() ;
3544 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3545 GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ;
3549 case 4012: // COMMON
3551 GeomGUI->EmitSignalDeactivateDialog() ;
3552 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3553 GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ;
3559 GeomGUI->EmitSignalDeactivateDialog() ;
3560 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3561 GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ;
3565 case 4014: // SECTION
3567 GeomGUI->EmitSignalDeactivateDialog() ;
3568 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3569 GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ;
3573 case 4021: // TRANSLATION
3575 GeomGUI->EmitSignalDeactivateDialog() ;
3576 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3577 GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ;
3581 case 4022: // ROTATION
3583 GeomGUI->EmitSignalDeactivateDialog() ;
3584 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3585 GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ;
3589 case 4030: // MULTI TRANSLATION
3591 GeomGUI->EmitSignalDeactivateDialog() ;
3592 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3593 GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ;
3597 case 4040: // MULTI ROTATION
3599 GeomGUI->EmitSignalDeactivateDialog() ;
3600 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3601 GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ;
3605 case 4023: // MIRROR
3607 GeomGUI->EmitSignalDeactivateDialog() ;
3608 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3609 GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ;
3615 GeomGUI->EmitSignalDeactivateDialog() ;
3616 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3617 GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ;
3621 case 4025: // PARTITION
3623 GeomGUI->EmitSignalDeactivateDialog() ;
3624 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3625 GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ;
3629 case 4026: // ARCHIMEDE
3631 GeomGUI->EmitSignalDeactivateDialog() ;
3632 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3633 GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ;
3637 case 4027: // FILLET
3639 GeomGUI->EmitSignalDeactivateDialog() ;
3640 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3641 GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ;
3645 case 4028: // CHAMFER
3647 GeomGUI->EmitSignalDeactivateDialog() ;
3648 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3649 GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ;
3655 GeomGUI->EmitSignalDeactivateDialog() ;
3656 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3657 GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ;
3663 GeomGUI->EmitSignalDeactivateDialog() ;
3664 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3665 GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ;
3669 case 4033: // FILLING
3671 GeomGUI->EmitSignalDeactivateDialog() ;
3672 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3673 GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ;
3679 GeomGUI->EmitSignalDeactivateDialog() ;
3680 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3681 GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ;
3685 case 5001: // CHECK GEOMETRY
3687 QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor();
3688 PyEditor->setText("from GEOM_usinggeom import *\n");
3689 PyEditor->setText(">>> ");
3690 PyEditor->handleReturn();
3694 case 6021: // SHADING - WIREFRAME
3696 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3697 VTKViewer_RenderWindowInteractor* myRenderInter=
3698 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3700 QApplication::setOverrideCursor(waitCursor);
3702 int themode = myRenderInter->GetDisplayMode();
3704 myRenderInter->SetDisplayMode(1);
3705 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3707 myRenderInter->SetDisplayMode(0);
3708 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3711 QApplication::restoreOverrideCursor();
3713 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3714 AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode();
3715 QApplication::setOverrideCursor( Qt::waitCursor );
3716 AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
3718 AIS_ListOfInteractive List;
3719 ic->DisplayedObjects(List);
3720 AIS_ListOfInteractive List1;
3721 ic->ObjectsInCollector(List1);
3724 AIS_ListIteratorOfListOfInteractive ite(List);
3725 while (ite.More()) {
3726 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3727 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3728 ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
3733 ic->SetDisplayMode( newmode, Standard_False);
3735 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3737 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3739 QApplication::restoreOverrideCursor();
3744 case 6022: // DISPLAY ALL
3746 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3748 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll();
3749 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
3750 GeomGUI->OnDisplayAll();
3754 case 6023: // DISPLAY ONLY
3755 case 8023: // DISPLAY ONLY - POPUP VIEWER
3757 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3759 GeomGUI->OnVTKDisplayOnly();
3761 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
3762 GeomGUI->OnDisplayOnly();
3766 case 6024: // ERASE ALL
3768 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3770 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
3772 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3773 ic->EraseAll(Standard_True, Standard_False);
3774 ic->Display(v3d->getTrihedron());
3777 //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3778 //NRI Sel->ClearInteractiveObjects();
3782 case 6025 : // ERASE ONLY
3783 case 8022 : // ERASE - POPUP VIEWER
3785 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3786 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3788 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3789 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3790 Handle(SALOME_InteractiveObject) anIObject;
3791 for(;It.More();It.Next()) {
3792 anIObject = It.Value();
3793 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3795 if(myRenderInter->isInViewer(anIObject)) {
3796 myRenderInter->Erase(anIObject);
3798 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3799 SALOMEDS::GenericAttribute_var anAttr;
3800 SALOMEDS::AttributeIOR_var anIOR;
3801 if ( !obj->_is_nil() ) {
3802 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3803 // this SObject may be GEOM module root SObject
3804 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3805 bool useSubItems = false;
3806 while (anIter->More() && !useSubItems) {
3807 SALOMEDS::SObject_var subobj = anIter->Value();
3808 SALOMEDS::GenericAttribute_var aTmpAttr;
3809 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3813 } else anIter->Next();
3816 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3817 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3818 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3819 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3820 if (obj->FindAttribute(anAttr, "AttributeName")) {
3821 // searchin for already displayed objects with the same shape
3822 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3823 vtkActorCollection* theAllActors = theRenderer->GetActors();
3824 theAllActors->InitTraversal();
3825 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3826 Handle(SALOME_InteractiveObject) anIObj;
3827 // don't create new study object if it already exists
3828 bool isDisplayed = false;
3829 while(!(actor==NULL)) {
3830 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3832 if (Gactor->hasIO()) {
3833 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3835 anIObj = Gactor->getIO();
3836 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
3840 actor=(vtkActor*)(theAllActors->GetNextActor());
3845 anAttr=SALOMEDS::GenericAttribute::_nil();
3846 while (anIter->More() && anAttr->_is_nil()) {
3847 SALOMEDS::SObject_var subobject = anIter->Value();
3848 SALOMEDS::GenericAttribute_var aTmpAttribute;
3849 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3850 anAttr = aTmpAttribute;
3852 } else anIter->Next();
3854 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3860 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3861 // for(;It.More();It.Next()) {
3862 // Handle(SALOME_InteractiveObject) IOS = It.Value();
3863 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
3865 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3867 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3868 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3869 Handle(SALOME_InteractiveObject) anIObject;
3870 for(;It.More();It.Next()) {
3871 anIObject = It.Value();
3872 if ( v3d->isInViewer( anIObject, true ) ) {
3873 Standard_Boolean found;
3874 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
3877 ic->AddOrRemoveCurrentObject(aSh, true);
3880 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3881 SALOMEDS::GenericAttribute_var anAttr;
3882 SALOMEDS::AttributeIOR_var anIOR;
3883 if ( !obj->_is_nil() ) {
3884 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3885 // this SObject may be GEOM module root SObject
3886 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3887 bool useSubItems = false;
3888 while (anIter->More() && !useSubItems) {
3889 SALOMEDS::SObject_var subobj = anIter->Value();
3890 SALOMEDS::GenericAttribute_var aTmpAttr;
3891 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3895 } else anIter->Next();
3898 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3899 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3900 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3901 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3902 if (obj->FindAttribute(anAttr, "AttributeName")) {
3903 // searchin for already displayed objects with the same shape
3904 AIS_ListOfInteractive aDisplayed;
3905 ic->DisplayedObjects(aDisplayed);
3906 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3907 Handle(AIS_Shape) anAISShape;
3908 for(;anIObjects.More();anIObjects.Next()) {
3909 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3910 if (!anAISShape.IsNull()) {
3911 if (anAISShape->Shape().IsSame(Shape)) break;
3912 anAISShape.Nullify();
3915 if (!anAISShape.IsNull()) {
3916 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
3921 anAttr=SALOMEDS::GenericAttribute::_nil();
3922 while (anIter->More() && anAttr->_is_nil()) {
3923 SALOMEDS::SObject_var subobject = anIter->Value();
3924 SALOMEDS::GenericAttribute_var aTmpAttribute;
3925 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3926 anAttr = aTmpAttribute;
3928 } else anIter->Next();
3930 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3937 Sel->ClearIObjects();
3942 case 6060: // BOUNDING BOX
3944 GeomGUI->EmitSignalDeactivateDialog() ;
3945 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3946 GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ;
3950 case 6061: // MIN DISTANCE
3952 GeomGUI->EmitSignalDeactivateDialog() ;
3953 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3954 GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ;
3958 case 8021: // WIREFRAME-SHADING
3960 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3962 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3964 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3965 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3967 QApplication::setOverrideCursor( Qt::waitCursor );
3968 for(;It.More();It.Next()) {
3969 Handle(SALOME_InteractiveObject) IOS = It.Value();
3970 myRenderInter->SwitchRepresentation(IOS, false);
3972 myRenderInter->Render();
3973 QApplication::restoreOverrideCursor();
3975 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3976 QApplication::setOverrideCursor( Qt::waitCursor );
3977 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3978 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3979 for(;It.More();It.Next()) {
3980 Handle(SALOME_InteractiveObject) IObject = It.Value();
3981 Standard_Boolean found;
3982 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3983 if (!Shape.IsNull()) {
3984 AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode();
3986 mode = ( AIS_DisplayMode )ic->DisplayMode();
3988 QApplication::setOverrideCursor( Qt::waitCursor );
3989 ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
3991 QApplication::restoreOverrideCursor();
3993 ic->UpdateCurrentViewer();
3995 QApplication::restoreOverrideCursor();
3999 case 8031: // COLOR - POPUP VIEWER
4001 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
4003 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4005 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4006 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4008 Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject();
4009 if(!FirstIOS.IsNull()) {
4011 QColor initcolor = myRenderInter->GetColor(FirstIOS);
4013 QColor c = QColorDialog::getColor( initcolor,
4014 QAD_Application::getDesktop() );
4016 if ( c.isValid() ) {
4017 QApplication::setOverrideCursor( Qt::waitCursor );
4018 for(;It.More();It.Next()) {
4019 Handle(SALOME_InteractiveObject) IOS = It.Value();
4020 myRenderInter->SetColor(IOS,c);
4023 QApplication::restoreOverrideCursor();
4026 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
4027 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4028 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
4029 Standard_Boolean found;
4030 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true);
4032 Quantity_Color CSFColor;
4033 Shape->Color( CSFColor );
4035 QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0,
4036 CSFColor.Green()* 255.0,
4037 CSFColor.Blue() * 255.0 ),
4038 QAD_Application::getDesktop() );
4040 if ( c.isValid() ) {
4041 CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
4042 QApplication::setOverrideCursor( Qt::waitCursor );
4044 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4045 for(;It.More();It.Next()) {
4046 Handle(SALOME_InteractiveObject) IObject = It.Value();
4047 Standard_Boolean found;
4048 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
4050 Shape->SetColor ( CSFColor );
4051 Shape->SetShadingColor ( CSFColor );
4057 QApplication::restoreOverrideCursor();
4061 case 8032: // TRANSPARENCY - POPUP VIEWER
4063 GeomGUI->EmitSignalDeactivateDialog() ;
4064 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4065 GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ;
4069 case 8033: // ISOS - POPUP VIEWER
4071 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4075 if ( ic->MoreCurrent() ) {
4076 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
4077 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
4078 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
4080 if ( !IsoU.isEmpty() )
4081 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
4084 if ( !IsoV.isEmpty() )
4085 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
4089 GeometryGUI_NbIsosDlg * NbIsosDlg =
4090 new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE );
4092 NbIsosDlg->SpinBoxU->setValue(IsoU.toInt());
4093 NbIsosDlg->SpinBoxV->setValue(IsoV.toInt());
4095 if ( NbIsosDlg->exec() ) {
4096 QApplication::setOverrideCursor( Qt::waitCursor );
4097 for ( ; ic->MoreCurrent (); ic->NextCurrent () ) {
4098 Handle (AIS_Drawer) CurDrawer;
4100 CurDrawer = ic->Current()->Attributes();
4101 CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() );
4102 CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() );
4104 ic->SetLocalAttributes(CurObject, CurDrawer);
4105 ic->Redisplay(CurObject);
4110 QApplication::restoreOverrideCursor();
4114 case 9022 : // ERASE - OBJBROSER POPUP
4116 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4117 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
4119 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4120 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4121 Handle(SALOME_InteractiveObject) anIObject;
4122 for(;It.More();It.Next()) {
4123 anIObject = It.Value();
4124 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4126 // Handle(SALOME_InteractiveObject) IObject;
4127 if(myRenderInter->isInViewer(anIObject)) {
4128 myRenderInter->Erase(anIObject);
4130 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4131 SALOMEDS::GenericAttribute_var anAttr;
4132 SALOMEDS::AttributeIOR_var anIOR;
4133 if ( !obj->_is_nil() ) {
4134 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4135 // this SObject may be GEOM module root SObject
4136 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4137 bool useSubItems = false;
4138 while (anIter->More() && !useSubItems) {
4139 SALOMEDS::SObject_var subobj = anIter->Value();
4140 SALOMEDS::GenericAttribute_var aTmpAttr;
4141 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4145 } else anIter->Next();
4148 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4149 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4150 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4151 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4152 if (obj->FindAttribute(anAttr, "AttributeName")) {
4153 // searchin for already displayed objects with the same shape
4154 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4155 vtkActorCollection* theAllActors = theRenderer->GetActors();
4156 theAllActors->InitTraversal();
4157 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
4158 Handle(SALOME_InteractiveObject) anIObj;
4159 // don't create new study object if it already exists
4160 bool isDisplayed = false;
4161 while(!(actor==NULL)) {
4162 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
4164 if (Gactor->hasIO()) {
4165 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
4167 anIObj = Gactor->getIO();
4168 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
4172 actor=(vtkActor*)(theAllActors->GetNextActor());
4177 anAttr=SALOMEDS::GenericAttribute::_nil();
4178 while (anIter->More() && anAttr->_is_nil()) {
4179 SALOMEDS::SObject_var subobject = anIter->Value();
4180 SALOMEDS::GenericAttribute_var aTmpAttribute;
4181 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4182 anAttr = aTmpAttribute;
4184 } else anIter->Next();
4186 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4191 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4192 // for(;It.More();It.Next()) {
4193 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4194 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4196 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4197 // for(;It.More();It.Next()) {
4198 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4199 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4202 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
4204 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4205 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4206 Handle(SALOME_InteractiveObject) anIObject;
4207 for(;It.More();It.Next()) {
4208 anIObject = It.Value();
4209 if ( v3d->isInViewer( anIObject, true ) ) {
4210 Standard_Boolean found;
4211 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
4214 ic->AddOrRemoveCurrentObject(aSh, true);
4217 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4218 SALOMEDS::GenericAttribute_var anAttr;
4219 SALOMEDS::AttributeIOR_var anIOR;
4220 if ( !obj->_is_nil() ) {
4221 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4222 // this SObject may be GEOM module root SObject
4223 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4224 bool useSubItems = false;
4225 while (anIter->More() && !useSubItems) {
4226 SALOMEDS::SObject_var subobj = anIter->Value();
4227 SALOMEDS::GenericAttribute_var aTmpAttr;
4228 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4232 } else anIter->Next();
4235 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4236 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4237 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4238 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4239 if (obj->FindAttribute(anAttr, "AttributeName")) {
4240 // searchin for already displayed objects with the same shape
4241 AIS_ListOfInteractive aDisplayed;
4242 ic->DisplayedObjects(aDisplayed);
4243 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
4244 Handle(AIS_Shape) anAISShape;
4245 for(;anIObjects.More();anIObjects.Next()) {
4246 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
4247 if (!anAISShape.IsNull()) {
4248 if (anAISShape->Shape().IsSame(Shape)) break;
4249 anAISShape.Nullify();
4252 if (!anAISShape.IsNull()) {
4253 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
4258 anAttr=SALOMEDS::GenericAttribute::_nil();
4259 while (anIter->More() && anAttr->_is_nil()) {
4260 SALOMEDS::SObject_var subobject = anIter->Value();
4261 SALOMEDS::GenericAttribute_var aTmpAttribute;
4262 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4263 anAttr = aTmpAttribute;
4265 } else anIter->Next();
4267 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4273 // QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC();
4274 // Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4275 // myContext->EraseSelected();
4278 Sel->ClearIObjects();
4282 case 9023 : // DISPLAY ONLY - OBJBROSER POPUP
4284 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
4285 GeomGUI->OnVTKDisplayOnly();
4286 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
4287 GeomGUI->OnDisplayOnly();
4291 case 9024 : // OPEN - OBJBROSER POPUP
4293 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4294 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4295 Handle(SALOME_InteractiveObject) anIObject;
4296 for(;It.More();It.Next()) {
4297 anIObject = It.Value();
4298 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4299 SALOMEDS::AttributePersistentRef_var aPersist;
4300 SALOMEDS::AttributeIOR_var anIOR;
4301 if ( !obj->_is_nil() ) {
4302 // this SObject may be GEOM module root SObject
4303 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4304 SALOMEDS::GenericAttribute_var anAttr;
4305 bool useSubItems = false;
4306 while (anIter->More() && !useSubItems) {
4307 SALOMEDS::SObject_var subobj = anIter->Value();
4308 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
4312 else anIter->Next();
4314 obj->FindAttribute(anAttr, "AttributePersistentRef");
4316 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4317 if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
4318 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
4320 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","GEOM");
4321 if (!CORBA::is_nil(comp)) {
4322 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
4325 SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder();
4326 aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver);
4329 MESSAGE("Component is null");
4334 obj = anIter->Value();
4335 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4342 case 10000 : // SKETCH Segment
4344 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4346 GeomGUI->OnSketchSegment();
4349 case 10001 : // SKETCH Arc
4351 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4353 GeomGUI->OnSketchArc();
4356 case 10002 : // SKETCH Set Angle
4358 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4360 GeomGUI->OnSketchSetAngle();
4363 case 10003 : // SKETCH Set X
4365 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4367 GeomGUI->OnSketchSetx();
4370 case 10004 : // SKETCH Set Y
4372 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4374 GeomGUI->OnSketchSety();
4377 case 10006 : // SKETCH Delete
4379 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4381 GeomGUI->OnSketchDelete();
4384 case 10007 : // SKETCH End
4386 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4388 GeomGUI->OnSketchEnd();
4391 case 10008 : // SKETCH Close
4393 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4395 GeomGUI->OnSketchClose();
4398 case 10010 : // SKETCH OptionsOnofflengthdimension
4400 GeomGUI->OnSketchOptionsOnofflengthdimension();
4403 case 10011 : // SKETCH OptionsOnoffangledimension
4405 GeomGUI->OnSketchOptionsOnoffangledimension();
4408 case 10012 : // SKETCH OptionsOnoffradiusdimension
4410 GeomGUI->OnSketchOptionsOnoffradiusdimension();
4413 case 10013 : // SKETCH OptionsOnoffxdimension
4415 GeomGUI->OnSketchOptionsOnoffxdimension();
4418 case 10014 : // SKETCH OptionsOnoffydimension
4420 GeomGUI->OnSketchOptionsOnoffydimension();
4426 parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) );
4434 //=======================================================================
4435 // function : ConvertClickToPoint()
4436 // purpose : Returns the point clicked in 3D view
4437 //=======================================================================
4438 gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x,
4440 Handle(V3d_View) aView )
4442 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
4443 aView->Eye(XEye, YEye, ZEye);
4445 aView->At(XAt, YAt, ZAt);
4446 gp_Pnt EyePoint(XEye, YEye, ZEye);
4447 gp_Pnt AtPoint(XAt, YAt, ZAt);
4449 gp_Vec EyeVector(EyePoint, AtPoint);
4450 gp_Dir EyeDir(EyeVector);
4452 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
4453 Standard_Real X, Y, Z;
4454 aView->Convert(x, y, X, Y, Z);
4455 gp_Pnt ConvertedPoint(X, Y, Z);
4457 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint);
4458 gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
4459 ConvertedPointOnPlane.Y(),
4467 //==================================================================================
4468 // function : 0nMousePress()
4469 // purpose : [static] manage mouse events
4470 //==================================================================================
4471 bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4473 MESSAGE ( "GeometryGUI::OnMousePress")
4474 GeometryGUI::GetOrCreateGeometryGUI(parent);
4476 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4479 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4480 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4481 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4483 /* Get the clicked or selected point */
4486 if ( GeomGUI->myState == CURRENT_SKETCH) {
4487 GeomGUI->mySketcher.ValidateEdge();
4488 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
4489 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
4491 QMenuItem* item = Mb->findItem(313,&pp);
4492 pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS
4494 } else if( GeomGUI->myState == POINT_METHOD ) {
4496 GeomGUI->EraseSimulationShape() ;
4497 GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ;
4499 if ( DialogPt->UseLocalContext() ) {
4501 if ( pe->state() == Qt::ShiftButton )
4502 v3d->getAISSelector()->shiftSelect(); /* Append selection */
4504 v3d->getAISSelector()->select(); /* New selection */
4506 if ( ic->MoreSelected() ) {
4507 thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) );
4510 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4513 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4515 if( DialogPt != 0 ) {
4516 DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */
4519 // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ;
4520 GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
4528 //=======================================================================
4529 // function : OnMouseMove()
4530 // purpose : [static] manage mouse events
4531 //=======================================================================
4532 bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4534 GeometryGUI::GetOrCreateGeometryGUI(parent);
4536 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4539 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4540 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4541 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4543 if ( GeomGUI->myState == CURRENT_SKETCH)
4544 GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
4550 //================================================================================
4551 // function : SetDisplayedObjectList()
4553 //================================================================================
4554 void GeometryGUI::SetDisplayedObjectList()
4556 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4559 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4560 ListDisplayedObject.Clear();
4562 Handle (AIS_InteractiveContext) aContext = v3d->getAISContext();
4563 aContext->DisplayedObjects( ListDisplayedObject );
4568 //=====================================================================================
4569 // function : OnDisplayAll()
4571 //=====================================================================================
4572 void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
4574 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4577 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4578 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4580 myContext->Display(v3d->getTrihedron());
4582 if ( !onlyPreviousDisplayedObject ) {
4583 AIS_ListOfInteractive List1;
4584 myContext->ObjectsInCollector(List1);
4585 AIS_ListIteratorOfListOfInteractive ite1(List1);
4586 while (ite1.More()) {
4587 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4588 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4589 if ( aSh->hasIO() ) {
4590 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4591 if ( v3d->isInViewer(GIO, true) ) {
4592 myContext->Display(aSh);
4599 AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject);
4600 while (ite.More()) {
4601 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4602 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4603 if ( aSh->hasIO() ) {
4604 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4605 if ( v3d->isInViewer(GIO,true) ) {
4606 myContext->Display(aSh);
4618 //=====================================================================================
4619 // function : OnVTKDisplayOnly()
4621 //=====================================================================================
4622 void GeometryGUI::OnVTKDisplayOnly()
4625 // Erase all not selected actors
4627 QApplication::setOverrideCursor( Qt::waitCursor );
4629 vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4630 vtkActorCollection* theActors = aren->GetActors();
4631 theActors->InitTraversal();
4632 vtkActor *ac = theActors->GetNextActor();
4633 while(!(ac==NULL)) {
4634 if ( ac->IsA("SALOME_Actor") ) {
4635 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
4636 if(!anActor->isHighlighted()) anActor->VisibilityOff();
4638 ac = theActors->GetNextActor();
4641 // Display selection
4642 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4643 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4644 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
4645 SALOMEDS::GenericAttribute_var anAttr;
4646 SALOMEDS::AttributeName_var aName;
4647 SALOMEDS::AttributeIOR_var anIOR;
4649 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4650 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4652 for(;It.More();It.Next()) {
4653 Handle(SALOME_InteractiveObject) IObject = It.Value();
4654 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4656 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4658 if(myRenderInter->isInViewer(IObject)) {
4659 myRenderInter->Display(IObject);
4663 if ( !obj->_is_nil() ) {
4664 if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
4666 // If selected object contains displayable subobjects, then do nothing
4667 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4668 SALOMEDS::GenericAttribute_var aTmpAttr;
4670 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4671 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4672 if (CORBA::is_nil(aShape)) continue;
4673 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4675 if (obj->FindAttribute(anAttr, "AttributeName")) {
4676 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4678 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
4681 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4682 aStudyBuilder->Addreference(newObj1, obj);
4683 // commit transaction
4686 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4687 int themode = myRenderInter->GetDisplayMode();
4688 vtkActorCollection* theActors =
4689 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
4690 theActors->InitTraversal();
4691 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
4692 while(!(anActor==NULL)) {
4693 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
4694 GActor->setIO( IObject );
4695 GActor->setName( IObject->getName() );
4697 theRenderer->AddActor(GActor);
4698 vtkRenderWindow *renWin
4699 = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
4701 anActor = (vtkActor*)theActors->GetNextActor();
4707 GeomGUI->myActiveStudy->updateObjBrowser( true );
4708 QApplication::restoreOverrideCursor();
4713 //=====================================================================================
4714 // function : OnDisplayOnly()
4716 //=====================================================================================
4717 void GeometryGUI::OnDisplayOnly()
4719 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4722 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4723 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4724 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4726 AIS_ListOfInteractive List;
4727 ic->DisplayedObjects(List);
4728 AIS_ListIteratorOfListOfInteractive ite(List);
4729 while (ite.More()) {
4730 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4731 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4732 if (!ic->IsSelected( aSh )) {
4733 ic->Erase( aSh, Standard_True, Standard_True );
4739 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4740 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4742 SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
4743 for(;It1.More();It1.Next()) {
4744 Handle(SALOME_InteractiveObject) IObject = It1.Value();
4747 SALOMEDS::SObject_var fatherSF =
4748 aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
4749 if ( v3d->isInViewer( IObject, true ) ) {
4750 AIS_ListOfInteractive List1;
4751 ic->ObjectsInCollector(List1);
4752 AIS_ListIteratorOfListOfInteractive ite1(List1);
4753 while (ite1.More()) {
4754 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4755 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4756 if ( aSh->hasIO() ) {
4757 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4758 if ( IObject->isSame( GIO ) ) {
4760 ic->AddOrRemoveCurrentObject(aSh, true);
4768 if ( IObject->hasEntry() ) {
4769 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4770 SALOMEDS::GenericAttribute_var anAttr;
4771 SALOMEDS::AttributeName_var aName;
4772 SALOMEDS::AttributeIOR_var anIOR;
4773 if ( !obj->_is_nil() ) {
4774 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
4775 // this SObject may be GEOM module root SObject
4777 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4778 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
4779 if (CORBA::is_nil(aShape)) continue;
4780 TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape);
4782 if (obj->FindAttribute(anAttr, "AttributeName")) {
4783 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4785 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4788 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4789 aStudyBuilder->Addreference(newObj1, obj);
4790 // commit transaction
4794 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
4795 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
4797 IO->setEntry(obj->GetID());
4799 aSh->setName( aName->Value() );
4801 ic->AddOrRemoveCurrentObject(aSh, true);
4810 //===============================================================================
4811 // function : OnEditDelete()
4813 //===============================================================================
4814 void GeometryGUI::OnEditDelete()
4816 if ( QAD_MessageBox::warn2
4817 ( QAD_Application::getDesktop(),
4818 tr ("GEOM_WRN_WARNING"),
4819 tr ("GEOM_REALLY_DELETE"),
4820 tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 )
4823 int nbSf = myActiveStudy->getStudyFramesCount();
4825 Standard_Boolean found;
4826 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4827 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4828 SALOMEDS::GenericAttribute_var anAttr;
4829 SALOMEDS::AttributeIOR_var anIOR;
4831 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4832 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4833 for(;It.More();It.Next()) {
4834 Handle(SALOME_InteractiveObject) IObject = It.Value();
4835 if ( IObject->hasEntry() ) {
4836 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
4837 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
4839 /* Erase child graphical objects */
4840 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
4841 for (; it->More();it->Next()) {
4842 SALOMEDS::SObject_var CSO= it->Value();
4843 if (CSO->FindAttribute(anAttr, "AttributeIOR") ) {
4844 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4845 /* Delete child(s) shape in Client : */
4846 const TCollection_AsciiString ASCior(anIOR->Value()) ;
4847 ShapeReader.RemoveShapeFromBuffer( ASCior ) ;
4849 for ( int i = 0; i < nbSf; i++ ) {
4850 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4851 if ( sf->getTypeView() == VIEW_OCC ) {
4852 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4853 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4854 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found );
4856 myContext->Erase( Result, true, false );
4857 } else if ( sf->getTypeView() == VIEW_VTK ) {
4858 //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
4859 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4860 GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found );
4862 //Renderer->RemoveActor(ac);
4864 myRenderInter->Remove( ac->getIO() );
4871 /* Erase main graphical object */
4872 for ( int i = 0; i < nbSf; i++ ) {
4873 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4874 if ( sf->getTypeView() == VIEW_OCC ) {
4875 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4876 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4877 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found );
4879 myContext->Erase( Result, true, false );
4880 } else if ( sf->getTypeView() == VIEW_VTK ) {
4881 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4882 myRenderInter->Remove( IObject );
4886 /* Delete main shape in Client : */
4887 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
4888 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4889 const TCollection_AsciiString ASCIor(anIOR->Value()) ;
4890 ShapeReader.RemoveShapeFromBuffer( ASCIor ) ;
4893 /* Erase objects in Study */
4894 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4895 if ( !obj->_is_nil() ) {
4896 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4898 aStudyBuilder->RemoveObject(obj);
4902 } /* IObject->hasEntry() */
4905 /* Clear any previous selection */
4906 Sel->ClearIObjects() ;
4907 myActiveStudy->updateObjBrowser();
4911 //==============================================================================
4912 // function : OnEditCopy()
4914 //==============================================================================
4915 void GeometryGUI::OnEditCopy()
4917 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4918 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
4920 const SALOME_ListIO& List = Sel->StoredIObjects();
4922 GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR);
4924 Sel->ClearIObjects();
4926 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
4927 GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]);
4929 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ;
4930 result->NameType( aShapeInit->NameType() );
4931 this->Display(result);
4933 catch (const SALOME::SALOME_Exception& S_ex) {
4934 QtCatchCorbaException(S_ex);
4938 myDesktop->putInfo(tr("GEOM_PRP_READY"));
4943 //=====================================================================================
4944 // function : OnKeyPress()
4945 // purpose : [static]
4946 //=====================================================================================
4947 bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4949 GeometryGUI::GetOrCreateGeometryGUI(parent);
4951 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4959 //=====================================================================================
4960 // function : DisplaySimulationShape()
4961 // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
4962 //=====================================================================================
4963 void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S)
4968 //NRI DEBUG : 14/02/2002
4969 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4972 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4973 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4976 /* erase any previous */
4977 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4978 ic->ClearPrs( this->mySimulationShape );
4979 this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ;
4980 this->mySimulationShape->Set( S ) ;
4981 this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ;
4982 ic->Deactivate( this->mySimulationShape );
4983 ic->Display( this->mySimulationShape, Standard_False );
4984 ic->UpdateCurrentViewer();
4986 catch(Standard_Failure) {
4987 MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ;
4989 this->mySimulationShape->UnsetColor() ;
4995 //==================================================================================
4996 // function : EraseSimulationShape()
4997 // purpose : Clears the display of 'mySimulationShape' a pure graphical shape
4998 //==================================================================================
4999 void GeometryGUI::EraseSimulationShape()
5001 int count = myActiveStudy->getStudyFramesCount();
5002 for ( int i = 0; i < count; i++ ) {
5003 if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
5004 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
5005 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5006 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
5007 ic->ClearPrs( this->mySimulationShape );
5008 ic->UpdateCurrentViewer();
5010 } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK
5013 // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " )
5018 //=====================================================================================
5019 // function : Import
5020 // purpose : BRep, Iges, Step
5021 //=====================================================================================
5022 bool GeometryGUI::Import( )
5024 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5025 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5027 GEOM::GEOM_Shape_var aShape;
5029 QStringList filtersList ;
5031 switch ( GeomGUI->myState )
5033 case 111 : // Import BREP
5035 filtersList.append( tr("GEOM_MEN_IMPORT_BREP") );
5036 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
5038 file = QAD_FileDlg::getFileName(myDesktop,
5041 tr("GEOM_MEN_IMPORT"),
5043 if ( !file.isEmpty() ) {
5044 QApplication::setOverrideCursor( Qt::waitCursor );
5046 aShape = myComponentGeom->ImportBREP( file.latin1() );
5048 catch (const SALOME::SALOME_Exception& S_ex) {
5049 QtCatchCorbaException(S_ex);
5054 case 112 : // Import IGES
5056 filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ;
5057 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
5059 file = QAD_FileDlg::getFileName(myDesktop,
5062 tr("GEOM_MEN_IMPORT"),
5064 if ( !file.isEmpty() ) {
5065 QApplication::setOverrideCursor( Qt::waitCursor );
5067 aShape = myComponentGeom->ImportIGES( file.latin1() );
5069 catch (const SALOME::SALOME_Exception& S_ex) {
5070 QtCatchCorbaException(S_ex);
5075 case 113 : // Import STEP
5077 filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ;
5078 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
5080 file = QAD_FileDlg::getFileName(myDesktop,
5083 tr("GEOM_MEN_IMPORT"),
5085 if ( !file.isEmpty() ) {
5086 QApplication::setOverrideCursor( Qt::waitCursor );
5088 aShape = myComponentGeom->ImportSTEP( file.latin1() );
5090 catch (const SALOME::SALOME_Exception& S_ex) {
5091 QtCatchCorbaException(S_ex);
5098 if ( !file.isEmpty() ) {
5099 myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) );
5101 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5102 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry());
5103 SALOMEDS::GenericAttribute_var anAttr;
5104 SALOMEDS::AttributeName_var aName;
5105 SALOMEDS::AttributePixMap_var aPixmap;
5106 int aLocked = false;
5107 if (father->_is_nil()) {
5108 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5110 aLocked = aStudy->GetProperties()->IsLocked();
5111 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5112 father = aStudyBuilder->NewComponent("GEOM");
5113 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5114 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5115 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5116 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5117 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5118 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5119 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5120 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5123 // if (aLocked) return false;
5124 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5125 father->ComponentIOR( Fatherior );
5127 QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++);
5129 if ( Display ( aShape, strdup(nameShape.latin1())) ) {
5130 myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) );
5131 myDesktop->putInfo( tr("GEOM_PRP_READY"));
5134 QApplication::restoreOverrideCursor();
5139 //=====================================================================================
5140 // function : Export
5141 // purpose : BRep, Iges, Step
5142 //=====================================================================================
5143 bool GeometryGUI::Export( )
5145 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5146 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5148 GEOM::GEOM_Shape_var aShape;
5150 static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"),
5151 tr("GEOM_MEN_IMPORT_IGES"),
5152 tr("GEOM_MEN_IMPORT_STEP") };
5154 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
5155 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5157 switch ( GeomGUI->myState )
5161 for(;It.More();It.Next()) {
5162 QApplication::restoreOverrideCursor();
5163 Handle(SALOME_InteractiveObject) IObject = It.Value();
5164 Standard_Boolean found;
5165 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5166 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5168 QString file = QAD_FileDlg::getFileName(myDesktop,
5169 QString( IObject->getName() ) + ".brep",
5170 tr("GEOM_MEN_IMPORT_BREP"),
5171 tr("GEOM_MEN_EXPORT"),
5173 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5174 QApplication::setOverrideCursor( Qt::waitCursor );
5175 // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) );
5177 GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape);
5179 catch (const SALOME::SALOME_Exception& S_ex) {
5180 QtCatchCorbaException(S_ex);
5189 for(;It.More();It.Next()) {
5190 QApplication::restoreOverrideCursor();
5191 Handle(SALOME_InteractiveObject) IObject = It.Value();
5192 Standard_Boolean found;
5193 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5194 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5196 QString file = QAD_FileDlg::getFileName(myDesktop,
5197 QString( IObject->getName() ) + ".igs",
5198 tr("GEOM_MEN_IMPORT_IGES"),
5199 tr("GEOM_MEN_EXPORT"),
5201 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5202 QApplication::setOverrideCursor( Qt::waitCursor );
5204 GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape);
5206 catch (const SALOME::SALOME_Exception& S_ex) {
5207 QtCatchCorbaException(S_ex);
5209 // //VRV: OCC 4.0 migration
5210 // IGESControl_Controller::Init();
5211 // IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
5212 // Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
5213 // //VRV: OCC 4.0 migration
5215 // ICW.AddShape (Shape->Shape());
5216 // ICW.ComputeModel();
5217 // Standard_Boolean result = ICW.Write( strdup(file.latin1()) );
5226 // bool test = false ;
5227 // IFSelect_ReturnStatus status ;
5228 // //VRV: OCC 4.0 migration
5229 // STEPControl_Writer aWriter;
5230 // //VRV: OCC 4.0 migration
5233 for( ; It.More(); It.Next() ) {
5234 // GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5235 QApplication::restoreOverrideCursor();
5236 Handle(SALOME_InteractiveObject) IObject = It.Value();
5237 Standard_Boolean found;
5238 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5239 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5241 file = QAD_FileDlg::getFileName(myDesktop,
5242 QString( IObject->getName() ) + ".stp",
5243 tr("GEOM_MEN_IMPORT_STEP"),
5244 tr("GEOM_MEN_EXPORT"),
5246 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5248 QApplication::setOverrideCursor( Qt::waitCursor ) ;
5250 GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape);
5252 catch (const SALOME::SALOME_Exception& S_ex) {
5253 QtCatchCorbaException(S_ex);
5255 // //VRV: OCC 4.0 migration
5256 // status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ;
5257 // //VRV: OCC 4.0 migration
5259 // if ( status != IFSelect_RetDone ) {
5260 // QApplication::restoreOverrideCursor() ;
5267 // status = aWriter.Write( strdup(file.latin1()) ) ;
5268 // QApplication::restoreOverrideCursor() ;
5275 QApplication::restoreOverrideCursor() ;
5279 //=====================================================================================
5280 // function : Display()
5281 // purpose : Displays a CORBA shape
5282 //=====================================================================================
5283 bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
5284 Standard_CString name)
5286 // MESSAGE ( "GeometryGUI::Display init ")
5287 Handle(GEOM_InteractiveObject) IO;
5288 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5289 Sel->ClearIObjects();
5291 if( aShape->_is_nil() ) {
5292 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
5293 tr ("GEOM_WRN_WARNING"),
5294 tr ("GEOM_PRP_ABORT"),
5295 tr ("GEOM_BUT_OK") );
5299 TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape);
5301 if ( shape.IsNull() )
5304 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5305 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5306 SALOMEDS::GenericAttribute_var anAttr;
5307 SALOMEDS::AttributeName_var aName;
5308 SALOMEDS::AttributePixMap_var aPixmap;
5310 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5311 int aLocked = false;
5312 if (father->_is_nil()) {
5313 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5315 aLocked = aStudy->GetProperties()->IsLocked();
5316 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5317 father = aStudyBuilder->NewComponent("GEOM");
5318 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5319 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5320 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5321 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5322 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5323 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5324 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5325 myActiveStudy->updateObjBrowser();
5326 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5329 // if (aLocked) return false;
5331 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5332 father->ComponentIOR( Fatherior );
5334 TCollection_AsciiString nameG("");
5335 Standard_CString Type;
5336 if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) {
5337 if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) {
5338 Standard_CString type;
5339 GetShapeTypeString(shape,type);
5340 aShape->NameType( type );
5341 nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") +
5342 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5344 nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") +
5345 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5347 nameG = TCollection_AsciiString(name);
5350 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5351 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5353 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5354 int themode = myRenderInter->GetDisplayMode();
5356 vtkActorCollection* theActors =
5357 GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True);
5358 theActors->InitTraversal();
5359 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
5361 IO = new GEOM_InteractiveObject(aShape->Name(),
5364 while(!(anActor==NULL)) {
5365 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
5366 GActor->setIO( IO );
5367 GActor->setName( nameG.ToCString() );
5369 theRenderer->AddActor(GActor);
5370 anActor = (vtkActor*)theActors->GetNextActor();
5374 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5375 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5376 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5377 Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() );
5378 theResult->SetShadingColor( myShadingColor );
5379 IO = new GEOM_InteractiveObject(aShape->Name(),
5382 theResult->setIO( IO );
5383 theResult->setName( nameG.ToCString() );
5385 /* Precaution : close any local context to permit the display */
5386 if ( ic->HasOpenedContext() ) {
5387 ic->CloseAllContexts();
5391 // theResult->SetInfiniteState() ;
5393 ic->Display(theResult);
5396 Sel->AddIObject( IO, false );
5397 myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
5398 if ( Settings_AddInStudy )
5399 GeomGUI->AddInStudy( false, IO );
5405 //=====================================================================================
5406 // function : AddInStudy()
5407 // purpose : anIOShape or a selected shape
5408 //=====================================================================================
5409 bool GeometryGUI::AddInStudy( bool selection,
5410 const Handle(SALOME_InteractiveObject)& anIO)
5412 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5413 if ( !( !Settings_AddInStudy || selection ) ) {
5414 Sel->ClearIObjects();
5417 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5418 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5419 SALOMEDS::GenericAttribute_var anAttr;
5420 SALOMEDS::AttributeName_var aName;
5421 SALOMEDS::AttributePixMap_var aPixmap;
5422 SALOMEDS::AttributeIOR_var anIOR;
5423 SALOMEDS::AttributeSelectable_var aSelAttr;
5425 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5426 int aLocked = false;
5427 if (father->_is_nil()) {
5428 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5430 aLocked = aStudy->GetProperties()->IsLocked();
5431 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5432 father = aStudyBuilder->NewComponent("GEOM");
5433 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5434 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5435 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5436 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5437 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5438 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5439 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5440 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5443 // if (aLocked) return false;
5445 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5446 father->ComponentIOR( Fatherior );
5448 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
5450 Handle(GEOM_AISShape) GAISShape;
5452 Handle(GEOM_InteractiveObject) GIO;
5456 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5457 vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5459 vtkActorCollection* theActors = Renderer->GetActors();
5460 theActors->InitTraversal();
5461 vtkActor *ac = theActors->GetNextActor();
5462 while(!(ac==NULL)) {
5463 if ( ac->IsA("GEOM_Actor") ) {
5464 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
5465 if ( anActor->hasIO() ) {
5466 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
5467 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5468 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5469 if ( anIO->isSame( GIO ) ) {
5477 ac = theActors->GetNextActor();
5484 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5485 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5486 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5488 AIS_ListOfInteractive List;
5489 ic->DisplayedObjects(List);
5490 AIS_ListIteratorOfListOfInteractive ite(List);
5491 while (ite.More()) {
5492 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
5493 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
5494 if ( aSh->hasIO() ) {
5495 Handle(SALOME_InteractiveObject) IO = aSh->getIO();
5496 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5497 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5498 if ( anIO->isSame( GIO ) ) {
5513 if ( !Settings_AddInStudy || selection ) {
5514 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() );
5515 if ( !Name.isEmpty() ) {
5517 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5518 GActor->setName( strdup(Name.latin1()) );
5521 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5522 GAISShape->setName( strdup(Name.latin1()) );
5530 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5533 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father);
5535 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() );
5537 /* For the shape inserted into the study we set its field 'studyshapeid' */
5538 /* so the shape will contain its corresponding entry in the study Ocaf doc. */
5539 aShape->StudyShapeId(newObj->GetID()) ;
5541 GIO->setEntry(newObj->GetID());
5543 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
5544 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5545 anIOR->SetValue(aShape->Name());
5547 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
5548 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5550 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
5551 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5552 if ( aShape->ShapeType() == GEOM::COMPOUND ) {
5553 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
5554 } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
5555 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
5556 } else if ( aShape->ShapeType() == GEOM::SOLID ) {
5557 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
5558 } else if ( aShape->ShapeType() == GEOM::SHELL ) {
5559 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
5560 } else if ( aShape->ShapeType() == GEOM::FACE ) {
5561 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
5562 } else if ( aShape->ShapeType() == GEOM::WIRE ) {
5563 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
5564 } else if ( aShape->ShapeType() == GEOM::EDGE ) {
5565 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
5566 } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
5567 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
5571 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5572 GActor->setIO( GIO );
5573 aName->SetValue(GActor->getName());
5576 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5577 GAISShape->setIO( GIO );
5578 aName->SetValue(GAISShape->getName());
5581 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
5582 aStudyBuilder->Addreference(newObj1,newObj);
5584 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
5585 listIOR = myComponentGeom->GetReferencedObjects(aShape);
5587 if (listIOR->length()>0) {
5588 SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj);
5589 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName");
5590 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5591 aName->SetValue(tr("GEOM_ARGUMENTS"));
5592 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable");
5593 aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
5594 aSelAttr->SetSelectable(false);
5596 bool ObjectReferenced = false;
5597 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
5598 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]);
5600 if ( !theObj->_is_nil() ) {
5601 SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments);
5602 aStudyBuilder->Addreference(RefObject, theObj);
5603 ObjectReferenced = true;
5607 if ( !ObjectReferenced )
5608 aStudyBuilder->RemoveObject(Arguments);
5614 if ( !Settings_AddInStudy || selection ) {
5615 myActiveStudy->updateObjBrowser();
5617 myActiveStudy->updateObjBrowser(false);
5618 Sel->AddIObject( GIO );
5621 // MESSAGE ( " highlihght done" )
5627 //=====================================================================================
5628 // function : GetShapeFromIOR()
5629 // purpose : exist also as static method !
5630 //=====================================================================================
5631 TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR )
5633 TopoDS_Shape result;
5634 if( IOR.stripWhiteSpace().isEmpty() )
5636 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
5637 CORBA::ORB_var& _orb = init.orb() ;
5638 CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) );
5639 if ( CORBA::is_nil( obj ) )
5641 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR );
5642 if (!aShape->_is_nil()) {
5643 result = ShapeReader.GetShape( myComponentGeom, aShape );
5649 //=====================================================================================
5650 // function : SetSettings()
5651 // purpose : [static]
5652 //=====================================================================================
5653 bool GeometryGUI::SetSettings( QAD_Desktop* parent )
5655 /* Create or retrieve an object GeomGUI */
5656 GeometryGUI::GetOrCreateGeometryGUI(parent);
5658 //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING
5659 //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS
5660 //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY
5661 parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS
5662 parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN
5665 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
5666 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
5667 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
5668 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
5669 GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255.,
5672 /* Wireframe or Shading */
5673 int DisplayMode = 0;
5674 if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5675 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5676 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
5677 DisplayMode = ic->DisplayMode();
5678 } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5679 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5680 DisplayMode = myRenderInter->GetDisplayMode();
5683 if ( DisplayMode == 1 )
5684 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
5686 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
5689 // QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy");
5690 // if ( !Copy.isEmpty() ) {
5691 // Settings_Copy = Copy.toInt();
5693 // parent->menuBar()->findItem(701,&pp);
5694 // pp->setItemChecked(701, Settings_Copy);
5697 if ( parent->menuBar()->findItem(701,&pp) )
5698 pp->removeItem(701);
5701 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
5702 if ( !AddInStudy.isEmpty() )
5703 Settings_AddInStudy = AddInStudy.toInt();
5705 Settings_AddInStudy = 1;
5706 parent->menuBar()->findItem(702,&pp);
5707 pp->setItemChecked(702, Settings_AddInStudy);
5710 QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
5712 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" );
5715 QAD_Study* ActiveStudy = parent->getActiveStudy();
5716 int count = ActiveStudy->getStudyFramesCount();
5718 bool ViewOCC = false;
5719 for ( int i = 0; i < count; i++ ) {
5720 if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
5721 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
5722 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5724 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
5725 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
5726 if ( !IsoU.isEmpty() )
5727 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
5728 if ( !IsoV.isEmpty() )
5729 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
5735 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
5737 Mb->setItemEnabled( 312, ViewOCC); //Sketch
5738 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
5739 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
5741 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
5742 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
5748 //=====================================================================================
5749 // function : DefinePopup()
5750 // purpose : [static]
5751 //=====================================================================================
5752 void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
5754 /* Create or retrieve an object GeomGUI */
5755 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
5756 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5759 if ( Sel->IObjectCount() == 1 )
5761 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
5764 SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
5765 if (!sobj->_is_nil())
5767 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
5768 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
5770 // component is selected
5771 theObject = "Component";
5777 if ( ( theParent.compare("Viewer")==0 ) )
5779 if ( GeomGUI->myState == CURRENT_SKETCH )
5780 theContext = "Sketch";
5783 if ( Sel->IObjectCount() > 0 )
5786 theContext = "NothingSelected";
5794 //=====================================================================================
5795 // function : CustomPopup()
5796 // purpose : [static]
5797 //=====================================================================================
5798 bool GeometryGUI::CustomPopup( QAD_Desktop* parent,
5800 const QString& theContext,
5801 const QString& theParent,
5802 const QString& theObject )
5804 /* Create or retrieve an object GeomGUI */
5805 GeometryGUI::GetOrCreateGeometryGUI(parent);
5807 /* Deactivate any non modal dialog box to get the neutral point */
5808 GeomGUI->EmitSignalDeactivateDialog() ;
5810 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5811 int nbSel = Sel->IObjectCount();
5813 if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) )
5817 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
5819 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->
5820 getRightFrame()->getViewFrame())->getViewer();
5821 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5822 if ( theParent.compare("Viewer")==0 )
5824 if ( theContext.compare("Sketch")==0 )
5826 SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus();
5827 popup->setCheckable(TRUE);
5830 popup->setItemChecked(10000,true);
5831 popup->setItemChecked(10001,false);
5833 else if (myCS==ARC_CHORD)
5835 popup->setItemChecked(10000,false);
5836 popup->setItemChecked(10001,true);
5842 if (theObject.compare("Component") == 0)
5844 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5849 QFont f = QApplication::font();
5853 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5854 popup->removeItem(QAD_TopLabel_Popup_ID);
5855 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5856 if ( IObject->hasEntry() )
5857 popup->setItemEnabled( 801, false );
5859 popup->setItemEnabled( 801, true );
5861 if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)))
5863 Standard_Boolean found;
5864 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
5868 if ( Result->DisplayMode() == 1 )
5869 popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") );
5871 popup->changeItem(8021, tr("GEOM_MEN_SHADING") );
5875 if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) )
5876 popup->removeItem(QAD_Erase_Popup_ID);
5878 popup->removeItem(QAD_Display_Popup_ID);
5883 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5884 popup->removeItem(QAD_TopLabel_Popup_ID);
5885 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ),
5886 QAD_TopLabel_Popup_ID, 0 );
5887 popup->setItemEnabled( 801, false );
5893 if ( theParent.compare("ObjectBrowser")==0 )
5895 popup->removeItem(QAD_TopLabel_Popup_ID);
5896 int id = popup->idAt(0); // separator
5897 if (id < 0) popup->removeItem(id);
5899 // checking for GEOM label in the selected list
5900 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5901 Handle(SALOME_InteractiveObject) anIObject;
5903 bool useSubItems = false;
5904 bool needOpen = false;
5905 bool needDisplay = false;
5906 bool needErase = false;
5907 SALOMEDS::GenericAttribute_var aTmpAttr;
5908 for(;It.More();It.Next())
5910 anIObject = It.Value();
5911 if (!anIObject->hasEntry())
5914 if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject))
5918 SALOMEDS::SObject_var obj =
5919 GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
5920 if (!obj->_is_nil())
5922 GEOM::GEOM_Shape_var aShape;
5923 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) {
5924 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5925 if (str && strlen(str))
5926 aShape = GeomGUI->myComponentGeom-> GetIORFromString(str);
5929 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5931 if (aShape->_is_nil())
5933 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->
5934 getStudyDocument()->NewChildIterator(obj);
5935 while (anIter->More())
5937 SALOMEDS::SObject_var subobj = anIter->Value();
5938 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
5945 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5955 // remove useless popup items
5956 if (nbSel != 1) popup->removeItem(901); // rename
5957 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5960 int index = popup->indexOf(9024);
5961 popup->removeItem(9024); // open
5962 popup->removeItemAt(index); // separator under Open
5964 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
5965 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
5966 if (!needDisplay && !needErase)
5968 int id = popup->idAt(popup->count()-1); // last item
5969 popup->removeItem(id); // separator
5974 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5975 popup->removeItem(QAD_Display_Popup_ID);
5976 popup->removeItem(QAD_Erase_Popup_ID);
5979 int id = popup->idAt(popup->count()-1); // last item
5980 popup->removeItem(id); // separator
5985 // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ")
5988 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
5990 // MESSAGE ( " CUSTOM POPUP VIEWER VTK ")
5991 if ( ( theParent.compare("Viewer")==0 ) )
5994 popup->setItemEnabled( 8033, false );
5995 if (theObject.compare("Component") == 0)
5997 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6001 //int id = popup->idAt(0);
6002 QFont f = QApplication::font();
6007 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
6008 popup->removeItem(QAD_TopLabel_Popup_ID);
6009 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
6010 if ( IObject->hasEntry() )
6012 popup->setItemEnabled( 801, false );
6013 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6014 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
6015 SALOMEDS::GenericAttribute_var anAttr;
6016 SALOMEDS::AttributeIOR_var anIOR;
6017 if ( !SO->_is_nil() )
6019 if (SO->FindAttribute(anAttr, "AttributeIOR") )
6021 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6022 Standard_Boolean found;
6023 GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true);
6026 if ( Result->getDisplayMode() == 1 )
6027 popup->changeItem(8021, "Wireframe" );
6029 popup->changeItem(8021, "Shading" );
6031 if ( !Result->GetVisibility() )
6032 popup->removeItem(QAD_Erase_Popup_ID);
6034 popup->removeItem(QAD_Display_Popup_ID);
6037 popup->removeItem(QAD_Erase_Popup_ID);
6042 popup->setItemEnabled( 801, true );
6046 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6047 popup->removeItem(QAD_TopLabel_Popup_ID);
6048 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 );
6049 popup->setItemEnabled( 801, false );
6054 if ( theParent.compare("ObjectBrowser")==0 )
6056 popup->removeItem(QAD_TopLabel_Popup_ID);
6057 int id = popup->idAt(0); // separator
6058 if (id < 0) popup->removeItem(id);
6060 // checking for GEOM label in the selected list
6061 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
6062 Handle(SALOME_InteractiveObject) anIObject;
6064 bool useSubItems = false;
6065 bool needOpen = false;
6066 bool needDisplay = false;
6067 bool needErase = false;
6068 SALOMEDS::GenericAttribute_var aTmpAttr;
6069 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->
6070 getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6071 for(;It.More();It.Next())
6073 anIObject = It.Value();
6074 if ( !anIObject->hasEntry() )
6077 if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject))
6082 SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument()
6083 ->FindObjectID( anIObject->getEntry() );
6084 if (!obj->_is_nil()) {
6085 GEOM::GEOM_Shape_var aShape;
6086 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){
6087 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
6088 if (str && strlen(str))
6089 aShape = GeomGUI->myComponentGeom->GetIORFromString(str);
6092 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
6094 if (aShape->_is_nil())
6096 SALOMEDS::ChildIterator_var anIter =
6097 GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6098 while (anIter->More())
6100 SALOMEDS::SObject_var subobj = anIter->Value();
6101 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
6108 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
6118 // remove useless popup items
6119 if (nbSel != 1) popup->removeItem(901); // rename
6120 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6123 int index = popup->indexOf(9024);
6124 popup->removeItem(9024); // open
6125 popup->removeItemAt(index); // separator under Open
6127 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
6128 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
6129 if (!needDisplay && !needErase)
6131 int id = popup->idAt(popup->count()-1); // last item
6132 popup->removeItem(id); // separator
6137 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6138 popup->removeItem(QAD_Display_Popup_ID);
6139 popup->removeItem(QAD_Erase_Popup_ID);
6142 int id = popup->idAt(popup->count()-1); // last item
6143 popup->removeItem(id); // separator
6147 // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.")
6150 { // other viewer types not supported.
6153 int id = popup->idAt(0);
6154 if (id <= QAD_TopLabel_Popup_ID && id != -1)
6155 popup->removeItemAt(0);
6159 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6160 popup->removeItem(QAD_Display_Popup_ID);
6161 popup->removeItem(QAD_Erase_Popup_ID);
6162 int id = popup->idAt(popup->count()-1); // last item
6163 if (id < 0 && id != -1) popup->removeItem(id); // separator
6169 void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
6171 /* Create or retrieve an object GeomGUI */
6172 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
6174 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6175 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
6177 OCCViewer_Viewer3d* v3d;
6178 Handle(AIS_InteractiveContext) ic;
6179 vtkRenderer* Renderer;
6181 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6182 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6183 ic = v3d->getAISContext();
6184 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6185 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6190 MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
6192 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6195 SALOMEDS::SObject_var fatherSF =
6196 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6198 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6200 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6202 SALOMEDS::GenericAttribute_var anAttr;
6203 SALOMEDS::AttributeName_var aName;
6204 SALOMEDS::AttributeIOR_var anIOR;
6206 if(myRenderInter->isInViewer(theIO)) {
6207 myRenderInter->Display(theIO, false);
6211 if ( !obj->_is_nil() ) {
6212 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6213 // this SObject may be GEOM module root SObject
6215 bool useSubItems = false;
6216 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6217 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6218 while (anIter->More() && !useSubItems) {
6219 SALOMEDS::SObject_var subobj = anIter->Value();
6220 SALOMEDS::GenericAttribute_var aTmpAttr;
6221 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6222 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6226 } else anIter->Next();
6227 } else anIter->Next();
6231 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6232 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6233 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6234 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6236 if (obj->FindAttribute(anAttr, "AttributeName")) {
6237 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6239 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6240 vtkActorCollection* theAllActors = theRenderer->GetActors();
6241 theAllActors->InitTraversal();
6242 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
6243 Handle(SALOME_InteractiveObject) anIObj;
6244 // don't create new study object if it already exists
6245 bool isDisplayed = false;
6246 while(!(actor==NULL)) {
6247 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
6249 if (Gactor->hasIO()) {
6250 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
6252 anIObj = Gactor->getIO();
6253 if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
6257 actor=(vtkActor*)(theAllActors->GetNextActor());
6261 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6264 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6265 aStudyBuilder->Addreference(newObj1, obj);
6266 // commit transaction
6269 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6270 int themode = myRenderInter->GetDisplayMode();
6272 vtkActorCollection* theActors =
6273 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
6274 theActors->InitTraversal();
6275 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
6276 while(!(anActor==NULL)) {
6277 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
6278 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
6279 IO->setEntry(obj->GetID());
6280 GActor->setIO( IO );
6281 GActor->setName( theIO->getName() );
6283 theRenderer->AddActor(GActor);
6284 // renWin->Render();
6285 anActor = (vtkActor*)theActors->GetNextActor();
6289 // next item iteration
6292 anAttr = SALOMEDS::GenericAttribute::_nil();
6293 while (anIter->More() && anAttr->_is_nil()) {
6294 SALOMEDS::SObject_var subobject = anIter->Value();
6295 SALOMEDS::GenericAttribute_var aTmpAttribute;
6296 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6297 anAttr = aTmpAttribute;
6299 } else anIter->Next();
6301 } else anAttr = SALOMEDS::GenericAttribute::_nil();
6306 // No viewer update should be done here!
6307 //myRenderInter->Render();
6308 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6309 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6310 SALOMEDS::SObject_var fatherSF =
6311 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6312 SALOMEDS::GenericAttribute_var anAttr;
6313 SALOMEDS::AttributeName_var aName;
6314 SALOMEDS::AttributeIOR_var anIOR;
6316 if ( v3d->isInViewer( theIO, true ) ) {
6317 Standard_Boolean found;
6318 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true );
6320 ic->Display(aSh, false);
6321 ic->AddOrRemoveCurrentObject(aSh, false);
6325 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6326 if ( !obj->_is_nil() ) {
6327 MESSAGE("BuildPresentation(): SObject not null")
6328 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6329 MESSAGE("BuildPresentation(): SObject has IOR")
6330 // this SObject may be GEOM module root SObject
6332 bool useSubItems = false;
6333 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6334 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6335 while (anIter->More() && !useSubItems) {
6336 SALOMEDS::SObject_var subobj = anIter->Value();
6337 SALOMEDS::GenericAttribute_var aTmpAttr;
6338 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6339 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6343 } else anIter->Next();
6344 } else anIter->Next();
6348 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6349 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6350 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6351 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6353 MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
6354 if (obj->FindAttribute(anAttr, "AttributeName")) {
6355 MESSAGE("BuildPresentation(): SObject has Name")
6356 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6357 // searchin for already displayed objects with the same shape
6358 AIS_ListOfInteractive aDisplayed;
6359 ic->DisplayedObjects(aDisplayed);
6360 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
6361 Handle(AIS_Shape) anAISShape;
6362 for(;anIObjects.More();anIObjects.Next()) {
6363 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
6364 if (!anAISShape.IsNull()) {
6365 if (anAISShape->Shape().IsSame(Shape)) break;
6366 anAISShape.Nullify();
6369 if (!anAISShape.IsNull()) {
6370 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false);
6374 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6376 if (fatherSF->_is_nil())
6377 MESSAGE("BuildPresentation(): fatherSF is nil!")
6378 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6379 aStudyBuilder->Addreference(newObj1, obj);
6380 // commit transaction
6383 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
6384 aSh->SetShadingColor( GeomGUI->myShadingColor );
6385 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
6388 IO->setEntry(obj->GetID());
6390 aSh->setName( aName->Value() );
6391 ic->Display (aSh, false);
6392 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false);
6395 // next item iteration
6398 anAttr=SALOMEDS::GenericAttribute::_nil();
6399 while (anIter->More() && anAttr->_is_nil()) {
6400 SALOMEDS::SObject_var subobject = anIter->Value();
6401 SALOMEDS::GenericAttribute_var aTmpAttribute;
6402 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6403 anAttr = aTmpAttribute;
6405 } else anIter->Next();
6408 anAttr = SALOMEDS::GenericAttribute::_nil();
6413 // No viewer update should be done here!
6414 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6415 //ic->UpdateCurrentViewer();
6419 //=======================================================================
6420 // function : Parameter()
6421 // purpose : return a parameter (float) from a dialog box
6423 // avalue1 : is a float or integer used as a default value displayed
6424 // aTitle1 : is the title for aValue1
6425 // aTitle : is the main title
6426 // bottom : maximum value to be entered
6427 // top : minimum value to be entered
6428 // decimals : number of decimals
6429 //=======================================================================
6430 double GeometryGUI::Parameter( Standard_Boolean& res,
6431 const char* aValue1,
6432 const char* aTitle1,
6434 const double bottom,
6436 const int decimals )
6438 GeometryGUI_aParameterDlg * Dialog =
6439 new GeometryGUI_aParameterDlg(aValue1,
6441 QAD_Application::getDesktop(),
6448 int r = Dialog->exec() ;
6450 if ( r == QDialog::Accepted ) {
6451 res = Standard_True;
6452 X = Dialog->getValue();
6454 res = Standard_False;
6460 //=======================================================================
6461 // function : OnSketchSegment()
6463 //=======================================================================
6464 void GeometryGUI::OnSketchSegment()
6466 this->mySketcher.ChangeMode(SEGMENT);
6470 //=======================================================================
6471 // function : OnSketchArc()
6473 //=======================================================================
6474 void GeometryGUI::OnSketchArc()
6476 this->mySketcher.ChangeMode(ARC_CHORD);
6479 //=======================================================================
6480 // function : OnSketchSetAngle()
6482 //=======================================================================
6483 void GeometryGUI::OnSketchSetAngle()
6485 Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180;
6486 Sketch::fitInResol(anAngle);
6487 Standard_Boolean res = false ;
6488 QString Value = QString("%1").arg( anAngle );
6489 anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ;
6492 this->mySketcher.SetSegmentAngle(anAngle);
6493 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6495 QMenuItem* item = Mb->findItem(3133,&pp);
6496 pp->setItemChecked(3133,false);
6497 item = Mb->findItem(3134,&pp);
6498 pp->setItemChecked(3134,false);
6504 //=======================================================================
6505 // function : OnSketchSetx()
6507 //=======================================================================
6508 void GeometryGUI::OnSketchSetx()
6510 Standard_Boolean res = false;
6511 double X = Parameter( res,
6514 tr("GEOM_MEN_SKETCHER_X"),
6515 2.0 * Precision::Confusion(),
6519 this->mySketcher.SetXDimension(X);
6520 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6522 QMenuItem* item = Mb->findItem(3133,&pp);
6523 pp->setItemChecked(3133,false);
6524 item = Mb->findItem(3134,&pp);
6525 pp->setItemChecked(3134,false);
6528 //=======================================================================
6529 // function : OnSketchSety()
6531 //=======================================================================
6532 void GeometryGUI::OnSketchSety()
6534 Standard_Boolean res = false;
6535 double Y = Parameter( res,
6538 tr("GEOM_MEN_SKETCHER_Y"),
6539 2.0 * Precision::Confusion(),
6543 this->mySketcher.SetYDimension(Y);
6544 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6546 QMenuItem* item = Mb->findItem(3133,&pp);
6547 pp->setItemChecked(3133,false);
6548 item = Mb->findItem(3134,&pp);
6549 pp->setItemChecked(3134,false);
6553 //=======================================================================
6554 // function : OnSketchDelete()
6556 //=======================================================================
6557 void GeometryGUI::OnSketchDelete()
6559 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
6560 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
6562 QMenuItem* item = Mb->findItem(313,&pp);
6563 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6564 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6567 if (this->mySketcher.Delete())
6568 GeomGUI->ResetState();
6572 //=======================================================================
6573 // function : OnSketchClose()
6575 //=======================================================================
6576 void GeometryGUI::OnSketchClose()
6578 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6579 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6581 TopoDS_Wire W = this->mySketcher.Close();
6582 if ( !W.IsNull() ) {
6584 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6585 listShapes->length(0);
6588 BRepTools_WireExplorer Ex(W);
6589 while ( Ex.More() ) {
6590 TopoDS_Edge E = Ex.Current();
6593 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6594 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6597 Handle(Geom_Curve) Curve;
6598 Handle(Geom_Circle) Circle;
6600 Standard_Real First,Last;
6602 Curve = BRep_Tool::Curve(E,First,Last);
6603 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6604 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6605 Circ = Circle->Circ(); // gp_Circ
6607 Curve->D0( (First + Last) / 2. , CenterPoint );
6609 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6610 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6611 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6613 GEOM::GEOM_Shape_var arc;
6616 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6618 catch (const SALOME::SALOME_Exception& S_ex) {
6619 QtCatchCorbaException(S_ex);
6622 listShapes->length(i+1);
6623 listShapes[i] = strdup(arc->Name());
6626 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6627 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6628 GEOM::GEOM_Shape_var segment;
6631 segment = myComponentGeom->MakeEdge(pI,pE) ;
6633 catch (const SALOME::SALOME_Exception& S_ex) {
6634 QtCatchCorbaException(S_ex);
6637 listShapes->length(i+1);
6638 listShapes[i] = strdup(segment->Name());
6643 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6644 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6645 Standard_CString type;
6646 GetShapeTypeString(S,type);
6647 Wire->NameType( type );
6649 if ( Display(Wire, "" )) {
6650 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6653 GeomGUI->ResetState();
6654 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6656 QMenuItem* item = Mb->findItem(313,&pp);
6657 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6658 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6663 //=======================================================================
6664 // function : OnSketchEnd()
6666 //=======================================================================
6667 void GeometryGUI::OnSketchEnd()
6669 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6670 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6672 TopoDS_Wire W = this->mySketcher.End();
6675 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6676 listShapes->length(0);
6679 BRepTools_WireExplorer Ex(W);
6680 while ( Ex.More() ) {
6681 TopoDS_Edge E = TopoDS::Edge( Ex.Current() );
6684 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6685 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6688 Handle(Geom_Curve) Curve;
6689 Handle(Geom_Circle) Circle;
6691 Standard_Real First,Last;
6693 Curve = BRep_Tool::Curve(E,First,Last);
6694 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6695 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6696 Circ = Circle->Circ(); // gp_Circ
6698 Curve->D0( (First + Last) / 2. , CenterPoint );
6700 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6701 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6702 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6704 GEOM::GEOM_Shape_var arc;
6707 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6709 catch (const SALOME::SALOME_Exception& S_ex) {
6710 QtCatchCorbaException(S_ex);
6713 listShapes->length(i+1);
6714 listShapes[i] = strdup(arc->Name());
6717 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6718 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6719 GEOM::GEOM_Shape_var segment;
6722 segment = myComponentGeom->MakeEdge(pI,pE) ;
6724 catch (const SALOME::SALOME_Exception& S_ex) {
6725 QtCatchCorbaException(S_ex);
6728 listShapes->length(i+1);
6729 listShapes[i] = strdup(segment->Name());
6735 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6736 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6737 Standard_CString type;
6738 GetShapeTypeString(S,type);
6739 Wire->NameType( type );
6741 if ( Display(Wire, "") ) {
6742 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6745 GeomGUI->ResetState();
6746 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6748 QMenuItem* item = Mb->findItem(313,&pp);
6749 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6750 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6753 //=======================================================================
6754 // function : OnSettingsNoconstraint()
6756 //=======================================================================
6757 void GeometryGUI::OnSettingsNoconstraint()
6759 this->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6762 //=======================================================================
6763 // function : OnSettingsPerpendicular()
6765 //=======================================================================
6766 void GeometryGUI::OnSettingsPerpendicular()
6768 this->mySketcher.SetTransitionStatus(PERPENDICULAR);
6771 //=======================================================================
6772 // function : OnSettingsTangent()
6774 //=======================================================================
6775 void GeometryGUI::OnSettingsTangent()
6777 this->mySketcher.SetTransitionStatus(TANGENT);
6780 //=======================================================================
6781 // function : OnSketchOptionsOnoffangledimension()
6783 //=======================================================================
6784 void GeometryGUI::OnSketchOptionsOnoffangledimension()
6786 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6788 QMenuItem* item = Mb->findItem(10011,&pp);
6789 pp->setItemChecked(10011,!pp->isItemChecked(10011));
6790 this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
6793 //=======================================================================
6794 // function : OnSketchOptionsOnofflengthdimension()
6796 //=======================================================================
6797 void GeometryGUI::OnSketchOptionsOnofflengthdimension()
6799 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6801 QMenuItem* item = Mb->findItem(10010,&pp);
6802 pp->setItemChecked(10010,!pp->isItemChecked(10010));
6803 this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
6806 //=======================================================================
6807 // function : OnSketchOptionsOnoffradiusdimension()
6809 //=======================================================================
6810 void GeometryGUI::OnSketchOptionsOnoffradiusdimension()
6812 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6814 QMenuItem* item = Mb->findItem(10012,&pp);
6815 pp->setItemChecked(10012,!pp->isItemChecked(10012));
6816 this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
6820 //=======================================================================
6821 // function : OnSketchOptionsOnoffxdimension()
6823 //=======================================================================
6824 void GeometryGUI::OnSketchOptionsOnoffxdimension()
6826 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6828 QMenuItem* item = Mb->findItem(10013,&pp);
6829 pp->setItemChecked(10013,!pp->isItemChecked(10013));
6830 this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
6833 //=======================================================================
6834 // function : OnSketchOptionsOnoffydimension()
6836 //=======================================================================
6837 void GeometryGUI::OnSketchOptionsOnoffydimension()
6839 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6841 QMenuItem* item = Mb->findItem(10014,&pp);
6842 pp->setItemChecked(10014,!pp->isItemChecked(10014));
6843 this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
6847 //=======================================================================
6848 // function : Archimede()
6850 //=======================================================================
6851 void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO,
6852 const double aWeight,
6853 const double aWaterDensity,
6854 const double aMeshingDeflection )
6857 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
6858 Handle(GEOM_InteractiveObject) GIO =
6859 Handle(GEOM_InteractiveObject)::DownCast( IO );
6860 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() );
6862 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6863 Result->NameType(tr("GEOM_PLANE"));
6864 if ( Display(Result, "") ) {
6865 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6869 if ( IO->hasEntry() ) {
6870 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6871 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
6872 SALOMEDS::GenericAttribute_var anAttr;
6873 SALOMEDS::AttributeIOR_var anIOR;
6874 if ( !obj->_is_nil() ) {
6875 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
6876 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6877 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() );
6878 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6879 Result->NameType(tr("GEOM_PLANE"));
6880 if ( Display(Result, "") ) {
6881 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6888 catch (const SALOME::SALOME_Exception& S_ex) {
6889 QtCatchCorbaException(S_ex);
6894 //=====================================================================================
6896 //=====================================================================================
6899 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
6901 return GeometryGUI::OnGUIEvent(theCommandID, parent);
6904 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6906 return GeometryGUI::OnKeyPress (pe, parent, studyFrame);
6909 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6911 return GeometryGUI::OnMousePress (pe, parent, studyFrame);
6914 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6916 return GeometryGUI::OnMouseMove (pe, parent, studyFrame);
6919 bool SetSettings ( QAD_Desktop* parent )
6921 return GeometryGUI::SetSettings( parent );
6924 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
6925 const QString & theParent, const QString & theObject )
6927 return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
6930 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
6932 GeometryGUI::DefinePopup( theContext, theParent, theObject );
6935 bool activeStudyChanged ( QAD_Desktop* parent )
6937 GeometryGUI::activeStudyChanged( parent );
6940 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
6942 GeometryGUI::BuildPresentation(theIO);
6945 void supportedViewType(int* buffer, int bufferSize)
6947 if (!buffer || !bufferSize) return;
6948 buffer[0] = (int)VIEW_OCC;
6949 if (--bufferSize) buffer[1] = (int)VIEW_VTK;
6953 //=====================================================================================
6954 // function : OnFilletGetAll()
6956 //=====================================================================================
6957 bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR)
6959 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6960 ListOfID->length(0);
6962 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6963 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6964 if ( theObj->_is_nil() ) {
6965 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6970 if( Radius <= Precision::Confusion() )
6973 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6974 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ;
6975 if ( result->_is_nil() ) {
6976 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6979 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
6980 Standard_CString type;
6981 GetShapeTypeString(S,type);
6982 result->NameType( type );
6984 if ( Display( result, "" ))
6985 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6987 catch (const SALOME::SALOME_Exception& S_ex) {
6988 QtCatchCorbaException(S_ex);
6993 //=====================================================================================
6994 // function : OnFilletGetSelected()
6996 //=====================================================================================
6997 bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
6998 const char* ShapeTopoIOR,
6999 const double Radius,
7000 const int SubShapeType,
7001 Standard_Integer& aLocalContextId,
7002 bool& myUseLocalContext )
7004 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
7008 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
7009 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
7011 if( myUseLocalContext == false ) {
7012 /* No local context opened for fillet method */
7013 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7017 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7019 int nbSelected = ic->NbSelected();
7023 while(ic->MoreSelected()) {
7024 TopoDS_Shape s = ic->SelectedShape();
7025 if ( s.ShapeType() == TopAbs_FACE ) {
7026 TopExp_Explorer Exp( s, TopAbs_EDGE );
7027 TopTools_MapOfShape M ;
7028 while ( Exp.More() ) {
7029 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
7030 ListOfID->length( i + 1 );
7031 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
7038 ListOfID->length( i + 1 );
7039 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
7045 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7046 GEOM::GEOM_Shape_var aResult ;
7048 aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID );
7050 /* local context from DialogBox */
7051 ic->CloseLocalContext(aLocalContextId) ;
7052 myUseLocalContext = false ;
7054 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
7055 Standard_CString type;
7056 GetShapeTypeString(S,type);
7057 aResult->NameType( type );
7059 if ( Display( aResult, "") )
7060 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7062 catch (const SALOME::SALOME_Exception& S_ex) {
7063 QtCatchCorbaException(S_ex);
7066 if ( myUseLocalContext ) {
7067 /* local context from DialogBox */
7068 ic->CloseLocalContext(aLocalContextId) ;
7069 myUseLocalContext = false ;
7072 this->OnDisplayAll(true);
7073 myActiveStudy->updateObjBrowser();
7074 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7079 //=====================================================================================
7080 // function : OnChamferGetAll()
7082 //=====================================================================================
7083 bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR)
7085 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7086 ListOfID->length(0);
7088 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
7089 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
7090 if ( theObj->_is_nil() ) {
7091 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
7096 if( D1 <= Precision::Confusion() )
7098 if( D2 <= Precision::Confusion() )
7101 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7102 GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ;
7103 if ( result->_is_nil() ) {
7104 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7108 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
7109 Standard_CString type;
7110 GetShapeTypeString(S,type);
7111 result->NameType( type );
7113 if ( Display( result, "") )
7114 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7116 catch (const SALOME::SALOME_Exception& S_ex) {
7117 QtCatchCorbaException(S_ex);
7122 //=====================================================================================
7123 // function : OnChamferGetSelected()
7125 //=====================================================================================
7126 bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
7127 const char* ShapeTopoIOR,
7128 const double D1, const double D2, const int SubShapeType,
7129 Standard_Integer& aLocalContextId,
7130 bool& myUseLocalContext)
7132 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
7136 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
7137 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
7139 if( myUseLocalContext == false ) {
7140 /* No local context opened for chamfer method */
7141 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7145 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7147 int nbSelected = ic->NbSelected();
7151 while(ic->MoreSelected()) {
7152 TopoDS_Shape s = ic->SelectedShape();
7153 if ( s.ShapeType() == TopAbs_FACE ) {
7154 TopExp_Explorer Exp( s, TopAbs_EDGE );
7155 TopTools_MapOfShape M ;
7156 while ( Exp.More() ) {
7157 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
7158 ListOfID->length( i + 1 );
7159 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
7166 ListOfID->length( i + 1 );
7167 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ;
7173 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7174 GEOM::GEOM_Shape_var aResult ;
7176 aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID );
7178 /* local context from DialogBox */
7179 ic->CloseLocalContext(aLocalContextId) ;
7180 myUseLocalContext = false ;
7182 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
7183 Standard_CString type;
7184 GetShapeTypeString(S,type);
7185 aResult->NameType( type );
7187 if ( Display( aResult, "") )
7188 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7190 catch (const SALOME::SALOME_Exception& S_ex) {
7191 QtCatchCorbaException(S_ex);
7194 if ( myUseLocalContext ) {
7195 /* local context from DialogBox */
7196 ic->CloseLocalContext(aLocalContextId) ;
7197 myUseLocalContext = false ;
7200 this->OnDisplayAll(true);
7201 myActiveStudy->updateObjBrowser();
7202 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7207 //=====================================================================================
7208 // function : MakeCDGAndDisplay()
7210 //=====================================================================================
7211 void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
7214 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape );
7215 if ( result->_is_nil() ) {
7216 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
7219 result->NameType( tr("GEOM_POINT") );
7220 if ( Display( result ) )
7221 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7223 catch (const SALOME::SALOME_Exception& S_ex) {
7224 QtCatchCorbaException(S_ex);
7229 bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) {
7230 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
7231 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
7232 SALOMEDS::SObject_var RefSO;
7233 SALOMEDS::GenericAttribute_var anAttr;
7234 SALOMEDS::AttributeIOR_var anIOR;
7235 for (; it->More();it->Next()) {
7236 SALOMEDS::SObject_var SO= it->Value();
7237 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
7238 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7239 if ( strcmp( anIOR->Value(), IOR ) == 0 )
7242 if ( SO->ReferencedObject( RefSO ) ) {
7243 if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) {
7244 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7245 if ( strcmp( anIOR->Value(), IOR ) == 0 )