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>
147 #include <qcheckbox.h>
148 #include <qcolordialog.h>
149 #include <qmessagebox.h>
150 #include <qspinbox.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_FilletDlg.h" // Method FILLET
207 #include "GeometryGUI_ChamferDlg.h" // Method CHAMFER
208 #include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE
209 #include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES
210 #include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE
211 #include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE
212 #include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement
213 #include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement
214 #include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX
215 #include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
216 #include "GeometryGUI_WhatisDlg.h" // Method WHATIS
217 #include "GeometryGUI_DistanceDlg.h" // Method DISTANCE
218 #include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE
221 static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape());
222 static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), "");
224 static AIS_ListOfInteractive ListDisplayedObject;
226 static bool Settings_AddInStudy = false;
227 static bool Settings_Copy = false;
228 static Standard_CString Fatherior = "";
229 static GEOM_Client ShapeReader;
231 /* The object itself created in the static method 'GetOrCreateGeometryGUI()' */
232 static GeometryGUI* GeomGUI = 0;
236 //=======================================================================
237 // class : CustomItem
238 // purpose : Set Font to a text.
239 //=======================================================================
240 class CustomItem : public QCustomMenuItem
243 CustomItem( const QString& s, const QFont& f )
244 : string( s ), font( f ){};
247 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
250 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
255 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
265 //=======================================================================
266 // function : GeometryGUI()
267 // purpose : Constructor
268 //=======================================================================
269 GeometryGUI::GeometryGUI() :
274 //=======================================================================
275 // function : ~GeometryGUI()
276 // purpose : Destructor
277 //=======================================================================
278 GeometryGUI::~GeometryGUI()
283 //=======================================================================
284 // function : GetGeometryGUI() static
285 // purpose : Returns current 'GeomGUI' a static pointer
286 //=======================================================================
287 GeometryGUI* GeometryGUI::GetGeometryGUI( )
293 //=====================================================================================
294 // function : GetIndex()
295 // purpose : Get the index of a sub shape in a main shape : index start at 1
296 //=====================================================================================
297 int GeometryGUI::GetIndex(const TopoDS_Shape& subshape,
298 const TopoDS_Shape& shape,
301 if( shape.IsNull() || subshape.IsNull() )
305 if (subshape.ShapeType() == TopAbs_COMPOUND)
308 TopTools_ListOfShape CL;
310 TopTools_ListIteratorOfListOfShape itC;
311 for (itC.Initialize( CL ); itC.More(); itC.Next())
313 for (it.Initialize( itC.Value() ); it.More(); it.Next())
315 if ( it.Value().ShapeType() == TopAbs_COMPOUND)
317 if (it.Value().IsSame(subshape))
321 CL.Append( it.Value() );
328 TopExp_Explorer Exp ( shape, subshape.ShapeType() );
329 TopTools_MapOfShape M;
332 if ( M.Add(Exp.Current()) )
334 if ( Exp.Current().IsSame(subshape) )
344 //=======================================================================
345 // function : GetOrCreateGeometryGUI()
346 // purpose : Gets or create an object 'GeometryGUI' with initialisations
347 // : Returns 'GeomGUI' as a pointer
348 //=======================================================================
349 GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
352 GeomGUI = new GeometryGUI;
353 GeomGUI->myActiveDialogBox = 0 ;
354 GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape());
355 GeomGUI->myState = -1 ;
356 GeomGUI->myDesktop = desktop ;
357 GeomGUI->myActiveStudy = desktop->getActiveStudy();
358 GeomGUI->mySimulationActor = vtkActorCollection::New() ;
360 GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
362 Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM");
363 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
365 /* GetCurrentStudy */
366 int studyId = GeomGUI->myActiveStudy->getStudyId();
367 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
369 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
371 /* study may have changed */
372 GeomGUI->myActiveStudy = desktop->getActiveStudy();
378 //=================================================================================
379 // function : VertexToPoint()
380 // purpose : If S can be converted in a gp_Pnt returns true and the result is P
381 //=================================================================================
382 bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P )
384 if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX )
386 P = BRep_Tool::Pnt(TopoDS::Vertex( S ));
391 //=================================================================================
392 // function : LinearEdgeExtremities()
393 // purpose : If S can be converted in a linear edge and if initial an final points
394 // : distance is sufficient, returns true else returns false.
395 // : Resulting points are respectively P1 and P2
396 //=================================================================================
397 bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 )
399 if( S.IsNull() || S.ShapeType() != TopAbs_EDGE )
401 BRepAdaptor_Curve curv(TopoDS::Edge(S));
402 if (curv.GetType() != GeomAbs_Line)
405 curv.D0( curv.FirstParameter(), P1 );
406 curv.D0( curv.LastParameter(), P2 );
408 if( P1.Distance(P2) <= Precision::Confusion() )
414 //=================================================================================
415 // function : GetBipointDxDyDz()
417 //=================================================================================
418 void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz )
420 dx = P2.X() - P1.X() ;
421 dy = P2.Y() - P1.Y() ;
422 dz = P2.Z() - P1.Z() ;
426 //=======================================================================
427 // function : GetTopoFromSelection()
428 // purpose : Define tds from a single selection and retuen true
429 //=======================================================================
430 bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
432 if(Sel->IObjectCount() != 1)
435 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
437 if ( IO->hasEntry() ) {
438 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
439 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
440 SALOMEDS::GenericAttribute_var anAttr;
441 SALOMEDS::AttributeIOR_var anIOR;
442 if ( !obj->_is_nil() ) {
443 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
444 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
445 tds = this->GetShapeFromIOR(anIOR->Value());
454 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
455 Standard_CString ior = "";
456 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
457 ior = GIObject->getIOR();
458 tds = this->GetShapeFromIOR(ior);
470 //=====================================================================================
471 // function : PrepareSubShapeSelection()
472 // purpose : ( localContextId of the method is opened and defined here)
473 //=====================================================================================
474 bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
476 //* Test the type of viewer */
477 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
480 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
481 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
483 /* local context opening */
484 SetDisplayedObjectList() ;
487 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
488 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
489 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
490 for(;It.More();It.Next()) {
491 Handle(SALOME_InteractiveObject) IObject = It.Value();
492 Standard_Boolean found;
493 Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found);
494 if ( found && SubShapeType >= Shape->Shape().ShapeType()) {
495 ic->Load(Shape, (8 - SubShapeType), Standard_True);
496 ic->HilightWithColor(Shape, Quantity_NOC_RED);
499 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
505 //=====================================================================================
506 // function : PrepareSubShapeSelectionArgumentShape()
507 // purpose : ( localContextId of the method is opened and defined here )
508 //=====================================================================================
509 bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
510 const int SubShapeType,
511 Standard_Integer& returnLocalContextId )
513 //* Test the type of viewer */
514 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
517 if( aShape.IsNull() )
520 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
521 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
523 /* local context opening */
524 SetDisplayedObjectList() ;
527 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
529 Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ;
530 ic->Display(Shape, 0, (8 - SubShapeType));
532 // Not Load(...) but Display(...)
533 // ic->Load(Shape, (8 - SubShapeType), Standard_True);
534 ic->HilightWithColor(Shape, Quantity_NOC_RED);
536 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
542 //=======================================================================
543 // function : GetNameOfSelectedIObjects()
544 // purpose : Define the name geom++ or other name of mono or multi sel.
545 //=======================================================================
546 int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel,
549 int nbSel = Sel->IObjectCount() ;
551 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
552 aName = IObject->getName();
554 aName = tr( "%1_objects" ).arg( nbSel );
560 //=======================================================================
561 // function : ConvertIOinGEOMAISShape()
563 //=======================================================================
564 Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
565 Standard_Boolean& testResult,
566 bool onlyInActiveView )
568 Handle(GEOM_AISShape) res;
569 int nbSf = myActiveStudy->getStudyFramesCount();
570 for ( int i = 0; i < nbSf; i++ ) {
571 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
572 if ( sf->getTypeView() == VIEW_OCC ) {
573 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
574 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
576 AIS_ListOfInteractive List;
577 ic->DisplayedObjects(List);
578 AIS_ListOfInteractive List1;
579 ic->ObjectsInCollector(List1);
582 AIS_ListIteratorOfListOfInteractive ite(List);
584 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
585 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
586 if ( aSh->hasIO() ) {
587 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
588 if ( GIO->isSame( IO ) ) {
589 if ( onlyInActiveView ) {
590 if ( sf == myActiveStudy->getActiveStudyFrame() ) {
609 //=======================================================================
610 // function : ConvertIORinGEOMAISShape()
612 //=======================================================================
613 Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR,
614 Standard_Boolean& testResult,
615 bool onlyInActiveView )
617 Handle(GEOM_AISShape) resultShape;
619 int nbSf = myActiveStudy->getStudyFramesCount();
620 for ( int i = 0; i < nbSf; i++ )
622 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
623 if ( sf->getTypeView() == VIEW_OCC )
625 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
626 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
628 AIS_ListOfInteractive List;
629 ic->DisplayedObjects(List);
630 AIS_ListOfInteractive List1;
631 ic->ObjectsInCollector(List1);
634 AIS_ListIteratorOfListOfInteractive ite(List);
637 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
639 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
642 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
643 Standard_CString theIOR = GIO->getIOR();
644 if ( strcmp( IOR, theIOR ) == 0 )
646 if ( onlyInActiveView )
648 if ( sf == myActiveStudy->getActiveStudyFrame() )
670 //=======================================================================
671 // function : ConvertIORinGEOMActor()
673 //=======================================================================
674 GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
675 Standard_Boolean& testResult,
676 bool onlyInActiveView )
678 int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount();
679 for ( int i = 0; i < nbSf; i++ ) {
680 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
681 if ( sf->getTypeView() == VIEW_VTK ) {
682 vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
683 vtkActorCollection* theActors = Renderer->GetActors();
684 theActors->InitTraversal();
685 vtkActor *ac = theActors->GetNextActor();
687 if ( ac->IsA("GEOM_Actor") ) {
688 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
689 if ( anActor->hasIO() ) {
690 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO());
691 Standard_CString theIOR = GIO->getIOR();
692 if ( strcmp( IOR, theIOR ) == 0 ) {
693 if ( onlyInActiveView ) {
694 if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) {
705 ac = theActors->GetNextActor();
710 return GEOM_Actor::New();
713 //=======================================================================
714 // function : ConvertIOinGEOMShape()
716 //=======================================================================
717 GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
718 Standard_Boolean& testResult )
720 GEOM::GEOM_Shape_ptr aShape ;
724 if ( IO->hasEntry() ) {
725 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
726 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
727 SALOMEDS::GenericAttribute_var anAttr;
728 SALOMEDS::AttributeIOR_var anIOR;
729 if ( !obj->_is_nil() ) {
730 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
731 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
732 aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
738 /* case Graphical Object */
739 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
740 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
741 Standard_CString ior = GIObject->getIOR();
743 aShape = myComponentGeom->GetIORFromString(ior) ;
750 //=======================================================================
751 // function : ConvertListOfIOInListOfIOR()
753 //=======================================================================
754 void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
755 GEOM::GEOM_Gen::ListOfIOR& listIOR )
757 int nbSel = aList.Extent();
758 listIOR.length(nbSel) ;
760 SALOME_ListIteratorOfListIO It( aList );
761 for ( int i=0; It.More(); It.Next(), i++ )
763 Handle(SALOME_InteractiveObject) IObject = It.Value();
765 if ( IObject->hasEntry() )
767 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
768 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
769 SALOMEDS::GenericAttribute_var anAttr;
770 SALOMEDS::AttributeIOR_var anIOR;
771 if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") )
773 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
774 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
775 CORBA::ORB_var& _orb = init.orb() ;
776 CORBA::String_var theValue = anIOR->Value();
777 CORBA::Object_var theObj = _orb->string_to_object(theValue);
778 if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0"))
780 listIOR[j] = strdup(theValue) ;
785 else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
786 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject );
787 Standard_CString ior = GIObject->getIOR();
788 listIOR[j] = strdup(ior) ;
796 //=================================================================================
797 // function : GetShapeTypeString()
798 // purpose : for a single shape
799 //=================================================================================
800 bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString )
802 if( aShape.IsNull() ) {
803 aTypeString = "aNullShape" ;
806 switch (aShape.ShapeType() )
808 case TopAbs_COMPOUND:
809 { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; }
810 case TopAbs_COMPSOLID:
811 { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; }
813 { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; }
815 { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; }
818 BRepAdaptor_Surface surf(TopoDS::Face(aShape));
819 if ( surf.GetType() == GeomAbs_Plane ) {
820 aTypeString = strdup(tr("GEOM_PLANE")) ;
822 } else if ( surf.GetType() == GeomAbs_Cylinder ) {
823 aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ;
825 } else if ( surf.GetType() == GeomAbs_Sphere ) {
826 aTypeString = strdup(tr("GEOM_SURFSPHERE")) ;
828 } else if ( surf.GetType() == GeomAbs_Torus ) {
829 aTypeString = strdup(tr("GEOM_SURFTORUS")) ;
831 } else if ( surf.GetType() == GeomAbs_Cone ) {
832 aTypeString = strdup(tr("GEOM_SURFCONE")) ;
835 aTypeString = strdup(tr("GEOM_FACE")) ;
840 { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; }
843 BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
844 if ( curv.GetType() == GeomAbs_Line ) {
845 if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
846 (Abs(curv.LastParameter()) >= 1E6 )) {
847 aTypeString = strdup(tr("GEOM_LINE")) ;
849 aTypeString = strdup(tr("GEOM_EDGE")) ;
851 } else if ( curv.GetType() == GeomAbs_Circle ) {
852 if ( curv.IsClosed() )
853 aTypeString = strdup(tr("GEOM_CIRCLE")) ;
855 aTypeString = strdup(tr("GEOM_ARC")) ;
858 aTypeString = strdup(tr("GEOM_EDGE")) ;
863 { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; }
865 { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; }
871 //=================================================================================
872 // function : CreateArrowForLinearEdge()
873 // purpose : Create a cone topology to be used to display an arrow in the middle
874 // : of an edge showing its orientation. (For simulation and Viewer OCC only)
875 //=================================================================================
876 bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone )
878 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE )
881 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
882 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
883 Standard_Real Width, Height ;
884 view3d->Size(Width, Height) ;
885 const Standard_Real aHeight = (Width + Height) / 50.0 ;
888 Standard_Real first, last ;
889 Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
893 const Standard_Real param = (first+last) / 2.0 ;
894 gp_Pnt middleParamPoint ;
896 curv->D1( param, middleParamPoint, V1) ;
897 if ( V1.Magnitude() < Precision::Confusion() )
900 /* Topology orientation not geom orientation */
901 if( tds.Orientation() == TopAbs_REVERSED )
904 gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ;
905 const Standard_Real radius1 = aHeight / 5.0 ;
906 if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) {
907 ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ;
911 catch(Standard_Failure) {
912 // OCC failures are hard to catch in GUI.
913 // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
914 // in SALOME environment : compilation error !
920 //=======================================================================
921 // function : SelectionByNameInDialogs()
922 // purpose : Called when user has entered a name of object in a LineEdit.
923 // : The selection is changed. Dialog box will receive the
924 // : corresponding signal to manage this event.
925 //=======================================================================
926 bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel )
929 /* Find SObject with name in component GEOM */
930 SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ;
931 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
932 listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ;
934 if ( listSO->length() < 1 ) {
935 const QString caption = tr("GEOM_WRN_WARNING") ;
936 const QString text = tr("GEOM_NAME_INCORRECT") ;
937 const QString button0 = tr("GEOM_BUT_OK") ;
938 QMessageBox::warning( aWidget, caption, text, button0 ) ;
941 /* More than one object with same name */
942 if ( listSO->length() > 1 ) {
943 const QString caption = tr("GEOM_WRN_WARNING") ;
944 const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ;
945 const QString button0 = tr("GEOM_BUT_OK") ;
946 QMessageBox::warning( aWidget, caption, text, button0 ) ;
950 SALOMEDS::SObject_var theObj = listSO[0] ;
951 /* Create a SALOME_InteractiveObject with a SALOME::SObject */
952 Standard_CString anEntry = theObj->GetID() ;
953 Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ;
955 /* Add as a selected object */
956 /* Clear any previous selection : */
957 /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
958 Sel->ClearIObjects() ;
959 Sel->AddIObject( SI ) ;
964 //=======================================================================
965 // function : MakePointAndDisplay
967 //=======================================================================
968 void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z )
971 GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z );
972 P->NameType( tr("GEOM_VERTEX") );
973 if ( Display( P, "") )
974 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
976 catch (const SALOME::SALOME_Exception& S_ex) {
977 QtCatchCorbaException(S_ex);
984 //=======================================================================
985 // function : MakeVectorAndDisplay()
987 //=======================================================================
988 void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
991 GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
992 GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
993 GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 );
994 Vector->NameType(tr("GEOM_VECTOR"));
995 if ( Display( Vector, "") )
996 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
998 catch (const SALOME::SALOME_Exception& S_ex) {
999 QtCatchCorbaException(S_ex);
1004 //=======================================================================
1005 // function : MakeBoxAndDisplay()
1007 //=======================================================================
1008 void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1011 GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() );
1012 box->NameType(tr("GEOM_BOX"));
1013 if ( Display( box, "") ) {
1014 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1017 catch (const SALOME::SALOME_Exception& S_ex) {
1018 QtCatchCorbaException(S_ex);
1025 //=======================================================================
1026 // function : MakePlaneAndDisplay()
1027 // purpose : Plane point is P1 and dx, dy, dz define a normal vector
1028 //=======================================================================
1029 void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
1030 const Standard_Real dy, const Standard_Real dz,
1031 const Standard_Real TrimSize )
1035 aDirection.SetCoord(dx, dy, dz) ;
1036 gp_Ax2 Axis( P1, aDirection );
1038 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1039 GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ;
1040 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1041 GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ;
1042 plane->NameType(tr("GEOM_PLANE"));
1043 if ( Display( plane, "") )
1044 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1046 catch (const SALOME::SALOME_Exception& S_ex) {
1047 QtCatchCorbaException(S_ex);
1052 //=======================================================================
1053 // function : MakeWorkingPlane()
1054 // purpose : Change the point of view3d
1055 //=======================================================================
1056 void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D)
1058 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
1059 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
1062 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
1063 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
1064 view3d->SetAt( P.X(), P.Y(), P.Z() );
1065 view3d->SetProj( D.X(), D.Y(), D.Z() );
1066 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1070 //=======================================================================
1071 // function : MakePrismAndDisplay()
1072 // purpose : P1 and P2 is to define a vector for prism
1073 //=======================================================================
1074 void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 )
1077 GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1078 GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ;
1079 if( BaseShape->_is_nil() ) {
1080 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1084 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ;
1085 if (result->_is_nil()) {
1086 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1090 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1091 Standard_CString type;
1092 GetShapeTypeString(S,type);
1093 result->NameType( type );
1095 if ( Display( result, "") )
1096 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1098 catch (const SALOME::SALOME_Exception& S_ex) {
1099 QtCatchCorbaException(S_ex);
1105 //=====================================================================================
1106 // function : MakeLineAndDisplay()
1107 // purpose : Create an infinite oriented line (linear edge in fact)
1108 //=====================================================================================
1109 void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint )
1113 GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ;
1114 Standard_Real length = InitPoint.Distance(LastPoint) ;
1115 if( length <= Precision::Confusion() ) {
1116 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1120 Standard_Real coeff = 1E6 / length ;
1122 /* To create a line with length = 1E6 */
1123 /* Precision::Infinite() is 1E100 in OCC */
1124 P1.SetX( InitPoint.X() - (coeff * dx) ) ;
1125 P1.SetY( InitPoint.Y() - (coeff * dy) ) ;
1126 P1.SetZ( InitPoint.Z() - (coeff * dz) ) ;
1128 P2.SetX( LastPoint.X() + (coeff * dx) ) ;
1129 P2.SetY( LastPoint.Y() + (coeff * dy) ) ;
1130 P2.SetZ( LastPoint.Z() + (coeff * dz) ) ;
1133 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ;
1134 GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ;
1135 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1137 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ;
1138 if(result->_is_nil()) {
1139 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1142 result->NameType(tr("GEOM_LINE"));
1144 if ( Display( result, "") )
1145 myDesktop->putInfo(tr("GEOM_PRP_READY"));
1147 catch (const SALOME::SALOME_Exception& S_ex) {
1148 QtCatchCorbaException(S_ex);
1155 //=======================================================================
1156 // function : MakeBooleanAndDisplay()
1158 //=======================================================================
1159 void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation )
1162 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ;
1163 if (result->_is_nil()) {
1164 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1168 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1169 Standard_CString type;
1170 GetShapeTypeString(S,type);
1171 result->NameType( type );
1173 if ( Display( result, "") )
1174 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1176 catch (const SALOME::SALOME_Exception& S_ex) {
1177 QtCatchCorbaException(S_ex);
1183 //=====================================================================================
1184 // function : MakeSphere()
1186 //=====================================================================================
1187 void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius )
1190 if( aRadius <= Precision::Confusion() ) {
1191 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"),
1192 tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") );
1195 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius);
1196 result->NameType(tr("GEOM_SPHERE"));
1197 if ( Display( result, "") )
1198 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1200 catch (const SALOME::SALOME_Exception& S_ex) {
1201 QtCatchCorbaException(S_ex);
1207 //=====================================================================================
1208 // function : MakeConeAndDisplay()
1210 //=====================================================================================
1211 void GeometryGUI::MakeConeAndDisplay( const gp_Pnt BasePoint,
1213 const double Radius1,
1214 const double Radius2,
1215 const double aHeight )
1218 if( ( Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion() ) || aHeight <= Precision::Confusion() )
1220 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1221 GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1222 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1224 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ;
1225 if ( result->_is_nil() ) {
1226 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1229 result->NameType(tr("GEOM_CONE"));
1230 if ( Display( result, "") )
1231 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1233 catch (const SALOME::SALOME_Exception& S_ex) {
1234 QtCatchCorbaException(S_ex);
1240 //=====================================================================================
1241 // function : MakeCylinderAndDisplay()
1243 //=====================================================================================
1244 void GeometryGUI::MakeCylinderAndDisplay( const gp_Pnt BasePoint,
1246 const double Radius,
1247 const double aHeight )
1250 if( Radius <= Precision::Confusion() || aHeight <= Precision::Confusion() )
1252 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1253 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1254 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1256 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ;
1257 if ( result->_is_nil() ) {
1258 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1261 result->NameType(tr("GEOM_CYLINDER"));
1262 if ( Display( result, "") )
1263 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1265 catch (const SALOME::SALOME_Exception& S_ex) {
1266 QtCatchCorbaException(S_ex);
1272 //=====================================================================================
1273 // function : MakeTorusAndDisplay()
1275 //=====================================================================================
1276 void GeometryGUI::MakeTorusAndDisplay( const gp_Pnt BasePoint,
1278 const double Radius1,
1279 const double Radius2 )
1282 if( Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion() )
1285 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1286 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1287 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1289 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ;
1290 if ( result->_is_nil() ) {
1291 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1294 result->NameType(tr("GEOM_TORUS"));
1295 if ( Display( result, "") )
1296 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1298 catch (const SALOME::SALOME_Exception& S_ex) {
1299 QtCatchCorbaException(S_ex);
1305 //=====================================================================================
1306 // function : MakePipeAndDisplay()
1308 //=====================================================================================
1309 void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase )
1312 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase);
1313 if ( !result->_is_nil() && Display( result, "") ) {
1315 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1316 Standard_CString type;
1317 GetShapeTypeString(S,type);
1318 result->NameType( type );
1320 myDesktop->putInfo( tr("GEOM_PRP_DONE") );
1323 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1326 catch (const SALOME::SALOME_Exception& S_ex) {
1327 QtCatchCorbaException(S_ex);
1333 //=====================================================================================
1334 // function : MakeFillingAndDisplay()
1336 //=====================================================================================
1337 void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape,
1342 const short nbiter )
1345 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape,
1347 tol3d, tol2d, nbiter );
1348 if (result->_is_nil()) {
1349 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1353 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1354 Standard_CString type;
1355 GetShapeTypeString(S,type);
1356 result->NameType( type );
1358 if ( Display( result, "") )
1359 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1362 catch (const SALOME::SALOME_Exception& S_ex) {
1363 QtCatchCorbaException(S_ex);
1369 //=====================================================================================
1370 // function : MakeMirrorAndDisplay()
1372 //=====================================================================================
1373 void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 )
1376 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 );
1377 if (result->_is_nil()) {
1378 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1381 result->NameType( Shape1->NameType() );
1382 if ( Display( result, "") )
1383 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1385 catch (const SALOME::SALOME_Exception& S_ex) {
1386 QtCatchCorbaException(S_ex);
1392 //=====================================================================================
1393 // function : MakeSewingAndDisplay()
1395 //=====================================================================================
1396 void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1397 const Standard_Real precision )
1400 GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ;
1401 if( result->_is_nil() ) {
1402 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1406 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1407 Standard_CString type;
1408 GetShapeTypeString(S,type);
1409 result->NameType( type );
1411 if( Display( result, "") )
1412 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1415 catch (const SALOME::SALOME_Exception& S_ex) {
1416 QtCatchCorbaException(S_ex);
1421 //=====================================================================================
1422 // function : MakeCompoundAndDisplay()
1424 //=====================================================================================
1425 void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1428 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ;
1429 if( result->_is_nil() ) {
1430 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1433 result->NameType(tr("GEOM_COMPOUND"));
1434 if( Display( result, "" ))
1435 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1437 catch (const SALOME::SALOME_Exception& S_ex) {
1438 QtCatchCorbaException(S_ex);
1444 //=====================================================================================
1445 // function : MakeFaceAndDisplay()
1447 //=====================================================================================
1448 void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar )
1451 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ;
1452 if( result->_is_nil() ) {
1453 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1457 result->NameType(tr("GEOM_PLANE"));
1459 result->NameType(tr("GEOM_FACE"));
1460 if( Display( result, "") )
1461 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1463 catch (const SALOME::SALOME_Exception& S_ex) {
1464 QtCatchCorbaException(S_ex);
1471 //=====================================================================================
1472 // function : MakeLinearEdgeAndDisplay()
1474 //=====================================================================================
1475 void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1478 GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
1479 GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
1480 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ;
1481 if( result->_is_nil() ) {
1482 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1485 result->NameType(tr("GEOM_EDGE"));
1486 if( Display( result, "") )
1487 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1489 catch(const SALOME::SALOME_Exception& S_ex) {
1490 QtCatchCorbaException(S_ex);
1496 //=====================================================================================
1497 // function : MakeOrientationChangeAndDisplay()
1499 //=====================================================================================
1500 void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape )
1503 GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ;
1504 if( result->_is_nil() ) {
1505 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1508 result->NameType( Shape->NameType() );
1509 if ( Display( result, "" ))
1510 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1513 catch (const SALOME::SALOME_Exception& S_ex) {
1514 QtCatchCorbaException(S_ex);
1519 //=====================================================================================
1520 // function : MakeScaleAndDisplay()
1522 //=====================================================================================
1523 void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor )
1526 GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ;
1527 GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ;
1528 // result->NameType(tr("GEOM_SCALE"));
1529 result->NameType( Shape->NameType() );
1530 if ( Display( result, "") )
1531 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1533 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1535 catch (const SALOME::SALOME_Exception& S_ex) {
1536 QtCatchCorbaException(S_ex);
1542 //=======================================================================================
1543 // function : MakeRevolutionAndDisplay()
1545 //=======================================================================================
1546 void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle )
1549 GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1550 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ;
1551 if ( result->_is_nil() ) {
1552 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1556 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1557 Standard_CString type;
1558 GetShapeTypeString(S,type);
1559 result->NameType( type );
1561 if ( Display( result ) )
1562 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1564 catch (const SALOME::SALOME_Exception& S_ex) {
1565 QtCatchCorbaException(S_ex);
1571 //=======================================================================================
1572 // function : MakeRotationAndDisplay()
1574 //=======================================================================================
1575 void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape,
1578 const Standard_Real angle )
1581 const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1582 GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle);
1583 if ( result->_is_nil() ) {
1584 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1587 result->NameType( Shape->NameType() );
1588 if ( Display( result ) )
1589 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1591 catch (const SALOME::SALOME_Exception& S_ex) {
1592 QtCatchCorbaException(S_ex);
1598 //=================================================================================
1599 // function : MakeTranslationAndDisplay()
1600 // purpose : Translate a shape
1601 //=================================================================================
1602 void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V )
1605 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ;
1606 if ( result->_is_nil() ) {
1607 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1610 result->NameType( Shape->NameType() );
1611 if ( Display( result ) )
1612 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1614 catch (const SALOME::SALOME_Exception& S_ex) {
1615 QtCatchCorbaException(S_ex);
1620 //=================================================================================
1621 // function : MakeMultiTranslation1DAndDisplay()
1622 // purpose : Multi-Translate a shape
1623 //=================================================================================
1624 void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes )
1627 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1628 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1630 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes );
1631 if ( result->_is_nil() ) {
1632 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1635 result->NameType( tr("GEOM_COMPOUND") );
1636 if ( Display( result ) )
1637 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1639 catch (const SALOME::SALOME_Exception& S_ex) {
1640 QtCatchCorbaException(S_ex);
1646 //=================================================================================
1647 // function : MakeMultiTranslation2DAndDisplay()
1648 // purpose : Multi-Translate a shape
1649 //=================================================================================
1650 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 )
1653 GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ;
1654 GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ;
1655 GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ;
1656 GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ;
1658 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 );
1659 if ( result->_is_nil() ) {
1660 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1663 result->NameType( tr("GEOM_COMPOUND") );
1664 if ( Display( result ) )
1665 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1667 catch (const SALOME::SALOME_Exception& S_ex) {
1668 QtCatchCorbaException(S_ex);
1674 //=================================================================================
1675 // function : MakeMultiRotation1DAndDisplay()
1676 // purpose : Multi-Rotate a shape
1677 //=================================================================================
1678 void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes )
1681 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1682 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1683 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1685 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes );
1686 if ( result->_is_nil() ) {
1687 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1690 result->NameType( tr("GEOM_COMPOUND") );
1691 if ( Display( result ) )
1692 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1694 catch (const SALOME::SALOME_Exception& S_ex) {
1695 QtCatchCorbaException(S_ex);
1701 //=================================================================================
1702 // function : MakeMultiRotation2DAndDisplay()
1703 // purpose : Multi-Rotate a shape
1704 //=================================================================================
1705 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 )
1708 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1709 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1710 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1712 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 );
1713 if ( result->_is_nil() ) {
1714 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1717 result->NameType( tr("GEOM_COMPOUND") );
1718 if ( Display( result ) )
1719 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1721 catch (const SALOME::SALOME_Exception& S_ex) {
1722 QtCatchCorbaException(S_ex);
1729 //=======================================================================================
1730 // function : MakeArcAndDisplay()
1731 // purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
1732 //=======================================================================================
1733 void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint )
1735 gp_Vec v1( CirclePoint, InitPoint ) ;
1736 gp_Vec v2( CirclePoint, EndPoint ) ;
1737 if( v1.IsParallel(v2, Precision::Angular() ) )
1741 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() );
1742 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() );
1743 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() );
1744 GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ;
1745 if ( result->_is_nil() ) {
1746 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1749 result->NameType(tr("GEOM_ARC"));
1750 if ( Display( result ) )
1751 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1753 catch (const SALOME::SALOME_Exception& S_ex) {
1754 QtCatchCorbaException(S_ex);
1760 //=====================================================================================
1761 // function : MakeCircleAndDisplay()
1763 //=====================================================================================
1764 void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius )
1767 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1768 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1769 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1771 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ;
1772 if ( result->_is_nil() ) {
1773 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1776 result->NameType(tr("GEOM_CIRCLE"));
1777 if ( Display( result ) )
1778 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1780 catch (const SALOME::SALOME_Exception& S_ex) {
1781 QtCatchCorbaException(S_ex);
1787 //=====================================================================================
1788 // function : MakeEllipseAndDisplay()
1790 //=====================================================================================
1791 void GeometryGUI::MakeEllipseAndDisplay( const gp_Pnt CenterPoint,
1793 const Standard_Real Major_Radius,
1794 const Standard_Real Minor_Radius )
1797 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1798 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1799 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1801 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius) ;
1802 if ( result->_is_nil() ) {
1803 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1806 result->NameType(tr("GEOM_ELLIPSE"));
1807 if ( Display( result ) )
1808 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1810 catch (const SALOME::SALOME_Exception& S_ex) {
1811 QtCatchCorbaException(S_ex);
1817 //=====================================================================================
1818 // function : MakeWireAndDisplay()
1820 //=====================================================================================
1821 void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1824 GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ;
1825 if( result->_is_nil() ) {
1826 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1829 result->NameType(tr("GEOM_WIRE"));
1830 if( Display( result, "") )
1831 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1833 catch (const SALOME::SALOME_Exception& S_ex) {
1834 QtCatchCorbaException(S_ex);
1840 //=====================================================================================
1841 // function : MakePartitionAndDisplay()
1843 //=====================================================================================
1844 void GeometryGUI::MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1845 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
1846 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
1847 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
1848 const GEOM::shape_type limit)
1851 GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR,
1855 (CORBA::Short) limit);
1856 if( result->_is_nil() ) {
1857 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1860 result->NameType(tr("GEOM_PARTITION"));
1861 if( Display( result, "") )
1862 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1865 catch (const SALOME::SALOME_Exception& S_ex) {
1866 QtCatchCorbaException(S_ex);
1870 //=======================================================================
1871 // function : SetState()
1872 // purpose : Sets myState = aState a private field indicating which methode is active
1873 //=======================================================================
1874 void GeometryGUI::SetState(int aState )
1875 { this->myState = aState ; return ; }
1878 //=======================================================================
1879 // function : ResetState()
1880 // purpose : Sets myState = -1 a private field indicating which methode is active
1881 //=======================================================================
1882 void GeometryGUI::ResetState()
1883 { this->myState = -1 ; return ; }
1886 //=======================================================================
1887 // function : EmitSignalDeactivateDialog()
1888 // purpose : Emit a signal to deactivate the active dialog Box
1889 //=======================================================================
1890 void GeometryGUI::EmitSignalDeactivateDialog()
1892 emit this->SignalDeactivateActiveDialog() ;
1896 //=======================================================================
1897 // function : EmitSignalCloseAllDialogs()
1898 // purpose : Emit a signal to deactivate all non modal dialogs box
1899 //=======================================================================
1900 void GeometryGUI::EmitSignalCloseAllDialogs()
1902 emit this->SignalCloseAllDialogs() ;
1907 //=======================================================================
1908 // function : GetActiveDialogBox()
1910 //=======================================================================
1911 QDialog* GeometryGUI::GetActiveDialogBox()
1913 return this->myActiveDialogBox ;
1917 //=======================================================================
1918 // function : SetActiveDialogBox()
1920 //=======================================================================
1921 void GeometryGUI::SetActiveDialogBox(QDialog* aDlg)
1923 this->myActiveDialogBox = (QDialog*)aDlg ;
1928 //=======================================================================
1929 // function : GetActiveStudy()
1931 //=======================================================================
1932 QAD_Study* GeometryGUI::GetActiveStudy()
1934 return this->myActiveStudy ;
1938 //=======================================================================
1939 // function : GetActiveDesktop()
1941 //=======================================================================
1942 QAD_Desktop* GeometryGUI::GetDesktop()
1944 return this->myDesktop ;
1948 //=====================================================================================
1949 // function : OnSubShapeGetAll()
1950 // purpose : Explode a shape in all sub shapes with a SubShapeType
1951 //=====================================================================================
1952 bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
1954 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1955 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
1956 if ( theObj->_is_nil() ) {
1957 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
1961 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1962 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
1963 SALOMEDS::GenericAttribute_var anAttr;
1964 SALOMEDS::AttributeName_var aName;
1965 SALOMEDS::AttributeIOR_var anIOR;
1966 SALOMEDS::AttributePixMap_var aPixmap;
1968 /* We create a sub object for each sub shape as attribute of the main object */
1969 /* Each sub object contains list (length=1) containing its index in the main shape */
1970 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
1971 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
1972 GEOM::GEOM_Shape_var aResult ;
1975 listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType );
1976 if( listGeomShapes->length() < 1 ) {
1977 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1981 catch (const SALOME::SALOME_Exception& S_ex) {
1982 QtCatchCorbaException(S_ex);
1985 /* open transaction */
1986 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
1989 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
1990 TopoDS_Shape mainShape;
1993 if ( aShape->IsMainShape() ) {
1994 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
1997 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2000 /* Loop on each sub shape created */
2001 /* int i = 1 ; /* index for the nameType */
2002 for( int j=0; j<listGeomShapes->length(); j++) {
2004 /* Get each sub shape extracted CORBA and OCC */
2005 aResult = listGeomShapes[j] ;
2006 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2009 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
2013 // NRI : Following lines are commented according to bugID SAL695 (see history)
2014 // BRepCheck_Analyzer anAnalyzer(S);
2015 // if(!anAnalyzer.IsValid()) {
2016 // myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
2017 // MESSAGE("#### An exploded shape number "<< j << " is not valid");
2022 /* Set the nameType of sub shape */
2023 char* nameG = (char *)malloc(20);
2024 Standard_CString Type;
2025 if ( GetShapeTypeString(S, Type) ) {
2026 aResult->NameType( Type );
2027 sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) );
2030 aResult->NameType( tr("GEOM_SHAPE") );
2031 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2033 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2035 bool allreadyexist = false;
2037 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2038 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2039 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2041 Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG );
2042 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2044 MESSAGE ( "SO->_is_nil() " << SO->_is_nil() )
2046 if ( SO->_is_nil() ) {
2047 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2048 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2049 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2050 aName->SetValue(nameG);
2051 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2052 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2053 anIOR->SetValue(aResult->Name());
2055 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2056 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2057 MESSAGE( " Type " << S.ShapeType() )
2058 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2059 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2060 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2061 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2062 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2063 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2064 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2065 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2066 } else if ( S.ShapeType() == TopAbs_FACE ) {
2067 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2068 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2069 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2070 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2071 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2072 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2073 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2076 MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() )
2078 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2079 aStudyBuilder->Addreference(newObj1, newObj);
2080 IO->setEntry(newObj->GetID());
2082 aResult->StudyShapeId( newObj->GetID() );
2084 allreadyexist = true;
2085 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2086 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2087 aStudyBuilder->Addreference(newObj1, SO);
2088 IO->setEntry(SO->GetID());
2089 aResult->StudyShapeId( SO->GetID() );
2093 result->setIO( IO );
2094 result->setName( nameG );
2095 if ( !allreadyexist )
2096 ic->Display(result);
2098 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2099 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
2101 int themode = myRenderInter->GetDisplayMode();
2102 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2103 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
2105 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM");
2107 if ( SO->_is_nil() ) {
2108 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2109 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2110 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2111 anIOR->SetValue(aResult->Name());
2112 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2113 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2114 aName->SetValue(nameG);
2116 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2117 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2118 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2119 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2120 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2121 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2122 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2123 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2124 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2125 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2126 } else if ( S.ShapeType() == TopAbs_FACE ) {
2127 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2128 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2129 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2130 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2131 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2132 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2133 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2136 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2137 aStudyBuilder->Addreference(newObj1, newObj);
2138 IO->setEntry(newObj->GetID());
2140 allreadyexist = true;
2141 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2142 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2143 aStudyBuilder->Addreference(newObj1, SO);
2144 IO->setEntry(SO->GetID());
2148 if ( !allreadyexist ) {
2149 vtkActorCollection* theActors =
2150 GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
2151 theActors->InitTraversal();
2152 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
2153 while(!(anActor==NULL)) {
2154 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
2155 GActor->setIO( IO );
2156 GActor->setName( nameG );
2157 theRenderer->AddActor(GActor);
2159 anActor = (vtkActor*)theActors->GetNextActor();
2165 /* commit transaction */
2168 myActiveStudy->updateObjBrowser();
2169 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2175 //=====================================================================================
2176 // function : GetIndexSubShapeSelected()
2177 // purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType
2178 // : Method used by Dialogs
2179 //=====================================================================================
2180 bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
2181 const int SubShapeType,
2182 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
2183 Standard_Integer& aLocalContextId,
2184 bool& myUseLocalContext )
2186 //* Test the type of viewer */
2187 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2191 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2192 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2195 int nbSelected = ic->NbSelected();
2196 ListOfID.length(nbSelected);
2199 //***************** DEFINE INDEX OF EACH SELECTION *********************//
2201 ic->InitSelected(); /* to restart */
2202 while( ic->MoreSelected() ) {
2204 /* Find index of sub shape into main shape */
2205 TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) );
2207 bool found = false ;
2208 while ( Exp.More() ) {
2209 if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) {
2217 /* Manage local context from DialogBox */
2218 ic->CloseLocalContext(aLocalContextId) ;
2219 myUseLocalContext = false ;
2222 ListOfID[i] = index ;
2226 //***************** END *********************//
2228 /* Manage local context from DialogBox */
2229 ic->CloseLocalContext(aLocalContextId) ;
2230 myUseLocalContext = false ;
2236 //=====================================================================================
2237 // function : OnSubShapeGetSelected()
2239 //=====================================================================================
2240 bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
2241 const char* ShapeTopoIOR,
2242 const int SubShapeType,
2243 Standard_Integer& aLocalContextId,
2244 bool& myUseLocalContext )
2246 //* Test the type of viewer */
2247 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2251 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2252 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2253 if ( theObj->_is_nil() ) {
2254 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2259 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2260 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2262 if( myUseLocalContext == false ) {
2263 /* local context is from DialogBox */
2264 MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
2268 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2269 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
2271 TopoDS_Shape mainShape;
2274 if ( aShape->IsMainShape() ) {
2275 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
2278 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2281 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2283 int nbSelected = ic->NbSelected();
2284 ListOfID->length(nbSelected);
2286 TopoDS_Compound compound;
2287 ic->InitSelected(); /* to init again */
2289 B.MakeCompound( compound );
2292 /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
2293 /* the compound is homogenous by selection */
2294 while(ic->MoreSelected()) {
2295 int index = GetIndex( ic->SelectedShape(), mainShape, SubShapeType );
2296 ListOfID[i] = index ;
2297 B.Add( compound, ic->SelectedShape() );
2302 /* Test if user has selected sub shapes */
2303 if( ListOfID->length() < 1 )
2306 GEOM::GEOM_Shape_var aResult ;
2308 aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID );
2310 catch (const SALOME::SALOME_Exception& S_ex) {
2311 QtCatchCorbaException(S_ex);
2314 /* local context from DialogBox */
2315 ic->CloseLocalContext(aLocalContextId) ;
2316 myUseLocalContext = false ;
2318 char* nameG = (char *)malloc(20);
2319 Standard_CString Type;
2321 Handle(GEOM_AISShape) result;
2322 Handle(GEOM_InteractiveObject) IO ;
2324 // if ( ! SObjectExist(theObj, aResult->Name()) ) {
2325 if ( nbSelected == 1 ) {
2326 TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) );
2328 if ( GetShapeTypeString(Exp.Current(),Type) ) {
2329 aResult->NameType( Type );
2330 sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) );
2332 aResult->NameType( tr("GEOM_SHAPE") );
2333 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2335 result = new GEOM_AISShape( Exp.Current(), nameG );
2336 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2340 if ( GetShapeTypeString(compound,Type) ) {
2341 aResult->NameType( Type );
2342 sprintf (nameG, "%s_%d", Type, this->myNbGeom++ );
2344 aResult->NameType( tr("GEOM_SHAPE") );
2345 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2347 result = new GEOM_AISShape( compound, nameG );
2348 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2351 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2353 /* open transaction */
2354 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
2357 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2358 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
2359 SALOMEDS::GenericAttribute_var anAttr;
2360 SALOMEDS::AttributeName_var aName;
2361 SALOMEDS::AttributeIOR_var anIOR;
2362 SALOMEDS::AttributePixMap_var aPixmap;
2364 bool allreadyexist = false;
2366 if ( SO->_is_nil() ) {
2367 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2368 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2369 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2370 anIOR->SetValue(aResult->Name());
2371 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2372 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2373 aName->SetValue(result->getName());
2375 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2376 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2377 if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) {
2378 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2379 } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) {
2380 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2381 } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) {
2382 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2383 } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) {
2384 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2385 } else if ( result->Shape().ShapeType() == TopAbs_FACE ) {
2386 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2387 } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) {
2388 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2389 } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) {
2390 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2391 } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) {
2392 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2395 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2396 aStudyBuilder->Addreference(newObj1, newObj);
2398 IO->setEntry(newObj->GetID());
2399 aResult->StudyShapeId(newObj->GetID());
2401 allreadyexist = true;
2402 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2403 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2404 aStudyBuilder->Addreference(newObj1, SO);
2406 IO->setEntry(SO->GetID());
2407 aResult->StudyShapeId(SO->GetID());
2411 /* commit transaction */
2414 result->setIO( IO );
2415 result->setName( nameG );
2417 if ( !allreadyexist )
2418 ic->Display(result);
2420 this->OnDisplayAll(true);
2421 myActiveStudy->updateObjBrowser();
2422 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2428 //=====================================================================================
2429 // function : OnSuppressFaces()
2430 // purpose : To suppress faces from a shape
2431 // : The result is one or more shells/faces as main shapes !
2432 //=====================================================================================
2433 bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
2434 const char* ShapeTopoIOR,
2435 const Standard_Integer& aLocalContextId,
2436 bool& myUseLocalContext )
2438 /* Test the type of viewer */
2439 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2443 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2444 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2445 if ( theObj->_is_nil() ) {
2446 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2450 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2451 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2453 if( myUseLocalContext == false ) {
2454 /* local context is from DialogBox */
2455 MESSAGE("Error : No local context opened for suppress faces method" << endl ) ;
2459 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2461 int nbSelected = ic->NbSelected();
2462 ListOfID->length(nbSelected);
2464 /* Create a list of indices of faces to be suppressed */
2466 const int SubShapeType = 4 ; /* GEOM::FACE type */
2467 ic->InitSelected(); /* to repositioning at beginning */
2468 while( ic->MoreSelected() ) {
2469 int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
2470 ListOfID[i] = index ;
2475 /* Close local context opened in DialogBox */
2476 ic->CloseLocalContext(aLocalContextId) ;
2477 myUseLocalContext = false ;
2479 /* Here is the main shape */
2480 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2481 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
2483 /* Call geom method that return a list of shells/faces as result of suppress */
2485 listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID );
2487 catch (const SALOME::SALOME_Exception& S_ex) {
2488 QtCatchCorbaException(S_ex);
2491 /* Test list of shells/faces */
2492 if( listGeomShapes->length() < 1 ) {
2496 /* Loop on each object created */
2497 for( int i=0; i<listGeomShapes->length(); i++ ) {
2499 GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ;
2500 TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace );
2506 char* nameG = (char *)malloc(20);
2507 Standard_CString Type;
2508 if ( GetShapeTypeString(S, Type) ) {
2509 aShellOrFace->NameType( Type );
2510 sprintf (nameG, "%s_%d", Type, this->myNbGeom++);
2513 aShellOrFace->NameType( tr("GEOM_SHAPE") );
2514 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2517 /* Display with name */
2518 if( !Display( aShellOrFace, nameG) ) {
2519 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
2524 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2529 //=====================================================================================
2530 // function : OnSuppressHole()
2531 // purpose : To suppress an hole on a shape 'ShapeTopo'.
2532 // : 'ListOfIdEndFace' may be an empty list.
2533 // : This means that hole do not traverse ShapeTopo.
2534 // : Warning : the hole to be suppressed must be defined by one or two single closed wires !
2535 //=====================================================================================
2536 bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR,
2537 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
2538 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
2539 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace )
2541 /* Test the type of viewer */
2542 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2547 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2548 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ;
2550 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2551 Standard_CString type;
2552 GetShapeTypeString(S,type);
2553 aResult->NameType( type );
2555 if ( Display( aResult, "" ) )
2556 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2558 catch (const SALOME::SALOME_Exception& S_ex) {
2559 QtCatchCorbaException(S_ex);
2565 //=====================================================================================
2566 // function : OnSuppressHolesInFaceOrShell()
2567 // purpose : To suppress one or more holes on a face
2568 // : 'ListOfIdWires' contains indices or wires/holes.
2569 //=====================================================================================
2570 bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
2571 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires )
2573 /* Test the type of viewer */
2574 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2579 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2580 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ;
2582 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2583 Standard_CString type;
2584 GetShapeTypeString(S,type);
2585 aResult->NameType( type );
2587 if ( Display( aResult, "") )
2588 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2590 catch (const SALOME::SALOME_Exception& S_ex) {
2591 QtCatchCorbaException(S_ex);
2598 //=======================================================================
2599 // function : activeStudyChanged()
2601 //=======================================================================
2602 void GeometryGUI::activeStudyChanged( QAD_Desktop* parent )
2604 MESSAGE ("GeometryGUI::activeStudyChanged init.")
2605 /* Create or retrieve an object GeomGUI */
2606 GeometryGUI::GetOrCreateGeometryGUI(parent);
2609 if (GeomGUI->myState == CURRENT_SKETCH) {
2610 GeomGUI->mySketcher.Clear();
2611 GeomGUI->ResetState();
2614 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2615 bool ViewOCC = false;
2616 if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
2619 Mb->setItemEnabled( 312, ViewOCC); //Sketch
2620 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
2621 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
2623 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2624 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2626 GeomGUI->EraseSimulationShape() ;
2627 GeomGUI->EmitSignalCloseAllDialogs() ;
2631 // GeomGUI->SetSettings( parent );
2632 // MESSAGE ("GeometryGUI::activeStudyChanged done.")
2637 //=======================================================================
2638 // function : DefineDlgPosition()
2639 // purpose : Define x and y the default position for a dialog box
2640 //=======================================================================
2641 bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
2643 /* Here the position is on the bottom right corner - 10 */
2644 QAD_Desktop* PP = QAD_Application::getDesktop() ;
2645 x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
2646 y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
2650 //=======================================================================
2651 // function : OnGUIEvent() [static]
2652 // purpose : manage all events on GUI
2653 //=======================================================================
2654 bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
2656 /* Create or retrieve an object GeomGUI */
2657 GeometryGUI::GetOrCreateGeometryGUI(parent);
2659 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
2660 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2662 OCCViewer_Viewer3d* v3d;
2663 Handle(AIS_InteractiveContext) ic;
2664 vtkRenderer* Renderer;
2666 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2668 bool ViewOCC = false;
2670 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2671 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2672 ic = v3d->getAISContext();
2674 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2675 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2676 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2678 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2679 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2681 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2682 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2684 // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER,
2685 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2686 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2687 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2689 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2690 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2695 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)
2698 switch (theCommandID)
2701 GeomGUI->OnEditCopy();
2705 GeomGUI->OnEditDelete();
2710 GeomGUI->SetState(111);
2712 GeomGUI->ResetState();
2717 GeomGUI->SetState(112);
2719 GeomGUI->ResetState();
2722 case 113: // IMPORT STEP
2724 GeomGUI->SetState(113);
2726 GeomGUI->ResetState();
2730 case 121: // EXPORT BREP
2732 GeomGUI->SetState(121);
2734 GeomGUI->ResetState();
2738 case 122: // EXPORT IGES
2740 GeomGUI->SetState(122);
2742 GeomGUI->ResetState();
2746 case 123: // EXPORT STEP
2748 GeomGUI->SetState(123);
2750 GeomGUI->ResetState();
2754 case 303: // EXPLODE : use ic
2756 GeomGUI->EmitSignalDeactivateDialog() ;
2757 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2758 GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ;
2762 case 304: // GEOM::EDGE
2764 GeomGUI->EmitSignalDeactivateDialog() ;
2765 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2766 GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ;
2770 case 305: // GEOM::WIRE
2772 GeomGUI->EmitSignalDeactivateDialog() ;
2773 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2774 GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ;
2778 case 306: // GEOM::FACE
2780 GeomGUI->EmitSignalDeactivateDialog() ;
2781 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2782 GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ;
2786 case 308: // GEOM::COMPOUND
2788 GeomGUI->EmitSignalDeactivateDialog() ;
2789 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2790 GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ;
2794 case 309: // SUPPRESS FACES : use ic
2796 GeomGUI->EmitSignalDeactivateDialog() ;
2797 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2798 GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ;
2802 case 314: // SUPPRESS HOLES : use ic
2804 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2805 GeomGUI->EmitSignalDeactivateDialog() ;
2806 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2807 GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ;
2810 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
2816 GeomGUI->EmitSignalDeactivateDialog() ;
2817 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2818 GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ;
2822 case 502: // ORIENTATION
2824 GeomGUI->EmitSignalDeactivateDialog() ;
2825 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2826 GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ;
2830 case 601: // PROPERTIES (Length, surface, volume)
2832 GeomGUI->EmitSignalDeactivateDialog() ;
2833 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2834 GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ;
2838 case 604: // CDG : Center of mass
2840 GeomGUI->EmitSignalDeactivateDialog() ;
2841 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2842 GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ;
2846 case 605: // INERTIA
2848 GeomGUI->EmitSignalDeactivateDialog() ;
2849 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2850 GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ;
2854 case 607: // MAXTOLERANCE
2856 GeomGUI->EmitSignalDeactivateDialog() ;
2857 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2858 GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ;
2864 GeomGUI->EmitSignalDeactivateDialog() ;
2865 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2866 GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ;
2870 case 609: // CHECKSHAPE
2872 GeomGUI->EmitSignalDeactivateDialog() ;
2873 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2874 GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ;
2878 case 701: // SETTINGS - COPY
2881 QMenuItem* item = parent->menuBar()->findItem(701,&pp);
2882 bool check = !pp->isItemChecked(701);
2883 pp->setItemChecked(701,check);
2884 Settings_Copy = check;
2885 QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy );
2889 case 702: // SETTINGS - ADD IN STUDY
2892 QMenuItem* item = parent->menuBar()->findItem(702,&pp);
2893 bool check = !pp->isItemChecked(702);
2894 pp->setItemChecked(702,check);
2895 Settings_AddInStudy = check;
2897 QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy );
2901 case 703: // SETTINGS - SHADING COLOR
2903 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2906 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
2907 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
2908 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
2910 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) {
2911 color = QColor (SCr.toInt(),
2915 Quantity_Color Default = Quantity_Color();
2916 color = QColor ( (int)Default.Red() * 255.0,
2917 (int)Default.Green()* 255.0,
2918 (int)Default.Blue() * 255.0 );
2921 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
2922 if ( c.isValid() ) {
2923 GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0,
2928 AIS_ListOfInteractive List;
2929 ic->DisplayedObjects(List);
2930 AIS_ListOfInteractive List1;
2931 ic->ObjectsInCollector(List1);
2934 AIS_ListIteratorOfListOfInteractive ite(List);
2935 while (ite.More()) {
2936 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
2937 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
2938 aSh->SetShadingColor( GeomGUI->myShadingColor );
2939 ic->Redisplay( aSh, Standard_True, Standard_True);
2944 ic->UpdateCurrentViewer();
2946 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() );
2947 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() );
2948 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() );
2954 case 704: // SETTINGS - ISOS
2956 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2959 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
2960 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
2961 if ( !IsoU.isEmpty() )
2962 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
2965 if ( !IsoV.isEmpty() )
2966 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
2970 GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(),
2971 tr("GEOM_MEN_ISOS"), TRUE );
2972 int UIso = IsoU.toInt();
2973 int VIso = IsoV.toInt();
2975 NbIsosDlg->SpinBoxU->setValue(UIso) ;
2976 NbIsosDlg->SpinBoxV->setValue(VIso) ;
2978 if ( NbIsosDlg->exec() ) {
2979 UIso = NbIsosDlg->SpinBoxU->text().toInt() ;
2980 VIso = NbIsosDlg->SpinBoxV->text().toInt() ;
2982 ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
2983 ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
2984 QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */
2985 QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */
2988 AIS_ListOfInteractive List;
2989 ic->DisplayedObjects(List);
2990 AIS_ListOfInteractive List1;
2991 ic->ObjectsInCollector(List1);
2994 AIS_ListIteratorOfListOfInteractive ite(List);
2996 if ( ic->NbCurrents() )
2997 while (ite.More()) {
2998 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3000 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3001 Handle (AIS_Drawer) CurDrawer;
3002 CurDrawer = aSh->Attributes();
3003 CurDrawer->UIsoAspect()->SetNumber( UIso );
3004 CurDrawer->VIsoAspect()->SetNumber( VIso );
3005 ic->SetLocalAttributes(aSh, CurDrawer);
3010 ic->UpdateCurrentViewer();
3014 case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES
3016 //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
3019 QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
3020 if( step.isEmpty() )
3023 Standard_Boolean res = false ;
3024 double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ;
3026 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ;
3028 /* Emit signal to GeometryGUI_SpinBoxes */
3029 GeomGUI->SignalDefaultStepValueChanged( dd ) ;
3032 parent->putInfo(tr("GEOM_PRP_ABORT"));
3037 case 801: // ADD IN STUDY - POPUP VIEWER
3039 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3040 const SALOME_ListIO& ListSelected = Sel->StoredIObjects();
3041 SALOME_ListIteratorOfListIO It( ListSelected );
3042 for ( ; It.More(); It.Next() ) {
3043 Handle(SALOME_InteractiveObject) IObject = It.Value();
3044 GeomGUI->AddInStudy(true, IObject);
3046 /* Is set on the dialog box */
3047 QApplication::restoreOverrideCursor();
3053 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3054 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3055 for ( ; It.More(); It.Next() ) {
3056 Handle(SALOME_InteractiveObject) IObject = It.Value();
3058 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3059 SALOMEDS::GenericAttribute_var anAttr;
3060 SALOMEDS::AttributeName_var aName;
3061 if ( !obj->_is_nil() ) {
3062 if (obj->FindAttribute(anAttr, "AttributeName")) {
3063 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3065 QString nm = QString( aName->Value() );
3066 nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
3067 if ( !nm.isEmpty() ) {
3068 QApplication::setOverrideCursor( Qt::waitCursor );
3069 GeomGUI->myActiveStudy->renameIObject( IObject, nm );
3070 QApplication::restoreOverrideCursor();
3078 case 903: // DISPLAY OBJECT BROWSER
3080 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3082 QApplication::setOverrideCursor( Qt::waitCursor );
3084 SALOMEDS::SObject_var fatherSF =
3085 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3087 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3088 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3090 for(;It.More();It.Next()) {
3091 Handle(SALOME_InteractiveObject) IObject = It.Value();
3092 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3094 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3096 SALOMEDS::GenericAttribute_var anAttr;
3097 SALOMEDS::AttributeName_var aName;
3098 SALOMEDS::AttributeIOR_var anIOR;
3100 if(myRenderInter->isInViewer(IObject)) {
3101 myRenderInter->Display(IObject);
3105 if ( !obj->_is_nil() ) {
3106 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3107 // this SObject may be GEOM module root SObject
3108 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3109 bool useSubItems = false;
3110 while (anIter->More() && !useSubItems) {
3111 SALOMEDS::SObject_var subobj = anIter->Value();
3112 SALOMEDS::GenericAttribute_var aTmpAttr;
3113 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3117 } else anIter->Next();
3120 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3121 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3122 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3123 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3125 if (obj->FindAttribute(anAttr, "AttributeName")) {
3126 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3128 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3129 vtkActorCollection* theAllActors = theRenderer->GetActors();
3130 theAllActors->InitTraversal();
3131 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3132 Handle(SALOME_InteractiveObject) anIObj;
3133 // don't create new study object if it already exists
3134 bool isDisplayed = false;
3135 while(!(actor==NULL)) {
3136 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3138 if (Gactor->hasIO()) {
3139 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3141 anIObj = Gactor->getIO();
3142 if (!anIObj.IsNull()) myRenderInter->Display(anIObj);
3146 actor=(vtkActor*)(theAllActors->GetNextActor());
3150 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3153 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3154 aStudyBuilder->Addreference(newObj1, obj);
3155 // commit transaction
3158 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
3159 int themode = myRenderInter->GetDisplayMode();
3161 vtkActorCollection* theActors =
3162 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
3163 theActors->InitTraversal();
3164 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
3165 while(!(anActor==NULL)) {
3166 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
3167 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
3168 IO->setEntry(obj->GetID());
3169 GActor->setIO( IO );
3170 GActor->setName( IObject->getName() );
3172 theRenderer->AddActor(GActor);
3174 anActor = (vtkActor*)theActors->GetNextActor();
3178 // next item iteration
3181 anAttr = SALOMEDS::GenericAttribute::_nil();
3182 while (anIter->More() && anAttr->_is_nil()) {
3183 SALOMEDS::SObject_var subobject = anIter->Value();
3184 SALOMEDS::GenericAttribute_var aTmpAttribute;
3185 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3186 anAttr = aTmpAttribute;
3188 } else anIter->Next();
3190 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3196 GeomGUI->myActiveStudy->updateObjBrowser( true );
3197 QApplication::restoreOverrideCursor();
3199 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3200 QApplication::setOverrideCursor( Qt::waitCursor );
3202 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3203 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3204 for(;It.More();It.Next()) {
3205 Handle(SALOME_InteractiveObject) IObject = It.Value();
3207 SALOMEDS::SObject_var fatherSF =
3208 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3209 SALOMEDS::GenericAttribute_var anAttr;
3210 SALOMEDS::AttributeName_var aName;
3211 SALOMEDS::AttributeIOR_var anIOR;
3213 if ( v3d->isInViewer( IObject, true ) ) {
3214 Standard_Boolean found;
3215 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3218 ic->AddOrRemoveCurrentObject(aSh, true);
3222 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3223 if ( !obj->_is_nil() ) {
3224 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3225 // this SObject may be GEOM module root SObject
3226 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3227 bool useSubItems = false;
3228 while (anIter->More() && !useSubItems) {
3229 SALOMEDS::SObject_var subobj = anIter->Value();
3230 SALOMEDS::GenericAttribute_var aTmpAttr;
3231 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3235 } else anIter->Next();
3237 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3238 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3239 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3240 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3241 if (obj->FindAttribute(anAttr, "AttributeName")) {
3242 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3243 // searchin for already displayed objects with the same shape
3244 AIS_ListOfInteractive aDisplayed;
3245 ic->DisplayedObjects(aDisplayed);
3246 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3247 Handle(AIS_Shape) anAISShape;
3248 for(;anIObjects.More();anIObjects.Next()) {
3249 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3250 if (!anAISShape.IsNull()) {
3251 if (anAISShape->Shape().IsSame(Shape)) break;
3252 anAISShape.Nullify();
3255 if (!anAISShape.IsNull()) {
3256 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape);
3260 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3263 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3264 aStudyBuilder->Addreference(newObj1, obj);
3265 // commit transaction
3269 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
3270 aSh->SetShadingColor( GeomGUI->myShadingColor );
3271 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
3274 IO->setEntry(obj->GetID());
3276 aSh->setName( aName->Value() );
3278 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true);
3281 // next item iteration
3284 anAttr=SALOMEDS::GenericAttribute::_nil();
3285 while (anIter->More() && anAttr->_is_nil()) {
3286 SALOMEDS::SObject_var subobject = anIter->Value();
3287 SALOMEDS::GenericAttribute_var aTmpAttribute;
3288 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3289 anAttr = aTmpAttribute;
3291 } else anIter->Next();
3293 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3299 GeomGUI->myActiveStudy->updateObjBrowser( true );
3300 QApplication::restoreOverrideCursor();
3307 GeomGUI->EmitSignalDeactivateDialog() ;
3308 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3309 GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ;
3315 GeomGUI->EmitSignalDeactivateDialog() ;
3316 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3317 GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ;
3321 case 3013: // CIRCLE
3323 GeomGUI->EmitSignalDeactivateDialog() ;
3324 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3325 GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ;
3329 case 3014: // ELLIPSE
3331 GeomGUI->EmitSignalDeactivateDialog() ;
3332 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3333 GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ;
3339 GeomGUI->EmitSignalDeactivateDialog() ;
3340 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3341 GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ;
3345 case 3016: // VECTOR
3347 GeomGUI->EmitSignalDeactivateDialog() ;
3348 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3349 GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ;
3355 GeomGUI->EmitSignalDeactivateDialog() ;
3356 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3357 GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ;
3361 case 3018: // WORKING PLANE
3363 GeomGUI->EmitSignalDeactivateDialog() ;
3364 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3365 GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ;
3369 case 312: // SKETCHER
3371 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
3374 GeomGUI->EmitSignalDeactivateDialog() ;
3376 ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
3378 GeomGUI->mySketcher = Sketch( v3d->getViewer3d() );
3379 GeomGUI->SetState(CURRENT_SKETCH);
3381 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3384 QMenuItem* item = Mb->findItem(10010,&pp);
3385 GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
3386 item = Mb->findItem(10011,&pp);
3387 GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
3388 item = Mb->findItem(10012,&pp);
3389 GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
3390 item = Mb->findItem(10013,&pp);
3391 GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
3392 item = Mb->findItem(10014,&pp);
3393 GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
3395 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3396 item = Mb->findItem(3133,&pp);
3397 pp->setItemChecked(3133,false);
3398 item = Mb->findItem(3134,&pp);
3399 pp->setItemChecked(3134,false);
3405 GeomGUI->EmitSignalDeactivateDialog() ;
3406 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3407 GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ;
3411 case 3022: // CYLINDER
3413 GeomGUI->EmitSignalDeactivateDialog() ;
3414 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3415 GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ;
3419 case 3023: // SPHERE
3421 GeomGUI->EmitSignalDeactivateDialog() ;
3422 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3423 GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ;
3429 GeomGUI->EmitSignalDeactivateDialog() ;
3430 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3431 GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ;
3437 GeomGUI->EmitSignalDeactivateDialog() ;
3438 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3439 GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ;
3448 case 3133: // sketcher
3450 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3452 QMenuItem* item = Mb->findItem(3133,&pp);
3453 pp->setItemChecked(3133,!pp->isItemChecked(3133));
3454 if (pp->isItemChecked(3133) == true)
3455 GeomGUI->mySketcher.SetTransitionStatus(TANGENT);
3457 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3459 pp->setItemChecked(3134,false);
3463 case 3134: // sketcher
3465 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3467 QMenuItem* item = Mb->findItem(3134,&pp);
3468 pp->setItemChecked(3134,!pp->isItemChecked(3134));
3469 if (pp->isItemChecked(3134) == true)
3470 GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR);
3472 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3474 pp->setItemChecked(3133,false);
3480 GeomGUI->EmitSignalDeactivateDialog() ;
3481 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3482 GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ;
3486 case 4012: // COMMON
3488 GeomGUI->EmitSignalDeactivateDialog() ;
3489 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3490 GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ;
3496 GeomGUI->EmitSignalDeactivateDialog() ;
3497 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3498 GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ;
3502 case 4014: // SECTION
3504 GeomGUI->EmitSignalDeactivateDialog() ;
3505 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3506 GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ;
3510 case 4021: // TRANSLATION
3512 GeomGUI->EmitSignalDeactivateDialog() ;
3513 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3514 GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ;
3518 case 4022: // ROTATION
3520 GeomGUI->EmitSignalDeactivateDialog() ;
3521 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3522 GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ;
3526 case 4030: // MULTI TRANSLATION
3528 GeomGUI->EmitSignalDeactivateDialog() ;
3529 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3530 GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ;
3534 case 4040: // MULTI ROTATION
3536 GeomGUI->EmitSignalDeactivateDialog() ;
3537 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3538 GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ;
3542 case 4023: // MIRROR
3544 GeomGUI->EmitSignalDeactivateDialog() ;
3545 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3546 GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ;
3552 GeomGUI->EmitSignalDeactivateDialog() ;
3553 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3554 GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ;
3558 case 4025: // PARTITION
3560 GeomGUI->EmitSignalDeactivateDialog() ;
3561 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3562 GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ;
3566 case 4026: // ARCHIMEDE
3568 GeomGUI->EmitSignalDeactivateDialog() ;
3569 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3570 GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ;
3574 case 4027: // FILLET
3576 GeomGUI->EmitSignalDeactivateDialog() ;
3577 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3578 GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ;
3582 case 4028: // CHAMFER
3584 GeomGUI->EmitSignalDeactivateDialog() ;
3585 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3586 GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ;
3592 GeomGUI->EmitSignalDeactivateDialog() ;
3593 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3594 GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ;
3600 GeomGUI->EmitSignalDeactivateDialog() ;
3601 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3602 GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ;
3606 case 4033: // FILLING
3608 GeomGUI->EmitSignalDeactivateDialog() ;
3609 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3610 GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ;
3616 GeomGUI->EmitSignalDeactivateDialog() ;
3617 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3618 GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ;
3622 case 5001: // CHECK GEOMETRY
3624 QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor();
3625 PyEditor->setText("from GEOM_usinggeom import *\n");
3626 PyEditor->setText(">>> ");
3627 PyEditor->handleReturn();
3631 case 6021: // SHADING - WIREFRAME
3633 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3634 VTKViewer_RenderWindowInteractor* myRenderInter=
3635 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3637 QApplication::setOverrideCursor(waitCursor);
3639 int themode = myRenderInter->GetDisplayMode();
3641 myRenderInter->SetDisplayMode(1);
3642 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3644 myRenderInter->SetDisplayMode(0);
3645 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3648 QApplication::restoreOverrideCursor();
3650 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3651 AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode();
3652 QApplication::setOverrideCursor( Qt::waitCursor );
3653 AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
3655 AIS_ListOfInteractive List;
3656 ic->DisplayedObjects(List);
3657 AIS_ListOfInteractive List1;
3658 ic->ObjectsInCollector(List1);
3661 AIS_ListIteratorOfListOfInteractive ite(List);
3662 while (ite.More()) {
3663 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3664 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3665 ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
3670 ic->SetDisplayMode( newmode, Standard_False);
3672 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3674 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3676 QApplication::restoreOverrideCursor();
3681 case 6022: // DISPLAY ALL
3683 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3685 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll();
3686 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
3687 GeomGUI->OnDisplayAll();
3691 case 6023: // DISPLAY ONLY
3692 case 8023: // DISPLAY ONLY - POPUP VIEWER
3694 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3696 GeomGUI->OnVTKDisplayOnly();
3698 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
3699 GeomGUI->OnDisplayOnly();
3703 case 6024: // ERASE ALL
3705 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3707 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
3709 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3710 ic->EraseAll(Standard_True, Standard_False);
3711 ic->Display(v3d->getTrihedron());
3714 //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3715 //NRI Sel->ClearInteractiveObjects();
3719 case 6025 : // ERASE ONLY
3720 case 8022 : // ERASE - POPUP VIEWER
3722 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3723 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3725 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3726 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3727 Handle(SALOME_InteractiveObject) anIObject;
3728 for(;It.More();It.Next()) {
3729 anIObject = It.Value();
3730 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3732 if(myRenderInter->isInViewer(anIObject)) {
3733 myRenderInter->Erase(anIObject);
3735 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3736 SALOMEDS::GenericAttribute_var anAttr;
3737 SALOMEDS::AttributeIOR_var anIOR;
3738 if ( !obj->_is_nil() ) {
3739 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3740 // this SObject may be GEOM module root SObject
3741 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3742 bool useSubItems = false;
3743 while (anIter->More() && !useSubItems) {
3744 SALOMEDS::SObject_var subobj = anIter->Value();
3745 SALOMEDS::GenericAttribute_var aTmpAttr;
3746 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3750 } else anIter->Next();
3753 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3754 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3755 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3756 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3757 if (obj->FindAttribute(anAttr, "AttributeName")) {
3758 // searchin for already displayed objects with the same shape
3759 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3760 vtkActorCollection* theAllActors = theRenderer->GetActors();
3761 theAllActors->InitTraversal();
3762 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3763 Handle(SALOME_InteractiveObject) anIObj;
3764 // don't create new study object if it already exists
3765 bool isDisplayed = false;
3766 while(!(actor==NULL)) {
3767 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3769 if (Gactor->hasIO()) {
3770 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3772 anIObj = Gactor->getIO();
3773 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
3777 actor=(vtkActor*)(theAllActors->GetNextActor());
3782 anAttr=SALOMEDS::GenericAttribute::_nil();
3783 while (anIter->More() && anAttr->_is_nil()) {
3784 SALOMEDS::SObject_var subobject = anIter->Value();
3785 SALOMEDS::GenericAttribute_var aTmpAttribute;
3786 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3787 anAttr = aTmpAttribute;
3789 } else anIter->Next();
3791 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3797 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3798 // for(;It.More();It.Next()) {
3799 // Handle(SALOME_InteractiveObject) IOS = It.Value();
3800 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
3802 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3804 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3805 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3806 Handle(SALOME_InteractiveObject) anIObject;
3807 for(;It.More();It.Next()) {
3808 anIObject = It.Value();
3809 if ( v3d->isInViewer( anIObject, true ) ) {
3810 Standard_Boolean found;
3811 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
3814 ic->AddOrRemoveCurrentObject(aSh, true);
3817 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3818 SALOMEDS::GenericAttribute_var anAttr;
3819 SALOMEDS::AttributeIOR_var anIOR;
3820 if ( !obj->_is_nil() ) {
3821 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3822 // this SObject may be GEOM module root SObject
3823 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3824 bool useSubItems = false;
3825 while (anIter->More() && !useSubItems) {
3826 SALOMEDS::SObject_var subobj = anIter->Value();
3827 SALOMEDS::GenericAttribute_var aTmpAttr;
3828 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3832 } else anIter->Next();
3835 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3836 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3837 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3838 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3839 if (obj->FindAttribute(anAttr, "AttributeName")) {
3840 // searchin for already displayed objects with the same shape
3841 AIS_ListOfInteractive aDisplayed;
3842 ic->DisplayedObjects(aDisplayed);
3843 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3844 Handle(AIS_Shape) anAISShape;
3845 for(;anIObjects.More();anIObjects.Next()) {
3846 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3847 if (!anAISShape.IsNull()) {
3848 if (anAISShape->Shape().IsSame(Shape)) break;
3849 anAISShape.Nullify();
3852 if (!anAISShape.IsNull()) {
3853 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
3858 anAttr=SALOMEDS::GenericAttribute::_nil();
3859 while (anIter->More() && anAttr->_is_nil()) {
3860 SALOMEDS::SObject_var subobject = anIter->Value();
3861 SALOMEDS::GenericAttribute_var aTmpAttribute;
3862 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3863 anAttr = aTmpAttribute;
3865 } else anIter->Next();
3867 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3874 Sel->ClearIObjects();
3879 case 6060: // BOUNDING BOX
3881 GeomGUI->EmitSignalDeactivateDialog() ;
3882 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3883 GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ;
3887 case 6061: // MIN DISTANCE
3889 GeomGUI->EmitSignalDeactivateDialog() ;
3890 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3891 GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ;
3895 case 8021: // WIREFRAME-SHADING
3897 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3899 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3901 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3902 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3904 QApplication::setOverrideCursor( Qt::waitCursor );
3905 for(;It.More();It.Next()) {
3906 Handle(SALOME_InteractiveObject) IOS = It.Value();
3907 myRenderInter->SwitchRepresentation(IOS, false);
3909 myRenderInter->Render();
3910 QApplication::restoreOverrideCursor();
3912 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3913 QApplication::setOverrideCursor( Qt::waitCursor );
3914 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3915 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3916 for(;It.More();It.Next()) {
3917 Handle(SALOME_InteractiveObject) IObject = It.Value();
3918 Standard_Boolean found;
3919 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3920 if (!Shape.IsNull()) {
3921 AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode();
3923 mode = ( AIS_DisplayMode )ic->DisplayMode();
3925 QApplication::setOverrideCursor( Qt::waitCursor );
3926 ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
3928 QApplication::restoreOverrideCursor();
3930 ic->UpdateCurrentViewer();
3932 QApplication::restoreOverrideCursor();
3936 case 8031: // COLOR - POPUP VIEWER
3938 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3940 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3942 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3943 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3945 Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject();
3946 if(!FirstIOS.IsNull()) {
3948 QColor initcolor = myRenderInter->GetColor(FirstIOS);
3950 QColor c = QColorDialog::getColor( initcolor,
3951 QAD_Application::getDesktop() );
3953 if ( c.isValid() ) {
3954 QApplication::setOverrideCursor( Qt::waitCursor );
3955 for(;It.More();It.Next()) {
3956 Handle(SALOME_InteractiveObject) IOS = It.Value();
3957 myRenderInter->SetColor(IOS,c);
3960 QApplication::restoreOverrideCursor();
3963 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3964 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3965 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
3966 Standard_Boolean found;
3967 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true);
3969 Quantity_Color CSFColor;
3970 Shape->Color( CSFColor );
3972 QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0,
3973 CSFColor.Green()* 255.0,
3974 CSFColor.Blue() * 255.0 ),
3975 QAD_Application::getDesktop() );
3977 if ( c.isValid() ) {
3978 CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
3979 QApplication::setOverrideCursor( Qt::waitCursor );
3981 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3982 for(;It.More();It.Next()) {
3983 Handle(SALOME_InteractiveObject) IObject = It.Value();
3984 Standard_Boolean found;
3985 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
3987 Shape->SetColor ( CSFColor );
3988 Shape->SetShadingColor ( CSFColor );
3994 QApplication::restoreOverrideCursor();
3998 case 8032: // TRANSPARENCY - POPUP VIEWER
4000 GeomGUI->EmitSignalDeactivateDialog() ;
4001 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4002 GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ;
4006 case 8033: // ISOS - POPUP VIEWER
4008 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4012 if ( ic->MoreCurrent() ) {
4013 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
4014 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
4015 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
4017 if ( !IsoU.isEmpty() )
4018 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
4021 if ( !IsoV.isEmpty() )
4022 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
4026 GeometryGUI_NbIsosDlg * NbIsosDlg =
4027 new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE );
4029 NbIsosDlg->SpinBoxU->setValue(IsoU.toInt());
4030 NbIsosDlg->SpinBoxV->setValue(IsoV.toInt());
4032 if ( NbIsosDlg->exec() ) {
4033 QApplication::setOverrideCursor( Qt::waitCursor );
4034 for ( ; ic->MoreCurrent (); ic->NextCurrent () ) {
4035 Handle (AIS_Drawer) CurDrawer;
4037 CurDrawer = ic->Current()->Attributes();
4038 CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() );
4039 CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() );
4041 ic->SetLocalAttributes(CurObject, CurDrawer);
4042 ic->Redisplay(CurObject);
4047 QApplication::restoreOverrideCursor();
4051 case 9022 : // ERASE - OBJBROSER POPUP
4053 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4054 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
4056 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4057 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4058 Handle(SALOME_InteractiveObject) anIObject;
4059 for(;It.More();It.Next()) {
4060 anIObject = It.Value();
4061 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4063 // Handle(SALOME_InteractiveObject) IObject;
4064 if(myRenderInter->isInViewer(anIObject)) {
4065 myRenderInter->Erase(anIObject);
4067 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4068 SALOMEDS::GenericAttribute_var anAttr;
4069 SALOMEDS::AttributeIOR_var anIOR;
4070 if ( !obj->_is_nil() ) {
4071 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4072 // this SObject may be GEOM module root SObject
4073 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4074 bool useSubItems = false;
4075 while (anIter->More() && !useSubItems) {
4076 SALOMEDS::SObject_var subobj = anIter->Value();
4077 SALOMEDS::GenericAttribute_var aTmpAttr;
4078 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4082 } else anIter->Next();
4085 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4086 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4087 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4088 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4089 if (obj->FindAttribute(anAttr, "AttributeName")) {
4090 // searchin for already displayed objects with the same shape
4091 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4092 vtkActorCollection* theAllActors = theRenderer->GetActors();
4093 theAllActors->InitTraversal();
4094 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
4095 Handle(SALOME_InteractiveObject) anIObj;
4096 // don't create new study object if it already exists
4097 bool isDisplayed = false;
4098 while(!(actor==NULL)) {
4099 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
4101 if (Gactor->hasIO()) {
4102 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
4104 anIObj = Gactor->getIO();
4105 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
4109 actor=(vtkActor*)(theAllActors->GetNextActor());
4114 anAttr=SALOMEDS::GenericAttribute::_nil();
4115 while (anIter->More() && anAttr->_is_nil()) {
4116 SALOMEDS::SObject_var subobject = anIter->Value();
4117 SALOMEDS::GenericAttribute_var aTmpAttribute;
4118 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4119 anAttr = aTmpAttribute;
4121 } else anIter->Next();
4123 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4128 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4129 // for(;It.More();It.Next()) {
4130 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4131 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4133 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4134 // for(;It.More();It.Next()) {
4135 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4136 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4139 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
4141 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4142 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4143 Handle(SALOME_InteractiveObject) anIObject;
4144 for(;It.More();It.Next()) {
4145 anIObject = It.Value();
4146 if ( v3d->isInViewer( anIObject, true ) ) {
4147 Standard_Boolean found;
4148 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
4151 ic->AddOrRemoveCurrentObject(aSh, true);
4154 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4155 SALOMEDS::GenericAttribute_var anAttr;
4156 SALOMEDS::AttributeIOR_var anIOR;
4157 if ( !obj->_is_nil() ) {
4158 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4159 // this SObject may be GEOM module root SObject
4160 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4161 bool useSubItems = false;
4162 while (anIter->More() && !useSubItems) {
4163 SALOMEDS::SObject_var subobj = anIter->Value();
4164 SALOMEDS::GenericAttribute_var aTmpAttr;
4165 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4169 } else anIter->Next();
4172 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4173 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4174 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4175 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4176 if (obj->FindAttribute(anAttr, "AttributeName")) {
4177 // searchin for already displayed objects with the same shape
4178 AIS_ListOfInteractive aDisplayed;
4179 ic->DisplayedObjects(aDisplayed);
4180 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
4181 Handle(AIS_Shape) anAISShape;
4182 for(;anIObjects.More();anIObjects.Next()) {
4183 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
4184 if (!anAISShape.IsNull()) {
4185 if (anAISShape->Shape().IsSame(Shape)) break;
4186 anAISShape.Nullify();
4189 if (!anAISShape.IsNull()) {
4190 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
4195 anAttr=SALOMEDS::GenericAttribute::_nil();
4196 while (anIter->More() && anAttr->_is_nil()) {
4197 SALOMEDS::SObject_var subobject = anIter->Value();
4198 SALOMEDS::GenericAttribute_var aTmpAttribute;
4199 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4200 anAttr = aTmpAttribute;
4202 } else anIter->Next();
4204 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4210 // QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC();
4211 // Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4212 // myContext->EraseSelected();
4215 Sel->ClearIObjects();
4219 case 9023 : // DISPLAY ONLY - OBJBROSER POPUP
4221 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
4222 GeomGUI->OnVTKDisplayOnly();
4223 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
4224 GeomGUI->OnDisplayOnly();
4228 case 9024 : // OPEN - OBJBROSER POPUP
4230 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4231 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4232 Handle(SALOME_InteractiveObject) anIObject;
4233 for(;It.More();It.Next()) {
4234 anIObject = It.Value();
4235 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4236 SALOMEDS::AttributePersistentRef_var aPersist;
4237 SALOMEDS::AttributeIOR_var anIOR;
4238 if ( !obj->_is_nil() ) {
4239 // this SObject may be GEOM module root SObject
4240 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4241 SALOMEDS::GenericAttribute_var anAttr;
4242 bool useSubItems = false;
4243 while (anIter->More() && !useSubItems) {
4244 SALOMEDS::SObject_var subobj = anIter->Value();
4245 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
4249 else anIter->Next();
4251 obj->FindAttribute(anAttr, "AttributePersistentRef");
4253 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4254 if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
4255 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
4257 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","GEOM");
4258 if (!CORBA::is_nil(comp)) {
4259 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
4262 SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder();
4263 aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver);
4266 MESSAGE("Component is null");
4271 obj = anIter->Value();
4272 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4279 case 10000 : // SKETCH Segment
4281 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4283 GeomGUI->OnSketchSegment();
4286 case 10001 : // SKETCH Arc
4288 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4290 GeomGUI->OnSketchArc();
4293 case 10002 : // SKETCH Set Angle
4295 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4297 GeomGUI->OnSketchSetAngle();
4300 case 10003 : // SKETCH Set X
4302 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4304 GeomGUI->OnSketchSetx();
4307 case 10004 : // SKETCH Set Y
4309 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4311 GeomGUI->OnSketchSety();
4314 case 10006 : // SKETCH Delete
4316 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4318 GeomGUI->OnSketchDelete();
4321 case 10007 : // SKETCH End
4323 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4325 GeomGUI->OnSketchEnd();
4328 case 10008 : // SKETCH Close
4330 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4332 GeomGUI->OnSketchClose();
4335 case 10010 : // SKETCH OptionsOnofflengthdimension
4337 GeomGUI->OnSketchOptionsOnofflengthdimension();
4340 case 10011 : // SKETCH OptionsOnoffangledimension
4342 GeomGUI->OnSketchOptionsOnoffangledimension();
4345 case 10012 : // SKETCH OptionsOnoffradiusdimension
4347 GeomGUI->OnSketchOptionsOnoffradiusdimension();
4350 case 10013 : // SKETCH OptionsOnoffxdimension
4352 GeomGUI->OnSketchOptionsOnoffxdimension();
4355 case 10014 : // SKETCH OptionsOnoffydimension
4357 GeomGUI->OnSketchOptionsOnoffydimension();
4363 parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) );
4371 //=======================================================================
4372 // function : ConvertClickToPoint()
4373 // purpose : Returns the point clicked in 3D view
4374 //=======================================================================
4375 gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x,
4377 Handle(V3d_View) aView )
4379 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
4380 aView->Eye(XEye, YEye, ZEye);
4382 aView->At(XAt, YAt, ZAt);
4383 gp_Pnt EyePoint(XEye, YEye, ZEye);
4384 gp_Pnt AtPoint(XAt, YAt, ZAt);
4386 gp_Vec EyeVector(EyePoint, AtPoint);
4387 gp_Dir EyeDir(EyeVector);
4389 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
4390 Standard_Real X, Y, Z;
4391 aView->Convert(x, y, X, Y, Z);
4392 gp_Pnt ConvertedPoint(X, Y, Z);
4394 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint);
4395 gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
4396 ConvertedPointOnPlane.Y(),
4404 //==================================================================================
4405 // function : 0nMousePress()
4406 // purpose : [static] manage mouse events
4407 //==================================================================================
4408 bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4410 MESSAGE ( "GeometryGUI::OnMousePress")
4411 GeometryGUI::GetOrCreateGeometryGUI(parent);
4413 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4416 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4417 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4418 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4420 /* Get the clicked or selected point */
4423 if ( GeomGUI->myState == CURRENT_SKETCH) {
4424 GeomGUI->mySketcher.ValidateEdge();
4425 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
4426 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
4428 QMenuItem* item = Mb->findItem(313,&pp);
4429 pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS
4431 } else if( GeomGUI->myState == POINT_METHOD ) {
4433 GeomGUI->EraseSimulationShape() ;
4434 GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ;
4436 if ( DialogPt->UseLocalContext() ) {
4438 if ( pe->state() == Qt::ShiftButton )
4439 v3d->getAISSelector()->shiftSelect(); /* Append selection */
4441 v3d->getAISSelector()->select(); /* New selection */
4443 if ( ic->MoreSelected() ) {
4444 thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) );
4447 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4450 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4452 if( DialogPt != 0 ) {
4453 DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */
4456 // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ;
4457 GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
4465 //=======================================================================
4466 // function : OnMouseMove()
4467 // purpose : [static] manage mouse events
4468 //=======================================================================
4469 bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4471 GeometryGUI::GetOrCreateGeometryGUI(parent);
4473 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4476 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4477 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4478 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4480 if ( GeomGUI->myState == CURRENT_SKETCH)
4481 GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
4487 //================================================================================
4488 // function : SetDisplayedObjectList()
4490 //================================================================================
4491 void GeometryGUI::SetDisplayedObjectList()
4493 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4496 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4497 ListDisplayedObject.Clear();
4499 Handle (AIS_InteractiveContext) aContext = v3d->getAISContext();
4500 aContext->DisplayedObjects( ListDisplayedObject );
4505 //=====================================================================================
4506 // function : OnDisplayAll()
4508 //=====================================================================================
4509 void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
4511 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4514 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4515 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4517 myContext->Display(v3d->getTrihedron());
4519 if ( !onlyPreviousDisplayedObject ) {
4520 AIS_ListOfInteractive List1;
4521 myContext->ObjectsInCollector(List1);
4522 AIS_ListIteratorOfListOfInteractive ite1(List1);
4523 while (ite1.More()) {
4524 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4525 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4526 if ( aSh->hasIO() ) {
4527 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4528 if ( v3d->isInViewer(GIO, true) ) {
4529 myContext->Display(aSh);
4536 AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject);
4537 while (ite.More()) {
4538 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4539 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4540 if ( aSh->hasIO() ) {
4541 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4542 if ( v3d->isInViewer(GIO,true) ) {
4543 myContext->Display(aSh);
4555 //=====================================================================================
4556 // function : OnVTKDisplayOnly()
4558 //=====================================================================================
4559 void GeometryGUI::OnVTKDisplayOnly()
4562 // Erase all not selected actors
4564 QApplication::setOverrideCursor( Qt::waitCursor );
4566 vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4567 vtkActorCollection* theActors = aren->GetActors();
4568 theActors->InitTraversal();
4569 vtkActor *ac = theActors->GetNextActor();
4570 while(!(ac==NULL)) {
4571 if ( ac->IsA("SALOME_Actor") ) {
4572 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
4573 if(!anActor->isHighlighted()) anActor->VisibilityOff();
4575 ac = theActors->GetNextActor();
4578 // Display selection
4579 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4580 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4581 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
4582 SALOMEDS::GenericAttribute_var anAttr;
4583 SALOMEDS::AttributeName_var aName;
4584 SALOMEDS::AttributeIOR_var anIOR;
4586 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4587 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4589 for(;It.More();It.Next()) {
4590 Handle(SALOME_InteractiveObject) IObject = It.Value();
4591 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4593 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4595 if(myRenderInter->isInViewer(IObject)) {
4596 myRenderInter->Display(IObject);
4600 if ( !obj->_is_nil() ) {
4601 if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
4603 // If selected object contains displayable subobjects, then do nothing
4604 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4605 SALOMEDS::GenericAttribute_var aTmpAttr;
4607 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4608 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4609 if (CORBA::is_nil(aShape)) continue;
4610 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4612 if (obj->FindAttribute(anAttr, "AttributeName")) {
4613 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4615 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
4618 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4619 aStudyBuilder->Addreference(newObj1, obj);
4620 // commit transaction
4623 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4624 int themode = myRenderInter->GetDisplayMode();
4625 vtkActorCollection* theActors =
4626 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
4627 theActors->InitTraversal();
4628 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
4629 while(!(anActor==NULL)) {
4630 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
4631 GActor->setIO( IObject );
4632 GActor->setName( IObject->getName() );
4634 theRenderer->AddActor(GActor);
4635 vtkRenderWindow *renWin
4636 = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
4638 anActor = (vtkActor*)theActors->GetNextActor();
4644 GeomGUI->myActiveStudy->updateObjBrowser( true );
4645 QApplication::restoreOverrideCursor();
4650 //=====================================================================================
4651 // function : OnDisplayOnly()
4653 //=====================================================================================
4654 void GeometryGUI::OnDisplayOnly()
4656 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4659 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4660 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4661 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4663 AIS_ListOfInteractive List;
4664 ic->DisplayedObjects(List);
4665 AIS_ListIteratorOfListOfInteractive ite(List);
4666 while (ite.More()) {
4667 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4668 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4669 if (!ic->IsSelected( aSh )) {
4670 ic->Erase( aSh, Standard_True, Standard_True );
4676 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4677 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4679 SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
4680 for(;It1.More();It1.Next()) {
4681 Handle(SALOME_InteractiveObject) IObject = It1.Value();
4684 SALOMEDS::SObject_var fatherSF =
4685 aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
4686 if ( v3d->isInViewer( IObject, true ) ) {
4687 AIS_ListOfInteractive List1;
4688 ic->ObjectsInCollector(List1);
4689 AIS_ListIteratorOfListOfInteractive ite1(List1);
4690 while (ite1.More()) {
4691 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4692 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4693 if ( aSh->hasIO() ) {
4694 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4695 if ( IObject->isSame( GIO ) ) {
4697 ic->AddOrRemoveCurrentObject(aSh, true);
4705 if ( IObject->hasEntry() ) {
4706 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4707 SALOMEDS::GenericAttribute_var anAttr;
4708 SALOMEDS::AttributeName_var aName;
4709 SALOMEDS::AttributeIOR_var anIOR;
4710 if ( !obj->_is_nil() ) {
4711 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
4712 // this SObject may be GEOM module root SObject
4714 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4715 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
4716 if (CORBA::is_nil(aShape)) continue;
4717 TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape);
4719 if (obj->FindAttribute(anAttr, "AttributeName")) {
4720 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4722 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4725 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4726 aStudyBuilder->Addreference(newObj1, obj);
4727 // commit transaction
4731 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
4732 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
4734 IO->setEntry(obj->GetID());
4736 aSh->setName( aName->Value() );
4738 ic->AddOrRemoveCurrentObject(aSh, true);
4747 //===============================================================================
4748 // function : OnEditDelete()
4750 //===============================================================================
4751 void GeometryGUI::OnEditDelete()
4753 if ( QAD_MessageBox::warn2
4754 ( QAD_Application::getDesktop(),
4755 tr ("GEOM_WRN_WARNING"),
4756 tr ("GEOM_REALLY_DELETE"),
4757 tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 )
4760 int nbSf = myActiveStudy->getStudyFramesCount();
4762 Standard_Boolean found;
4763 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4764 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4765 SALOMEDS::GenericAttribute_var anAttr;
4766 SALOMEDS::AttributeIOR_var anIOR;
4768 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4769 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4770 for(;It.More();It.Next()) {
4771 Handle(SALOME_InteractiveObject) IObject = It.Value();
4772 if ( IObject->hasEntry() ) {
4773 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
4774 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
4776 /* Erase child graphical objects */
4777 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
4778 for (; it->More();it->Next()) {
4779 SALOMEDS::SObject_var CSO= it->Value();
4780 if (CSO->FindAttribute(anAttr, "AttributeIOR") ) {
4781 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4782 /* Delete child(s) shape in Client : */
4783 const TCollection_AsciiString ASCior(anIOR->Value()) ;
4784 ShapeReader.RemoveShapeFromBuffer( ASCior ) ;
4786 for ( int i = 0; i < nbSf; i++ ) {
4787 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4788 if ( sf->getTypeView() == VIEW_OCC ) {
4789 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4790 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4791 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found );
4793 myContext->Erase( Result, true, false );
4794 } else if ( sf->getTypeView() == VIEW_VTK ) {
4795 //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
4796 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4797 GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found );
4799 //Renderer->RemoveActor(ac);
4801 myRenderInter->Remove( ac->getIO() );
4808 /* Erase main graphical object */
4809 for ( int i = 0; i < nbSf; i++ ) {
4810 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4811 if ( sf->getTypeView() == VIEW_OCC ) {
4812 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4813 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4814 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found );
4816 myContext->Erase( Result, true, false );
4817 } else if ( sf->getTypeView() == VIEW_VTK ) {
4818 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4819 myRenderInter->Remove( IObject );
4823 /* Delete main shape in Client : */
4824 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
4825 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4826 const TCollection_AsciiString ASCIor(anIOR->Value()) ;
4827 ShapeReader.RemoveShapeFromBuffer( ASCIor ) ;
4830 /* Erase objects in Study */
4831 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4832 if ( !obj->_is_nil() ) {
4833 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4835 aStudyBuilder->RemoveObject(obj);
4839 } /* IObject->hasEntry() */
4842 /* Clear any previous selection */
4843 Sel->ClearIObjects() ;
4844 myActiveStudy->updateObjBrowser();
4848 //==============================================================================
4849 // function : OnEditCopy()
4851 //==============================================================================
4852 void GeometryGUI::OnEditCopy()
4854 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4855 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
4857 const SALOME_ListIO& List = Sel->StoredIObjects();
4859 GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR);
4861 Sel->ClearIObjects();
4863 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
4864 GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]);
4866 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ;
4867 result->NameType( aShapeInit->NameType() );
4868 this->Display(result);
4870 catch (const SALOME::SALOME_Exception& S_ex) {
4871 QtCatchCorbaException(S_ex);
4875 myDesktop->putInfo(tr("GEOM_PRP_READY"));
4880 //=====================================================================================
4881 // function : OnKeyPress()
4882 // purpose : [static]
4883 //=====================================================================================
4884 bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4886 GeometryGUI::GetOrCreateGeometryGUI(parent);
4888 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4896 //=====================================================================================
4897 // function : DisplaySimulationShape()
4898 // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
4899 //=====================================================================================
4900 void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S)
4905 //NRI DEBUG : 14/02/2002
4906 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4909 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4910 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4913 /* erase any previous */
4914 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4915 ic->ClearPrs( this->mySimulationShape );
4916 this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ;
4917 this->mySimulationShape->Set( S ) ;
4918 this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ;
4919 ic->Deactivate( this->mySimulationShape );
4920 ic->Display( this->mySimulationShape, Standard_False );
4921 ic->UpdateCurrentViewer();
4923 catch(Standard_Failure) {
4924 MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ;
4926 this->mySimulationShape->UnsetColor() ;
4932 //==================================================================================
4933 // function : EraseSimulationShape()
4934 // purpose : Clears the display of 'mySimulationShape' a pure graphical shape
4935 //==================================================================================
4936 void GeometryGUI::EraseSimulationShape()
4938 int count = myActiveStudy->getStudyFramesCount();
4939 for ( int i = 0; i < count; i++ ) {
4940 if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
4941 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
4942 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4943 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4944 ic->ClearPrs( this->mySimulationShape );
4945 ic->UpdateCurrentViewer();
4947 } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK
4950 // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " )
4955 //=====================================================================================
4956 // function : Import
4957 // purpose : BRep, Iges, Step
4958 //=====================================================================================
4959 bool GeometryGUI::Import( )
4961 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4962 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4964 GEOM::GEOM_Shape_var aShape;
4966 QStringList filtersList ;
4968 switch ( GeomGUI->myState )
4970 case 111 : // Import BREP
4972 filtersList.append( tr("GEOM_MEN_IMPORT_BREP") );
4973 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4975 file = QAD_FileDlg::getFileName(myDesktop,
4978 tr("GEOM_MEN_IMPORT"),
4980 if ( !file.isEmpty() ) {
4981 QApplication::setOverrideCursor( Qt::waitCursor );
4983 aShape = myComponentGeom->ImportBREP( file.latin1() );
4985 catch (const SALOME::SALOME_Exception& S_ex) {
4986 QtCatchCorbaException(S_ex);
4991 case 112 : // Import IGES
4993 filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ;
4994 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4996 file = QAD_FileDlg::getFileName(myDesktop,
4999 tr("GEOM_MEN_IMPORT"),
5001 if ( !file.isEmpty() ) {
5002 QApplication::setOverrideCursor( Qt::waitCursor );
5004 aShape = myComponentGeom->ImportIGES( file.latin1() );
5006 catch (const SALOME::SALOME_Exception& S_ex) {
5007 QtCatchCorbaException(S_ex);
5012 case 113 : // Import STEP
5014 filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ;
5015 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
5017 file = QAD_FileDlg::getFileName(myDesktop,
5020 tr("GEOM_MEN_IMPORT"),
5022 if ( !file.isEmpty() ) {
5023 QApplication::setOverrideCursor( Qt::waitCursor );
5025 aShape = myComponentGeom->ImportSTEP( file.latin1() );
5027 catch (const SALOME::SALOME_Exception& S_ex) {
5028 QtCatchCorbaException(S_ex);
5035 if ( !file.isEmpty() ) {
5036 myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) );
5038 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5039 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry());
5040 SALOMEDS::GenericAttribute_var anAttr;
5041 SALOMEDS::AttributeName_var aName;
5042 SALOMEDS::AttributePixMap_var aPixmap;
5043 int aLocked = false;
5044 if (father->_is_nil()) {
5045 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5047 aLocked = aStudy->GetProperties()->IsLocked();
5048 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5049 father = aStudyBuilder->NewComponent("GEOM");
5050 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5051 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5052 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5053 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5054 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5055 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5056 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5057 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5060 // if (aLocked) return false;
5061 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5062 father->ComponentIOR( Fatherior );
5064 QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++);
5066 if ( Display ( aShape, strdup(nameShape.latin1())) ) {
5067 myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) );
5068 myDesktop->putInfo( tr("GEOM_PRP_READY"));
5071 QApplication::restoreOverrideCursor();
5076 //=====================================================================================
5077 // function : Export
5078 // purpose : BRep, Iges, Step
5079 //=====================================================================================
5080 bool GeometryGUI::Export( )
5082 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5083 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5085 GEOM::GEOM_Shape_var aShape;
5087 static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"),
5088 tr("GEOM_MEN_IMPORT_IGES"),
5089 tr("GEOM_MEN_IMPORT_STEP") };
5091 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
5092 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5094 switch ( GeomGUI->myState )
5098 for(;It.More();It.Next()) {
5099 QApplication::restoreOverrideCursor();
5100 Handle(SALOME_InteractiveObject) IObject = It.Value();
5101 Standard_Boolean found;
5102 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5103 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5105 QString file = QAD_FileDlg::getFileName(myDesktop,
5106 QString( IObject->getName() ) + ".brep",
5107 tr("GEOM_MEN_IMPORT_BREP"),
5108 tr("GEOM_MEN_EXPORT"),
5110 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5111 QApplication::setOverrideCursor( Qt::waitCursor );
5112 // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) );
5114 GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape);
5116 catch (const SALOME::SALOME_Exception& S_ex) {
5117 QtCatchCorbaException(S_ex);
5126 for(;It.More();It.Next()) {
5127 QApplication::restoreOverrideCursor();
5128 Handle(SALOME_InteractiveObject) IObject = It.Value();
5129 Standard_Boolean found;
5130 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5131 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5133 QString file = QAD_FileDlg::getFileName(myDesktop,
5134 QString( IObject->getName() ) + ".igs",
5135 tr("GEOM_MEN_IMPORT_IGES"),
5136 tr("GEOM_MEN_EXPORT"),
5138 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5139 QApplication::setOverrideCursor( Qt::waitCursor );
5141 GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape);
5143 catch (const SALOME::SALOME_Exception& S_ex) {
5144 QtCatchCorbaException(S_ex);
5146 // //VRV: OCC 4.0 migration
5147 // IGESControl_Controller::Init();
5148 // IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
5149 // Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
5150 // //VRV: OCC 4.0 migration
5152 // ICW.AddShape (Shape->Shape());
5153 // ICW.ComputeModel();
5154 // Standard_Boolean result = ICW.Write( strdup(file.latin1()) );
5163 // bool test = false ;
5164 // IFSelect_ReturnStatus status ;
5165 // //VRV: OCC 4.0 migration
5166 // STEPControl_Writer aWriter;
5167 // //VRV: OCC 4.0 migration
5170 for( ; It.More(); It.Next() ) {
5171 // GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5172 QApplication::restoreOverrideCursor();
5173 Handle(SALOME_InteractiveObject) IObject = It.Value();
5174 Standard_Boolean found;
5175 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5176 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5178 file = QAD_FileDlg::getFileName(myDesktop,
5179 QString( IObject->getName() ) + ".stp",
5180 tr("GEOM_MEN_IMPORT_STEP"),
5181 tr("GEOM_MEN_EXPORT"),
5183 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5185 QApplication::setOverrideCursor( Qt::waitCursor ) ;
5187 GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape);
5189 catch (const SALOME::SALOME_Exception& S_ex) {
5190 QtCatchCorbaException(S_ex);
5192 // //VRV: OCC 4.0 migration
5193 // status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ;
5194 // //VRV: OCC 4.0 migration
5196 // if ( status != IFSelect_RetDone ) {
5197 // QApplication::restoreOverrideCursor() ;
5204 // status = aWriter.Write( strdup(file.latin1()) ) ;
5205 // QApplication::restoreOverrideCursor() ;
5212 QApplication::restoreOverrideCursor() ;
5216 //=====================================================================================
5217 // function : Display()
5218 // purpose : Displays a CORBA shape
5219 //=====================================================================================
5220 bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
5221 Standard_CString name)
5223 // MESSAGE ( "GeometryGUI::Display init ")
5224 Handle(GEOM_InteractiveObject) IO;
5225 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5226 Sel->ClearIObjects();
5228 if( aShape->_is_nil() ) {
5229 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
5230 tr ("GEOM_WRN_WARNING"),
5231 tr ("GEOM_PRP_ABORT"),
5232 tr ("GEOM_BUT_OK") );
5236 TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape);
5238 if ( shape.IsNull() )
5241 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5242 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5243 SALOMEDS::GenericAttribute_var anAttr;
5244 SALOMEDS::AttributeName_var aName;
5245 SALOMEDS::AttributePixMap_var aPixmap;
5247 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5248 int aLocked = false;
5249 if (father->_is_nil()) {
5250 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5252 aLocked = aStudy->GetProperties()->IsLocked();
5253 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5254 father = aStudyBuilder->NewComponent("GEOM");
5255 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5256 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5257 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5258 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5259 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5260 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5261 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5262 myActiveStudy->updateObjBrowser();
5263 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5266 // if (aLocked) return false;
5268 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5269 father->ComponentIOR( Fatherior );
5271 TCollection_AsciiString nameG("");
5272 Standard_CString Type;
5273 if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) {
5274 if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) {
5275 Standard_CString type;
5276 GetShapeTypeString(shape,type);
5277 aShape->NameType( type );
5278 nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") +
5279 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5281 nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") +
5282 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5284 nameG = TCollection_AsciiString(name);
5287 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5288 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5290 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5291 int themode = myRenderInter->GetDisplayMode();
5293 vtkActorCollection* theActors =
5294 GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True);
5295 theActors->InitTraversal();
5296 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
5298 IO = new GEOM_InteractiveObject(aShape->Name(),
5301 while(!(anActor==NULL)) {
5302 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
5303 GActor->setIO( IO );
5304 GActor->setName( nameG.ToCString() );
5306 theRenderer->AddActor(GActor);
5307 anActor = (vtkActor*)theActors->GetNextActor();
5311 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5312 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5313 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5314 Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() );
5315 theResult->SetShadingColor( myShadingColor );
5316 IO = new GEOM_InteractiveObject(aShape->Name(),
5319 theResult->setIO( IO );
5320 theResult->setName( nameG.ToCString() );
5322 /* Precaution : close any local context to permit the display */
5323 if ( ic->HasOpenedContext() ) {
5324 ic->CloseAllContexts();
5328 // theResult->SetInfiniteState() ;
5330 ic->Display(theResult);
5333 Sel->AddIObject( IO, false );
5334 myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
5335 if ( Settings_AddInStudy )
5336 GeomGUI->AddInStudy( false, IO );
5342 //=====================================================================================
5343 // function : AddInStudy()
5344 // purpose : anIOShape or a selected shape
5345 //=====================================================================================
5346 bool GeometryGUI::AddInStudy( bool selection,
5347 const Handle(SALOME_InteractiveObject)& anIO)
5349 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5350 if ( !( !Settings_AddInStudy || selection ) ) {
5351 Sel->ClearIObjects();
5354 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5355 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5356 SALOMEDS::GenericAttribute_var anAttr;
5357 SALOMEDS::AttributeName_var aName;
5358 SALOMEDS::AttributePixMap_var aPixmap;
5359 SALOMEDS::AttributeIOR_var anIOR;
5360 SALOMEDS::AttributeSelectable_var aSelAttr;
5362 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5363 int aLocked = false;
5364 if (father->_is_nil()) {
5365 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5367 aLocked = aStudy->GetProperties()->IsLocked();
5368 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5369 father = aStudyBuilder->NewComponent("GEOM");
5370 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5371 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5372 // aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5373 aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) );
5374 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5375 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5376 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5377 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5380 // if (aLocked) return false;
5382 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5383 father->ComponentIOR( Fatherior );
5385 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
5387 Handle(GEOM_AISShape) GAISShape;
5389 Handle(GEOM_InteractiveObject) GIO;
5393 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5394 vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5396 vtkActorCollection* theActors = Renderer->GetActors();
5397 theActors->InitTraversal();
5398 vtkActor *ac = theActors->GetNextActor();
5399 while(!(ac==NULL)) {
5400 if ( ac->IsA("GEOM_Actor") ) {
5401 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
5402 if ( anActor->hasIO() ) {
5403 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
5404 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5405 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5406 if ( anIO->isSame( GIO ) ) {
5414 ac = theActors->GetNextActor();
5421 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5422 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5423 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5425 AIS_ListOfInteractive List;
5426 ic->DisplayedObjects(List);
5427 AIS_ListIteratorOfListOfInteractive ite(List);
5428 while (ite.More()) {
5429 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
5430 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
5431 if ( aSh->hasIO() ) {
5432 Handle(SALOME_InteractiveObject) IO = aSh->getIO();
5433 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5434 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5435 if ( anIO->isSame( GIO ) ) {
5450 if ( !Settings_AddInStudy || selection ) {
5451 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() );
5452 if ( !Name.isEmpty() ) {
5454 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5455 GActor->setName( strdup(Name.latin1()) );
5458 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5459 GAISShape->setName( strdup(Name.latin1()) );
5467 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5470 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father);
5472 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() );
5474 /* For the shape inserted into the study we set its field 'studyshapeid' */
5475 /* so the shape will contain its corresponding entry in the study Ocaf doc. */
5476 aShape->StudyShapeId(newObj->GetID()) ;
5478 GIO->setEntry(newObj->GetID());
5480 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
5481 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5482 anIOR->SetValue(aShape->Name());
5484 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
5485 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5487 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
5488 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5489 if ( aShape->ShapeType() == GEOM::COMPOUND ) {
5490 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
5491 } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
5492 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
5493 } else if ( aShape->ShapeType() == GEOM::SOLID ) {
5494 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
5495 } else if ( aShape->ShapeType() == GEOM::SHELL ) {
5496 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
5497 } else if ( aShape->ShapeType() == GEOM::FACE ) {
5498 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
5499 } else if ( aShape->ShapeType() == GEOM::WIRE ) {
5500 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
5501 } else if ( aShape->ShapeType() == GEOM::EDGE ) {
5502 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
5503 } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
5504 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
5508 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5509 GActor->setIO( GIO );
5510 aName->SetValue(GActor->getName());
5513 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5514 GAISShape->setIO( GIO );
5515 aName->SetValue(GAISShape->getName());
5518 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
5519 aStudyBuilder->Addreference(newObj1,newObj);
5521 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
5522 listIOR = myComponentGeom->GetReferencedObjects(aShape);
5524 if (listIOR->length()>0) {
5525 SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj);
5526 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName");
5527 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5528 aName->SetValue(tr("GEOM_ARGUMENTS"));
5529 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable");
5530 aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
5531 aSelAttr->SetSelectable(false);
5533 bool ObjectReferenced = false;
5534 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
5535 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]);
5537 if ( !theObj->_is_nil() ) {
5538 SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments);
5539 aStudyBuilder->Addreference(RefObject, theObj);
5540 ObjectReferenced = true;
5544 if ( !ObjectReferenced )
5545 aStudyBuilder->RemoveObject(Arguments);
5551 if ( !Settings_AddInStudy || selection ) {
5552 myActiveStudy->updateObjBrowser();
5554 myActiveStudy->updateObjBrowser(false);
5555 Sel->AddIObject( GIO );
5558 // MESSAGE ( " highlihght done" )
5564 //=====================================================================================
5565 // function : GetShapeFromIOR()
5566 // purpose : exist also as static method !
5567 //=====================================================================================
5568 TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR )
5570 TopoDS_Shape result;
5571 if( IOR.stripWhiteSpace().isEmpty() )
5573 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
5574 CORBA::ORB_var& _orb = init.orb() ;
5575 CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) );
5576 if ( CORBA::is_nil( obj ) )
5578 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR );
5579 if (!aShape->_is_nil()) {
5580 result = ShapeReader.GetShape( myComponentGeom, aShape );
5586 //=====================================================================================
5587 // function : SetSettings()
5588 // purpose : [static]
5589 //=====================================================================================
5590 bool GeometryGUI::SetSettings( QAD_Desktop* parent )
5592 /* Create or retrieve an object GeomGUI */
5593 GeometryGUI::GetOrCreateGeometryGUI(parent);
5595 //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING
5596 //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS
5597 //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY
5598 parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS
5599 parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN
5602 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
5603 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
5604 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
5605 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
5606 GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255.,
5609 /* Wireframe or Shading */
5610 int DisplayMode = 0;
5611 if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5612 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5613 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
5614 DisplayMode = ic->DisplayMode();
5615 } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5616 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5617 DisplayMode = myRenderInter->GetDisplayMode();
5620 if ( DisplayMode == 1 )
5621 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
5623 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
5626 // QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy");
5627 // if ( !Copy.isEmpty() ) {
5628 // Settings_Copy = Copy.toInt();
5630 // parent->menuBar()->findItem(701,&pp);
5631 // pp->setItemChecked(701, Settings_Copy);
5634 if ( parent->menuBar()->findItem(701,&pp) )
5635 pp->removeItem(701);
5638 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
5639 if ( !AddInStudy.isEmpty() )
5640 Settings_AddInStudy = AddInStudy.toInt();
5642 Settings_AddInStudy = 1;
5643 parent->menuBar()->findItem(702,&pp);
5644 pp->setItemChecked(702, Settings_AddInStudy);
5647 QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
5649 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" );
5652 QAD_Study* ActiveStudy = parent->getActiveStudy();
5653 int count = ActiveStudy->getStudyFramesCount();
5655 bool ViewOCC = false;
5656 for ( int i = 0; i < count; i++ ) {
5657 if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
5658 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
5659 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5661 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
5662 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
5663 if ( !IsoU.isEmpty() )
5664 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
5665 if ( !IsoV.isEmpty() )
5666 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
5672 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
5674 Mb->setItemEnabled( 312, ViewOCC); //Sketch
5675 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
5676 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
5678 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
5679 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
5685 //=====================================================================================
5686 // function : DefinePopup()
5687 // purpose : [static]
5688 //=====================================================================================
5689 void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
5691 /* Create or retrieve an object GeomGUI */
5692 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
5693 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5696 if ( Sel->IObjectCount() == 1 )
5698 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
5701 SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
5702 if (!sobj->_is_nil())
5704 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
5705 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
5707 // component is selected
5708 theObject = "Component";
5714 if ( ( theParent.compare("Viewer")==0 ) )
5716 if ( GeomGUI->myState == CURRENT_SKETCH )
5717 theContext = "Sketch";
5720 if ( Sel->IObjectCount() > 0 )
5723 theContext = "NothingSelected";
5731 //=====================================================================================
5732 // function : CustomPopup()
5733 // purpose : [static]
5734 //=====================================================================================
5735 bool GeometryGUI::CustomPopup( QAD_Desktop* parent,
5737 const QString& theContext,
5738 const QString& theParent,
5739 const QString& theObject )
5741 /* Create or retrieve an object GeomGUI */
5742 GeometryGUI::GetOrCreateGeometryGUI(parent);
5744 /* Deactivate any non modal dialog box to get the neutral point */
5745 GeomGUI->EmitSignalDeactivateDialog() ;
5747 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5748 int nbSel = Sel->IObjectCount();
5750 if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) )
5754 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
5756 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->
5757 getRightFrame()->getViewFrame())->getViewer();
5758 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5759 if ( theParent.compare("Viewer")==0 )
5761 if ( theContext.compare("Sketch")==0 )
5763 SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus();
5764 popup->setCheckable(TRUE);
5767 popup->setItemChecked(10000,true);
5768 popup->setItemChecked(10001,false);
5770 else if (myCS==ARC_CHORD)
5772 popup->setItemChecked(10000,false);
5773 popup->setItemChecked(10001,true);
5779 if (theObject.compare("Component") == 0)
5781 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5786 QFont f = QApplication::font();
5790 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5791 popup->removeItem(QAD_TopLabel_Popup_ID);
5792 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5793 if ( IObject->hasEntry() )
5794 popup->setItemEnabled( 801, false );
5796 popup->setItemEnabled( 801, true );
5798 if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)))
5800 Standard_Boolean found;
5801 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
5805 if ( Result->DisplayMode() == 1 )
5806 popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") );
5808 popup->changeItem(8021, tr("GEOM_MEN_SHADING") );
5812 if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) )
5813 popup->removeItem(QAD_Erase_Popup_ID);
5815 popup->removeItem(QAD_Display_Popup_ID);
5820 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5821 popup->removeItem(QAD_TopLabel_Popup_ID);
5822 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ),
5823 QAD_TopLabel_Popup_ID, 0 );
5824 popup->setItemEnabled( 801, false );
5830 if ( theParent.compare("ObjectBrowser")==0 )
5832 popup->removeItem(QAD_TopLabel_Popup_ID);
5833 int id = popup->idAt(0); // separator
5834 if (id < 0) popup->removeItem(id);
5836 // checking for GEOM label in the selected list
5837 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5838 Handle(SALOME_InteractiveObject) anIObject;
5840 bool useSubItems = false;
5841 bool needOpen = false;
5842 bool needDisplay = false;
5843 bool needErase = false;
5844 SALOMEDS::GenericAttribute_var aTmpAttr;
5845 for(;It.More();It.Next())
5847 anIObject = It.Value();
5848 if (!anIObject->hasEntry())
5851 if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject))
5855 SALOMEDS::SObject_var obj =
5856 GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
5857 if (!obj->_is_nil())
5859 GEOM::GEOM_Shape_var aShape;
5860 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) {
5861 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5862 if (str && strlen(str))
5863 aShape = GeomGUI->myComponentGeom-> GetIORFromString(str);
5866 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5868 if (aShape->_is_nil())
5870 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->
5871 getStudyDocument()->NewChildIterator(obj);
5872 while (anIter->More())
5874 SALOMEDS::SObject_var subobj = anIter->Value();
5875 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
5882 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5892 // remove useless popup items
5893 if (nbSel != 1) popup->removeItem(901); // rename
5894 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5897 int index = popup->indexOf(9024);
5898 popup->removeItem(9024); // open
5899 popup->removeItemAt(index); // separator under Open
5901 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
5902 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
5903 if (!needDisplay && !needErase)
5905 int id = popup->idAt(popup->count()-1); // last item
5906 popup->removeItem(id); // separator
5911 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5912 popup->removeItem(QAD_Display_Popup_ID);
5913 popup->removeItem(QAD_Erase_Popup_ID);
5916 int id = popup->idAt(popup->count()-1); // last item
5917 popup->removeItem(id); // separator
5922 // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ")
5925 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
5927 // MESSAGE ( " CUSTOM POPUP VIEWER VTK ")
5928 if ( ( theParent.compare("Viewer")==0 ) )
5931 popup->setItemEnabled( 8033, false );
5932 if (theObject.compare("Component") == 0)
5934 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5938 //int id = popup->idAt(0);
5939 QFont f = QApplication::font();
5944 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5945 popup->removeItem(QAD_TopLabel_Popup_ID);
5946 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5947 if ( IObject->hasEntry() )
5949 popup->setItemEnabled( 801, false );
5950 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
5951 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
5952 SALOMEDS::GenericAttribute_var anAttr;
5953 SALOMEDS::AttributeIOR_var anIOR;
5954 if ( !SO->_is_nil() )
5956 if (SO->FindAttribute(anAttr, "AttributeIOR") )
5958 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5959 Standard_Boolean found;
5960 GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true);
5963 if ( Result->getDisplayMode() == 1 )
5964 popup->changeItem(8021, "Wireframe" );
5966 popup->changeItem(8021, "Shading" );
5968 if ( !Result->GetVisibility() )
5969 popup->removeItem(QAD_Erase_Popup_ID);
5971 popup->removeItem(QAD_Display_Popup_ID);
5974 popup->removeItem(QAD_Erase_Popup_ID);
5979 popup->setItemEnabled( 801, true );
5983 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5984 popup->removeItem(QAD_TopLabel_Popup_ID);
5985 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 );
5986 popup->setItemEnabled( 801, false );
5991 if ( theParent.compare("ObjectBrowser")==0 )
5993 popup->removeItem(QAD_TopLabel_Popup_ID);
5994 int id = popup->idAt(0); // separator
5995 if (id < 0) popup->removeItem(id);
5997 // checking for GEOM label in the selected list
5998 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5999 Handle(SALOME_InteractiveObject) anIObject;
6001 bool useSubItems = false;
6002 bool needOpen = false;
6003 bool needDisplay = false;
6004 bool needErase = false;
6005 SALOMEDS::GenericAttribute_var aTmpAttr;
6006 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->
6007 getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6008 for(;It.More();It.Next())
6010 anIObject = It.Value();
6011 if ( !anIObject->hasEntry() )
6014 if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject))
6019 SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument()
6020 ->FindObjectID( anIObject->getEntry() );
6021 if (!obj->_is_nil()) {
6022 GEOM::GEOM_Shape_var aShape;
6023 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){
6024 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
6025 if (str && strlen(str))
6026 aShape = GeomGUI->myComponentGeom->GetIORFromString(str);
6029 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
6031 if (aShape->_is_nil())
6033 SALOMEDS::ChildIterator_var anIter =
6034 GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6035 while (anIter->More())
6037 SALOMEDS::SObject_var subobj = anIter->Value();
6038 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
6045 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
6055 // remove useless popup items
6056 if (nbSel != 1) popup->removeItem(901); // rename
6057 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6060 int index = popup->indexOf(9024);
6061 popup->removeItem(9024); // open
6062 popup->removeItemAt(index); // separator under Open
6064 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
6065 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
6066 if (!needDisplay && !needErase)
6068 int id = popup->idAt(popup->count()-1); // last item
6069 popup->removeItem(id); // separator
6074 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6075 popup->removeItem(QAD_Display_Popup_ID);
6076 popup->removeItem(QAD_Erase_Popup_ID);
6079 int id = popup->idAt(popup->count()-1); // last item
6080 popup->removeItem(id); // separator
6084 // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.")
6087 { // other viewer types not supported.
6090 int id = popup->idAt(0);
6091 if (id <= QAD_TopLabel_Popup_ID && id != -1)
6092 popup->removeItemAt(0);
6096 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6097 popup->removeItem(QAD_Display_Popup_ID);
6098 popup->removeItem(QAD_Erase_Popup_ID);
6099 int id = popup->idAt(popup->count()-1); // last item
6100 if (id < 0 && id != -1) popup->removeItem(id); // separator
6106 void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
6108 /* Create or retrieve an object GeomGUI */
6109 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
6111 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6112 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
6114 OCCViewer_Viewer3d* v3d;
6115 Handle(AIS_InteractiveContext) ic;
6116 vtkRenderer* Renderer;
6118 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6119 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6120 ic = v3d->getAISContext();
6121 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6122 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6127 MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
6129 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6132 SALOMEDS::SObject_var fatherSF =
6133 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6135 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6137 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6139 SALOMEDS::GenericAttribute_var anAttr;
6140 SALOMEDS::AttributeName_var aName;
6141 SALOMEDS::AttributeIOR_var anIOR;
6143 if(myRenderInter->isInViewer(theIO)) {
6144 myRenderInter->Display(theIO, false);
6148 if ( !obj->_is_nil() ) {
6149 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6150 // this SObject may be GEOM module root SObject
6152 bool useSubItems = false;
6153 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6154 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6155 while (anIter->More() && !useSubItems) {
6156 SALOMEDS::SObject_var subobj = anIter->Value();
6157 SALOMEDS::GenericAttribute_var aTmpAttr;
6158 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6159 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6163 } else anIter->Next();
6164 } else anIter->Next();
6168 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6169 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6170 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6171 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6173 if (obj->FindAttribute(anAttr, "AttributeName")) {
6174 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6176 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6177 vtkActorCollection* theAllActors = theRenderer->GetActors();
6178 theAllActors->InitTraversal();
6179 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
6180 Handle(SALOME_InteractiveObject) anIObj;
6181 // don't create new study object if it already exists
6182 bool isDisplayed = false;
6183 while(!(actor==NULL)) {
6184 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
6186 if (Gactor->hasIO()) {
6187 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
6189 anIObj = Gactor->getIO();
6190 if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
6194 actor=(vtkActor*)(theAllActors->GetNextActor());
6198 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6201 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6202 aStudyBuilder->Addreference(newObj1, obj);
6203 // commit transaction
6206 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6207 int themode = myRenderInter->GetDisplayMode();
6209 vtkActorCollection* theActors =
6210 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
6211 theActors->InitTraversal();
6212 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
6213 while(!(anActor==NULL)) {
6214 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
6215 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
6216 IO->setEntry(obj->GetID());
6217 GActor->setIO( IO );
6218 GActor->setName( theIO->getName() );
6220 theRenderer->AddActor(GActor);
6221 // renWin->Render();
6222 anActor = (vtkActor*)theActors->GetNextActor();
6226 // next item iteration
6229 anAttr = SALOMEDS::GenericAttribute::_nil();
6230 while (anIter->More() && anAttr->_is_nil()) {
6231 SALOMEDS::SObject_var subobject = anIter->Value();
6232 SALOMEDS::GenericAttribute_var aTmpAttribute;
6233 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6234 anAttr = aTmpAttribute;
6236 } else anIter->Next();
6238 } else anAttr = SALOMEDS::GenericAttribute::_nil();
6243 // No viewer update should be done here!
6244 //myRenderInter->Render();
6245 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6246 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6247 SALOMEDS::SObject_var fatherSF =
6248 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6249 SALOMEDS::GenericAttribute_var anAttr;
6250 SALOMEDS::AttributeName_var aName;
6251 SALOMEDS::AttributeIOR_var anIOR;
6253 if ( v3d->isInViewer( theIO, true ) ) {
6254 Standard_Boolean found;
6255 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true );
6257 ic->Display(aSh, false);
6258 ic->AddOrRemoveCurrentObject(aSh, false);
6262 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6263 if ( !obj->_is_nil() ) {
6264 MESSAGE("BuildPresentation(): SObject not null")
6265 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6266 MESSAGE("BuildPresentation(): SObject has IOR")
6267 // this SObject may be GEOM module root SObject
6269 bool useSubItems = false;
6270 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6271 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6272 while (anIter->More() && !useSubItems) {
6273 SALOMEDS::SObject_var subobj = anIter->Value();
6274 SALOMEDS::GenericAttribute_var aTmpAttr;
6275 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6276 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6280 } else anIter->Next();
6281 } else anIter->Next();
6285 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6286 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6287 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6288 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6290 MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
6291 if (obj->FindAttribute(anAttr, "AttributeName")) {
6292 MESSAGE("BuildPresentation(): SObject has Name")
6293 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6294 // searchin for already displayed objects with the same shape
6295 AIS_ListOfInteractive aDisplayed;
6296 ic->DisplayedObjects(aDisplayed);
6297 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
6298 Handle(AIS_Shape) anAISShape;
6299 for(;anIObjects.More();anIObjects.Next()) {
6300 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
6301 if (!anAISShape.IsNull()) {
6302 if (anAISShape->Shape().IsSame(Shape)) break;
6303 anAISShape.Nullify();
6306 if (!anAISShape.IsNull()) {
6307 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false);
6311 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6313 if (fatherSF->_is_nil())
6314 MESSAGE("BuildPresentation(): fatherSF is nil!")
6315 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6316 aStudyBuilder->Addreference(newObj1, obj);
6317 // commit transaction
6320 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
6321 aSh->SetShadingColor( GeomGUI->myShadingColor );
6322 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
6325 IO->setEntry(obj->GetID());
6327 aSh->setName( aName->Value() );
6328 ic->Display (aSh, false);
6329 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false);
6332 // next item iteration
6335 anAttr=SALOMEDS::GenericAttribute::_nil();
6336 while (anIter->More() && anAttr->_is_nil()) {
6337 SALOMEDS::SObject_var subobject = anIter->Value();
6338 SALOMEDS::GenericAttribute_var aTmpAttribute;
6339 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6340 anAttr = aTmpAttribute;
6342 } else anIter->Next();
6345 anAttr = SALOMEDS::GenericAttribute::_nil();
6350 // No viewer update should be done here!
6351 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6352 //ic->UpdateCurrentViewer();
6356 //=======================================================================
6357 // function : Parameter()
6358 // purpose : return a parameter (float) from a dialog box
6360 // avalue1 : is a float or integer used as a default value displayed
6361 // aTitle1 : is the title for aValue1
6362 // aTitle : is the main title
6363 // bottom : maximum value to be entered
6364 // top : minimum value to be entered
6365 // decimals : number of decimals
6366 //=======================================================================
6367 double GeometryGUI::Parameter( Standard_Boolean& res,
6368 const char* aValue1,
6369 const char* aTitle1,
6371 const double bottom,
6373 const int decimals )
6375 GeometryGUI_aParameterDlg * Dialog =
6376 new GeometryGUI_aParameterDlg(aValue1,
6378 QAD_Application::getDesktop(),
6385 int r = Dialog->exec() ;
6387 if ( r == QDialog::Accepted ) {
6388 res = Standard_True;
6389 X = Dialog->getValue();
6391 res = Standard_False;
6397 //=======================================================================
6398 // function : OnSketchSegment()
6400 //=======================================================================
6401 void GeometryGUI::OnSketchSegment()
6403 this->mySketcher.ChangeMode(SEGMENT);
6407 //=======================================================================
6408 // function : OnSketchArc()
6410 //=======================================================================
6411 void GeometryGUI::OnSketchArc()
6413 this->mySketcher.ChangeMode(ARC_CHORD);
6416 //=======================================================================
6417 // function : OnSketchSetAngle()
6419 //=======================================================================
6420 void GeometryGUI::OnSketchSetAngle()
6422 Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180;
6423 Sketch::fitInResol(anAngle);
6424 Standard_Boolean res = false ;
6425 QString Value = QString("%1").arg( anAngle );
6426 anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ;
6429 this->mySketcher.SetSegmentAngle(anAngle);
6430 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6432 QMenuItem* item = Mb->findItem(3133,&pp);
6433 pp->setItemChecked(3133,false);
6434 item = Mb->findItem(3134,&pp);
6435 pp->setItemChecked(3134,false);
6441 //=======================================================================
6442 // function : OnSketchSetx()
6444 //=======================================================================
6445 void GeometryGUI::OnSketchSetx()
6447 Standard_Boolean res = false;
6448 double X = Parameter( res,
6451 tr("GEOM_MEN_SKETCHER_X"),
6452 2.0 * Precision::Confusion(),
6456 this->mySketcher.SetXDimension(X);
6457 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6459 QMenuItem* item = Mb->findItem(3133,&pp);
6460 pp->setItemChecked(3133,false);
6461 item = Mb->findItem(3134,&pp);
6462 pp->setItemChecked(3134,false);
6465 //=======================================================================
6466 // function : OnSketchSety()
6468 //=======================================================================
6469 void GeometryGUI::OnSketchSety()
6471 Standard_Boolean res = false;
6472 double Y = Parameter( res,
6475 tr("GEOM_MEN_SKETCHER_Y"),
6476 2.0 * Precision::Confusion(),
6480 this->mySketcher.SetYDimension(Y);
6481 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6483 QMenuItem* item = Mb->findItem(3133,&pp);
6484 pp->setItemChecked(3133,false);
6485 item = Mb->findItem(3134,&pp);
6486 pp->setItemChecked(3134,false);
6490 //=======================================================================
6491 // function : OnSketchDelete()
6493 //=======================================================================
6494 void GeometryGUI::OnSketchDelete()
6496 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
6497 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
6499 QMenuItem* item = Mb->findItem(313,&pp);
6500 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6501 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6504 if (this->mySketcher.Delete())
6505 GeomGUI->ResetState();
6509 //=======================================================================
6510 // function : OnSketchClose()
6512 //=======================================================================
6513 void GeometryGUI::OnSketchClose()
6515 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6516 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6518 TopoDS_Wire W = this->mySketcher.Close();
6519 if ( !W.IsNull() ) {
6521 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6522 listShapes->length(0);
6525 BRepTools_WireExplorer Ex(W);
6526 while ( Ex.More() ) {
6527 TopoDS_Edge E = Ex.Current();
6530 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6531 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6534 Handle(Geom_Curve) Curve;
6535 Handle(Geom_Circle) Circle;
6537 Standard_Real First,Last;
6539 Curve = BRep_Tool::Curve(E,First,Last);
6540 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6541 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6542 Circ = Circle->Circ(); // gp_Circ
6544 Curve->D0( (First + Last) / 2. , CenterPoint );
6546 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6547 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6548 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6550 GEOM::GEOM_Shape_var arc;
6553 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6555 catch (const SALOME::SALOME_Exception& S_ex) {
6556 QtCatchCorbaException(S_ex);
6559 listShapes->length(i+1);
6560 listShapes[i] = strdup(arc->Name());
6563 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6564 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6565 GEOM::GEOM_Shape_var segment;
6568 segment = myComponentGeom->MakeEdge(pI,pE) ;
6570 catch (const SALOME::SALOME_Exception& S_ex) {
6571 QtCatchCorbaException(S_ex);
6574 listShapes->length(i+1);
6575 listShapes[i] = strdup(segment->Name());
6580 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6581 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6582 Standard_CString type;
6583 GetShapeTypeString(S,type);
6584 Wire->NameType( type );
6586 if ( Display(Wire, "" )) {
6587 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6590 GeomGUI->ResetState();
6591 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6593 QMenuItem* item = Mb->findItem(313,&pp);
6594 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6595 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6600 //=======================================================================
6601 // function : OnSketchEnd()
6603 //=======================================================================
6604 void GeometryGUI::OnSketchEnd()
6606 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6607 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6609 TopoDS_Wire W = this->mySketcher.End();
6612 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6613 listShapes->length(0);
6616 BRepTools_WireExplorer Ex(W);
6617 while ( Ex.More() ) {
6618 TopoDS_Edge E = TopoDS::Edge( Ex.Current() );
6621 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6622 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6625 Handle(Geom_Curve) Curve;
6626 Handle(Geom_Circle) Circle;
6628 Standard_Real First,Last;
6630 Curve = BRep_Tool::Curve(E,First,Last);
6631 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6632 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6633 Circ = Circle->Circ(); // gp_Circ
6635 Curve->D0( (First + Last) / 2. , CenterPoint );
6637 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6638 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6639 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6641 GEOM::GEOM_Shape_var arc;
6644 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6646 catch (const SALOME::SALOME_Exception& S_ex) {
6647 QtCatchCorbaException(S_ex);
6650 listShapes->length(i+1);
6651 listShapes[i] = strdup(arc->Name());
6654 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6655 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6656 GEOM::GEOM_Shape_var segment;
6659 segment = myComponentGeom->MakeEdge(pI,pE) ;
6661 catch (const SALOME::SALOME_Exception& S_ex) {
6662 QtCatchCorbaException(S_ex);
6665 listShapes->length(i+1);
6666 listShapes[i] = strdup(segment->Name());
6672 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6673 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6674 Standard_CString type;
6675 GetShapeTypeString(S,type);
6676 Wire->NameType( type );
6678 if ( Display(Wire, "") ) {
6679 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6682 GeomGUI->ResetState();
6683 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6685 QMenuItem* item = Mb->findItem(313,&pp);
6686 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6687 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6690 //=======================================================================
6691 // function : OnSettingsNoconstraint()
6693 //=======================================================================
6694 void GeometryGUI::OnSettingsNoconstraint()
6696 this->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6699 //=======================================================================
6700 // function : OnSettingsPerpendicular()
6702 //=======================================================================
6703 void GeometryGUI::OnSettingsPerpendicular()
6705 this->mySketcher.SetTransitionStatus(PERPENDICULAR);
6708 //=======================================================================
6709 // function : OnSettingsTangent()
6711 //=======================================================================
6712 void GeometryGUI::OnSettingsTangent()
6714 this->mySketcher.SetTransitionStatus(TANGENT);
6717 //=======================================================================
6718 // function : OnSketchOptionsOnoffangledimension()
6720 //=======================================================================
6721 void GeometryGUI::OnSketchOptionsOnoffangledimension()
6723 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6725 QMenuItem* item = Mb->findItem(10011,&pp);
6726 pp->setItemChecked(10011,!pp->isItemChecked(10011));
6727 this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
6730 //=======================================================================
6731 // function : OnSketchOptionsOnofflengthdimension()
6733 //=======================================================================
6734 void GeometryGUI::OnSketchOptionsOnofflengthdimension()
6736 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6738 QMenuItem* item = Mb->findItem(10010,&pp);
6739 pp->setItemChecked(10010,!pp->isItemChecked(10010));
6740 this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
6743 //=======================================================================
6744 // function : OnSketchOptionsOnoffradiusdimension()
6746 //=======================================================================
6747 void GeometryGUI::OnSketchOptionsOnoffradiusdimension()
6749 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6751 QMenuItem* item = Mb->findItem(10012,&pp);
6752 pp->setItemChecked(10012,!pp->isItemChecked(10012));
6753 this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
6757 //=======================================================================
6758 // function : OnSketchOptionsOnoffxdimension()
6760 //=======================================================================
6761 void GeometryGUI::OnSketchOptionsOnoffxdimension()
6763 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6765 QMenuItem* item = Mb->findItem(10013,&pp);
6766 pp->setItemChecked(10013,!pp->isItemChecked(10013));
6767 this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
6770 //=======================================================================
6771 // function : OnSketchOptionsOnoffydimension()
6773 //=======================================================================
6774 void GeometryGUI::OnSketchOptionsOnoffydimension()
6776 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6778 QMenuItem* item = Mb->findItem(10014,&pp);
6779 pp->setItemChecked(10014,!pp->isItemChecked(10014));
6780 this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
6784 //=======================================================================
6785 // function : Archimede()
6787 //=======================================================================
6788 void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO,
6789 const double aWeight,
6790 const double aWaterDensity,
6791 const double aMeshingDeflection )
6794 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
6795 Handle(GEOM_InteractiveObject) GIO =
6796 Handle(GEOM_InteractiveObject)::DownCast( IO );
6797 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() );
6799 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6800 Result->NameType(tr("GEOM_PLANE"));
6801 if ( Display(Result, "") ) {
6802 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6806 if ( IO->hasEntry() ) {
6807 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6808 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
6809 SALOMEDS::GenericAttribute_var anAttr;
6810 SALOMEDS::AttributeIOR_var anIOR;
6811 if ( !obj->_is_nil() ) {
6812 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
6813 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6814 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() );
6815 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6816 Result->NameType(tr("GEOM_PLANE"));
6817 if ( Display(Result, "") ) {
6818 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6825 catch (const SALOME::SALOME_Exception& S_ex) {
6826 QtCatchCorbaException(S_ex);
6831 //=====================================================================================
6833 //=====================================================================================
6836 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
6838 return GeometryGUI::OnGUIEvent(theCommandID, parent);
6841 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6843 return GeometryGUI::OnKeyPress (pe, parent, studyFrame);
6846 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6848 return GeometryGUI::OnMousePress (pe, parent, studyFrame);
6851 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6853 return GeometryGUI::OnMouseMove (pe, parent, studyFrame);
6856 bool SetSettings ( QAD_Desktop* parent )
6858 return GeometryGUI::SetSettings( parent );
6861 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
6862 const QString & theParent, const QString & theObject )
6864 return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
6867 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
6869 GeometryGUI::DefinePopup( theContext, theParent, theObject );
6872 bool activeStudyChanged ( QAD_Desktop* parent )
6874 GeometryGUI::activeStudyChanged( parent );
6877 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
6879 GeometryGUI::BuildPresentation(theIO);
6882 void supportedViewType(int* buffer, int bufferSize)
6884 if (!buffer || !bufferSize) return;
6885 buffer[0] = (int)VIEW_OCC;
6886 if (--bufferSize) buffer[1] = (int)VIEW_VTK;
6890 //=====================================================================================
6891 // function : OnFilletGetAll()
6893 //=====================================================================================
6894 bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR)
6896 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6897 ListOfID->length(0);
6899 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6900 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6901 if ( theObj->_is_nil() ) {
6902 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6907 if( Radius <= Precision::Confusion() )
6910 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6911 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ;
6912 if ( result->_is_nil() ) {
6913 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6916 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
6917 Standard_CString type;
6918 GetShapeTypeString(S,type);
6919 result->NameType( type );
6921 if ( Display( result, "" ))
6922 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6924 catch (const SALOME::SALOME_Exception& S_ex) {
6925 QtCatchCorbaException(S_ex);
6930 //=====================================================================================
6931 // function : OnFilletGetSelected()
6933 //=====================================================================================
6934 bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
6935 const char* ShapeTopoIOR,
6936 const double Radius,
6937 const int SubShapeType,
6938 Standard_Integer& aLocalContextId,
6939 bool& myUseLocalContext )
6941 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
6945 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6946 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
6948 if( myUseLocalContext == false ) {
6949 /* No local context opened for fillet method */
6950 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6954 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6956 int nbSelected = ic->NbSelected();
6960 while(ic->MoreSelected()) {
6961 TopoDS_Shape s = ic->SelectedShape();
6962 if ( s.ShapeType() == TopAbs_FACE ) {
6963 TopExp_Explorer Exp( s, TopAbs_EDGE );
6964 TopTools_MapOfShape M ;
6965 while ( Exp.More() ) {
6966 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
6967 ListOfID->length( i + 1 );
6968 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
6975 ListOfID->length( i + 1 );
6976 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
6982 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6983 GEOM::GEOM_Shape_var aResult ;
6985 aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID );
6987 /* local context from DialogBox */
6988 ic->CloseLocalContext(aLocalContextId) ;
6989 myUseLocalContext = false ;
6991 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
6992 Standard_CString type;
6993 GetShapeTypeString(S,type);
6994 aResult->NameType( type );
6996 if ( Display( aResult, "") )
6997 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6999 catch (const SALOME::SALOME_Exception& S_ex) {
7000 QtCatchCorbaException(S_ex);
7003 if ( myUseLocalContext ) {
7004 /* local context from DialogBox */
7005 ic->CloseLocalContext(aLocalContextId) ;
7006 myUseLocalContext = false ;
7009 this->OnDisplayAll(true);
7010 myActiveStudy->updateObjBrowser();
7011 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7016 //=====================================================================================
7017 // function : OnChamferGetAll()
7019 //=====================================================================================
7020 bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR)
7022 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7023 ListOfID->length(0);
7025 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
7026 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
7027 if ( theObj->_is_nil() ) {
7028 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
7033 if( D1 <= Precision::Confusion() )
7035 if( D2 <= Precision::Confusion() )
7038 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7039 GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ;
7040 if ( result->_is_nil() ) {
7041 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7045 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
7046 Standard_CString type;
7047 GetShapeTypeString(S,type);
7048 result->NameType( type );
7050 if ( Display( result, "") )
7051 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7053 catch (const SALOME::SALOME_Exception& S_ex) {
7054 QtCatchCorbaException(S_ex);
7059 //=====================================================================================
7060 // function : OnChamferGetSelected()
7062 //=====================================================================================
7063 bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
7064 const char* ShapeTopoIOR,
7065 const double D1, const double D2, const int SubShapeType,
7066 Standard_Integer& aLocalContextId,
7067 bool& myUseLocalContext)
7069 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
7073 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
7074 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
7076 if( myUseLocalContext == false ) {
7077 /* No local context opened for chamfer method */
7078 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7082 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7084 int nbSelected = ic->NbSelected();
7088 while(ic->MoreSelected()) {
7089 TopoDS_Shape s = ic->SelectedShape();
7090 if ( s.ShapeType() == TopAbs_FACE ) {
7091 TopExp_Explorer Exp( s, TopAbs_EDGE );
7092 TopTools_MapOfShape M ;
7093 while ( Exp.More() ) {
7094 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
7095 ListOfID->length( i + 1 );
7096 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
7103 ListOfID->length( i + 1 );
7104 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ;
7110 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7111 GEOM::GEOM_Shape_var aResult ;
7113 aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID );
7115 /* local context from DialogBox */
7116 ic->CloseLocalContext(aLocalContextId) ;
7117 myUseLocalContext = false ;
7119 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
7120 Standard_CString type;
7121 GetShapeTypeString(S,type);
7122 aResult->NameType( type );
7124 if ( Display( aResult, "") )
7125 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7127 catch (const SALOME::SALOME_Exception& S_ex) {
7128 QtCatchCorbaException(S_ex);
7131 if ( myUseLocalContext ) {
7132 /* local context from DialogBox */
7133 ic->CloseLocalContext(aLocalContextId) ;
7134 myUseLocalContext = false ;
7137 this->OnDisplayAll(true);
7138 myActiveStudy->updateObjBrowser();
7139 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7144 //=====================================================================================
7145 // function : MakeCDGAndDisplay()
7147 //=====================================================================================
7148 void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
7151 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape );
7152 if ( result->_is_nil() ) {
7153 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
7156 result->NameType( tr("GEOM_POINT") );
7157 if ( Display( result ) )
7158 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7160 catch (const SALOME::SALOME_Exception& S_ex) {
7161 QtCatchCorbaException(S_ex);
7166 bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) {
7167 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
7168 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
7169 SALOMEDS::SObject_var RefSO;
7170 SALOMEDS::GenericAttribute_var anAttr;
7171 SALOMEDS::AttributeIOR_var anIOR;
7172 for (; it->More();it->Next()) {
7173 SALOMEDS::SObject_var SO= it->Value();
7174 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
7175 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7176 if ( strcmp( anIOR->Value(), IOR ) == 0 )
7179 if ( SO->ReferencedObject( RefSO ) ) {
7180 if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) {
7181 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7182 if ( strcmp( anIOR->Value(), IOR ) == 0 )