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_RevolDlg.h" // Method REVOL
183 #include "GeometryGUI_RotationDlg.h" // Method ROTATION
184 #include "GeometryGUI_TranslationDlg.h" // Method TRANSLATION
185 #include "GeometryGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
186 #include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION
187 #include "GeometryGUI_ArcDlg.h" // Method ARC
188 #include "GeometryGUI_PipeDlg.h" // Method PIPE
189 #include "GeometryGUI_CylinderDlg.h" // Method CYLINDER
190 #include "GeometryGUI_ConeDlg.h" // Method CONE
191 #include "GeometryGUI_TorusDlg.h" // Method TORUS
192 #include "GeometryGUI_FillingDlg.h" // Method FILLING
193 #include "GeometryGUI_SewingDlg.h" // Method SEWING
194 #include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND
195 #include "GeometryGUI_EdgeDlg.h" // Method GEOM::EDGE
196 #include "GeometryGUI_OrientationDlg.h" // Method ORIENTATION
197 #include "GeometryGUI_PartitionDlg.h" // Method PARTITION
198 #include "GeometryGUI_SubShapeDlg.h" // Method EXPLODE
199 #include "GeometryGUI_WireDlg.h" // Method GEOM::WIRE
200 #include "GeometryGUI_WorkingPlaneDlg.h" // Method WORKING PLANE
201 #include "GeometryGUI_PropertiesDlg.h" // Method PROPERTIES
202 #include "GeometryGUI_CenterMassDlg.h" // Method CENTER MASS
203 #include "GeometryGUI_InertiaDlg.h" // Method INERTIA
204 #include "GeometryGUI_FaceDlg.h" // Method GEOM::FACE
205 #include "GeometryGUI_FilletDlg.h" // Method FILLET
206 #include "GeometryGUI_ChamferDlg.h" // Method CHAMFER
207 #include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE
208 #include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES
209 #include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE
210 #include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE
211 #include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement
212 #include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement
213 #include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX
214 #include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
215 #include "GeometryGUI_WhatisDlg.h" // Method WHATIS
216 #include "GeometryGUI_DistanceDlg.h" // Method DISTANCE
217 #include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE
220 static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape());
221 static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), "");
223 static AIS_ListOfInteractive ListDisplayedObject;
225 static bool Settings_AddInStudy = false;
226 static bool Settings_Copy = false;
227 static Standard_CString Fatherior = "";
228 static GEOM_Client ShapeReader;
230 /* The object itself created in the static method 'GetOrCreateGeometryGUI()' */
231 static GeometryGUI* GeomGUI = 0;
235 //=======================================================================
236 // class : CustomItem
237 // purpose : Set Font to a text.
238 //=======================================================================
239 class CustomItem : public QCustomMenuItem
242 CustomItem( const QString& s, const QFont& f )
243 : string( s ), font( f ){};
246 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
249 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
254 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
264 //=======================================================================
265 // function : GeometryGUI()
266 // purpose : Constructor
267 //=======================================================================
268 GeometryGUI::GeometryGUI() :
273 //=======================================================================
274 // function : ~GeometryGUI()
275 // purpose : Destructor
276 //=======================================================================
277 GeometryGUI::~GeometryGUI()
282 //=======================================================================
283 // function : GetGeometryGUI() static
284 // purpose : Returns current 'GeomGUI' a static pointer
285 //=======================================================================
286 GeometryGUI* GeometryGUI::GetGeometryGUI( )
292 //=====================================================================================
293 // function : GetIndex()
294 // purpose : Get the index of a sub shape in a main shape : index start at 1
295 //=====================================================================================
296 int GeometryGUI::GetIndex(const TopoDS_Shape& subshape,
297 const TopoDS_Shape& shape,
300 if( shape.IsNull() || subshape.IsNull() )
304 if (subshape.ShapeType() == TopAbs_COMPOUND)
307 TopTools_ListOfShape CL;
309 TopTools_ListIteratorOfListOfShape itC;
310 for (itC.Initialize( CL ); itC.More(); itC.Next())
312 for (it.Initialize( itC.Value() ); it.More(); it.Next())
314 if ( it.Value().ShapeType() == TopAbs_COMPOUND)
316 if (it.Value().IsSame(subshape))
320 CL.Append( it.Value() );
327 TopExp_Explorer Exp ( shape, subshape.ShapeType() );
328 TopTools_MapOfShape M;
331 if ( M.Add(Exp.Current()) )
333 if ( Exp.Current().IsSame(subshape) )
343 //=======================================================================
344 // function : GetOrCreateGeometryGUI()
345 // purpose : Gets or create an object 'GeometryGUI' with initialisations
346 // : Returns 'GeomGUI' as a pointer
347 //=======================================================================
348 GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
351 GeomGUI = new GeometryGUI;
352 GeomGUI->myActiveDialogBox = 0 ;
353 GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape());
354 GeomGUI->myState = -1 ;
355 GeomGUI->myDesktop = desktop ;
356 GeomGUI->myActiveStudy = desktop->getActiveStudy();
357 GeomGUI->mySimulationActor = vtkActorCollection::New() ;
359 GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
361 Engines::Component_var comp = desktop->getEngine("FactoryServer", "Geometry");
362 GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
364 /* GetCurrentStudy */
365 int studyId = GeomGUI->myActiveStudy->getStudyId();
366 GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
368 GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
370 /* study may have changed */
371 GeomGUI->myActiveStudy = desktop->getActiveStudy();
377 //=================================================================================
378 // function : VertexToPoint()
379 // purpose : If S can be converted in a gp_Pnt returns true and the result is P
380 //=================================================================================
381 bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P )
383 if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX )
385 P = BRep_Tool::Pnt(TopoDS::Vertex( S ));
390 //=================================================================================
391 // function : LinearEdgeExtremities()
392 // purpose : If S can be converted in a linear edge and if initial an final points
393 // : distance is sufficient, returns true else returns false.
394 // : Resulting points are respectively P1 and P2
395 //=================================================================================
396 bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 )
398 if( S.IsNull() || S.ShapeType() != TopAbs_EDGE )
400 BRepAdaptor_Curve curv(TopoDS::Edge(S));
401 if (curv.GetType() != GeomAbs_Line)
404 curv.D0( curv.FirstParameter(), P1 );
405 curv.D0( curv.LastParameter(), P2 );
407 if( P1.Distance(P2) <= Precision::Confusion() )
413 //=================================================================================
414 // function : GetBipointDxDyDz()
416 //=================================================================================
417 void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz )
419 dx = P2.X() - P1.X() ;
420 dy = P2.Y() - P1.Y() ;
421 dz = P2.Z() - P1.Z() ;
425 //=======================================================================
426 // function : GetTopoFromSelection()
427 // purpose : Define tds from a single selection and retuen true
428 //=======================================================================
429 bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
431 if(Sel->IObjectCount() != 1)
434 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
436 if ( IO->hasEntry() ) {
437 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
438 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
439 SALOMEDS::GenericAttribute_var anAttr;
440 SALOMEDS::AttributeIOR_var anIOR;
441 if ( !obj->_is_nil() ) {
442 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
443 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
444 tds = this->GetShapeFromIOR(anIOR->Value());
453 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
454 Standard_CString ior = "";
455 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
456 ior = GIObject->getIOR();
457 tds = this->GetShapeFromIOR(ior);
469 //=====================================================================================
470 // function : PrepareSubShapeSelection()
471 // purpose : ( localContextId of the method is opened and defined here)
472 //=====================================================================================
473 bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
475 //* Test the type of viewer */
476 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
479 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
480 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
482 /* local context opening */
483 SetDisplayedObjectList() ;
486 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
487 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
488 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
489 for(;It.More();It.Next()) {
490 Handle(SALOME_InteractiveObject) IObject = It.Value();
491 Standard_Boolean found;
492 Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found);
493 if ( found && SubShapeType >= Shape->Shape().ShapeType()) {
494 ic->Load(Shape, (8 - SubShapeType), Standard_True);
495 ic->HilightWithColor(Shape, Quantity_NOC_RED);
498 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
504 //=====================================================================================
505 // function : PrepareSubShapeSelectionArgumentShape()
506 // purpose : ( localContextId of the method is opened and defined here )
507 //=====================================================================================
508 bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
509 const int SubShapeType,
510 Standard_Integer& returnLocalContextId )
512 //* Test the type of viewer */
513 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
516 if( aShape.IsNull() )
519 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
520 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
522 /* local context opening */
523 SetDisplayedObjectList() ;
526 returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
528 Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ;
529 ic->Display(Shape, 0, (8 - SubShapeType));
531 // Not Load(...) but Display(...)
532 // ic->Load(Shape, (8 - SubShapeType), Standard_True);
533 ic->HilightWithColor(Shape, Quantity_NOC_RED);
535 myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
541 //=======================================================================
542 // function : GetNameOfSelectedIObjects()
543 // purpose : Define the name geom++ or other name of mono or multi sel.
544 //=======================================================================
545 int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel,
548 int nbSel = Sel->IObjectCount() ;
550 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
551 aName = IObject->getName();
553 aName = tr( "%1_objects" ).arg( nbSel );
559 //=======================================================================
560 // function : ConvertIOinGEOMAISShape()
562 //=======================================================================
563 Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
564 Standard_Boolean& testResult,
565 bool onlyInActiveView )
567 Handle(GEOM_AISShape) res;
568 int nbSf = myActiveStudy->getStudyFramesCount();
569 for ( int i = 0; i < nbSf; i++ ) {
570 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
571 if ( sf->getTypeView() == VIEW_OCC ) {
572 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
573 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
575 AIS_ListOfInteractive List;
576 ic->DisplayedObjects(List);
577 AIS_ListOfInteractive List1;
578 ic->ObjectsInCollector(List1);
581 AIS_ListIteratorOfListOfInteractive ite(List);
583 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
584 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
585 if ( aSh->hasIO() ) {
586 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
587 if ( GIO->isSame( IO ) ) {
588 if ( onlyInActiveView ) {
589 if ( sf == myActiveStudy->getActiveStudyFrame() ) {
608 //=======================================================================
609 // function : ConvertIORinGEOMAISShape()
611 //=======================================================================
612 Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR,
613 Standard_Boolean& testResult,
614 bool onlyInActiveView )
616 Handle(GEOM_AISShape) resultShape;
618 int nbSf = myActiveStudy->getStudyFramesCount();
619 for ( int i = 0; i < nbSf; i++ )
621 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
622 if ( sf->getTypeView() == VIEW_OCC )
624 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
625 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
627 AIS_ListOfInteractive List;
628 ic->DisplayedObjects(List);
629 AIS_ListOfInteractive List1;
630 ic->ObjectsInCollector(List1);
633 AIS_ListIteratorOfListOfInteractive ite(List);
636 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
638 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
641 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
642 Standard_CString theIOR = GIO->getIOR();
643 if ( strcmp( IOR, theIOR ) == 0 )
645 if ( onlyInActiveView )
647 if ( sf == myActiveStudy->getActiveStudyFrame() )
669 //=======================================================================
670 // function : ConvertIORinGEOMActor()
672 //=======================================================================
673 GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
674 Standard_Boolean& testResult,
675 bool onlyInActiveView )
677 int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount();
678 for ( int i = 0; i < nbSf; i++ ) {
679 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
680 if ( sf->getTypeView() == VIEW_VTK ) {
681 vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
682 vtkActorCollection* theActors = Renderer->GetActors();
683 theActors->InitTraversal();
684 vtkActor *ac = theActors->GetNextActor();
686 if ( ac->IsA("GEOM_Actor") ) {
687 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
688 if ( anActor->hasIO() ) {
689 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO());
690 Standard_CString theIOR = GIO->getIOR();
691 if ( strcmp( IOR, theIOR ) == 0 ) {
692 if ( onlyInActiveView ) {
693 if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) {
704 ac = theActors->GetNextActor();
709 return GEOM_Actor::New();
712 //=======================================================================
713 // function : ConvertIOinGEOMShape()
715 //=======================================================================
716 GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
717 Standard_Boolean& testResult )
719 GEOM::GEOM_Shape_var aShape ;
723 if ( IO->hasEntry() ) {
724 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
725 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
726 SALOMEDS::GenericAttribute_var anAttr;
727 SALOMEDS::AttributeIOR_var anIOR;
728 if ( !obj->_is_nil() ) {
729 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
730 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
731 aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
732 if(!CORBA::is_nil(aShape)) testResult = true ;
733 return aShape._retn();
737 /* case Graphical Object */
738 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
739 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
740 Standard_CString ior = GIObject->getIOR();
741 aShape = myComponentGeom->GetIORFromString(ior) ;
742 if(!CORBA::is_nil(aShape)) testResult = true ;
743 return aShape._retn();
745 return aShape._retn();
749 //=======================================================================
750 // function : ConvertListOfIOInListOfIOR()
752 //=======================================================================
753 void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
754 GEOM::GEOM_Gen::ListOfIOR& listIOR )
756 int nbSel = aList.Extent();
757 listIOR.length(nbSel) ;
759 SALOME_ListIteratorOfListIO It( aList );
760 for ( int i=0; It.More(); It.Next(), i++ )
762 Handle(SALOME_InteractiveObject) IObject = It.Value();
764 if ( IObject->hasEntry() )
766 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
767 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
768 SALOMEDS::GenericAttribute_var anAttr;
769 SALOMEDS::AttributeIOR_var anIOR;
770 if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") )
772 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
773 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
774 CORBA::ORB_var& _orb = init.orb() ;
775 CORBA::String_var theValue = anIOR->Value();
776 CORBA::Object_var theObj = _orb->string_to_object(theValue);
777 if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0"))
779 listIOR[j] = strdup(theValue) ;
784 else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
785 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject );
786 Standard_CString ior = GIObject->getIOR();
787 listIOR[j] = strdup(ior) ;
795 //=================================================================================
796 // function : GetShapeTypeString()
797 // purpose : for a single shape
798 //=================================================================================
799 bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString )
801 if( aShape.IsNull() ) {
802 aTypeString = "aNullShape" ;
805 switch (aShape.ShapeType() )
807 case TopAbs_COMPOUND:
808 { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; }
809 case TopAbs_COMPSOLID:
810 { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; }
812 { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; }
814 { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; }
817 BRepAdaptor_Surface surf(TopoDS::Face(aShape));
818 if ( surf.GetType() == GeomAbs_Plane ) {
819 aTypeString = strdup(tr("GEOM_PLANE")) ;
821 } else if ( surf.GetType() == GeomAbs_Cylinder ) {
822 aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ;
824 } else if ( surf.GetType() == GeomAbs_Sphere ) {
825 aTypeString = strdup(tr("GEOM_SURFSPHERE")) ;
827 } else if ( surf.GetType() == GeomAbs_Torus ) {
828 aTypeString = strdup(tr("GEOM_SURFTORUS")) ;
830 } else if ( surf.GetType() == GeomAbs_Cone ) {
831 aTypeString = strdup(tr("GEOM_SURFCONE")) ;
834 aTypeString = strdup(tr("GEOM_FACE")) ;
839 { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; }
842 BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
843 if ( curv.GetType() == GeomAbs_Line ) {
844 if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
845 (Abs(curv.LastParameter()) >= 1E6 )) {
846 aTypeString = strdup(tr("GEOM_LINE")) ;
848 aTypeString = strdup(tr("GEOM_EDGE")) ;
850 } else if ( curv.GetType() == GeomAbs_Circle ) {
851 if ( curv.IsClosed() )
852 aTypeString = strdup(tr("GEOM_CIRCLE")) ;
854 aTypeString = strdup(tr("GEOM_ARC")) ;
857 aTypeString = strdup(tr("GEOM_EDGE")) ;
862 { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; }
864 { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; }
870 //=================================================================================
871 // function : CreateArrowForLinearEdge()
872 // purpose : Create a cone topology to be used to display an arrow in the middle
873 // : of an edge showing its orientation. (For simulation and Viewer OCC only)
874 //=================================================================================
875 bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone )
877 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE )
880 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
881 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
882 Standard_Real Width, Height ;
883 view3d->Size(Width, Height) ;
884 const Standard_Real aHeight = (Width + Height) / 50.0 ;
887 Standard_Real first, last ;
888 Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
892 const Standard_Real param = (first+last) / 2.0 ;
893 gp_Pnt middleParamPoint ;
895 curv->D1( param, middleParamPoint, V1) ;
896 if ( V1.Magnitude() < Precision::Confusion() )
899 /* Topology orientation not geom orientation */
900 if( tds.Orientation() == TopAbs_REVERSED )
903 gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ;
904 const Standard_Real radius1 = aHeight / 5.0 ;
905 if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) {
906 ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ;
910 catch(Standard_Failure) {
911 // OCC failures are hard to catch in GUI.
912 // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
913 // in SALOME environment : compilation error !
919 //=======================================================================
920 // function : SelectionByNameInDialogs()
921 // purpose : Called when user has entered a name of object in a LineEdit.
922 // : The selection is changed. Dialog box will receive the
923 // : corresponding signal to manage this event.
924 //=======================================================================
925 bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel )
928 /* Find SObject with name in component GEOM */
929 SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ;
930 SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
931 listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ;
933 if ( listSO->length() < 1 ) {
934 const QString caption = tr("GEOM_WRN_WARNING") ;
935 const QString text = tr("GEOM_NAME_INCORRECT") ;
936 const QString button0 = tr("GEOM_BUT_OK") ;
937 QMessageBox::warning( aWidget, caption, text, button0 ) ;
940 /* More than one object with same name */
941 if ( listSO->length() > 1 ) {
942 const QString caption = tr("GEOM_WRN_WARNING") ;
943 const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ;
944 const QString button0 = tr("GEOM_BUT_OK") ;
945 QMessageBox::warning( aWidget, caption, text, button0 ) ;
949 SALOMEDS::SObject_var theObj = listSO[0] ;
950 /* Create a SALOME_InteractiveObject with a SALOME::SObject */
951 Standard_CString anEntry = theObj->GetID() ;
952 Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ;
954 /* Add as a selected object */
955 /* Clear any previous selection : */
956 /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
957 Sel->ClearIObjects() ;
958 Sel->AddIObject( SI ) ;
963 //=======================================================================
964 // function : MakePointAndDisplay
966 //=======================================================================
967 void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z )
970 GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z );
971 P->NameType( tr("GEOM_VERTEX") );
972 if ( Display( P, "") )
973 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
975 catch (const SALOME::SALOME_Exception& S_ex) {
976 QtCatchCorbaException(S_ex);
983 //=======================================================================
984 // function : MakeVectorAndDisplay()
986 //=======================================================================
987 void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
990 GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
991 GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
992 GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 );
993 Vector->NameType(tr("GEOM_VECTOR"));
994 if ( Display( Vector, "") )
995 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
997 catch (const SALOME::SALOME_Exception& S_ex) {
998 QtCatchCorbaException(S_ex);
1003 //=======================================================================
1004 // function : MakeBoxAndDisplay()
1006 //=======================================================================
1007 void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1010 GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() );
1011 box->NameType(tr("GEOM_BOX"));
1012 if ( Display( box, "") ) {
1013 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1016 catch (const SALOME::SALOME_Exception& S_ex) {
1017 QtCatchCorbaException(S_ex);
1024 //=======================================================================
1025 // function : MakePlaneAndDisplay()
1026 // purpose : Plane point is P1 and dx, dy, dz define a normal vector
1027 //=======================================================================
1028 void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
1029 const Standard_Real dy, const Standard_Real dz,
1030 const Standard_Real TrimSize )
1034 aDirection.SetCoord(dx, dy, dz) ;
1035 gp_Ax2 Axis( P1, aDirection );
1037 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1038 GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ;
1039 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1040 GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ;
1041 plane->NameType(tr("GEOM_PLANE"));
1042 if ( Display( plane, "") )
1043 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1045 catch (const SALOME::SALOME_Exception& S_ex) {
1046 QtCatchCorbaException(S_ex);
1051 //=======================================================================
1052 // function : MakeWorkingPlane()
1053 // purpose : Change the point of view3d
1054 //=======================================================================
1055 void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D)
1057 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
1058 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
1061 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
1062 Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
1063 view3d->SetAt( P.X(), P.Y(), P.Z() );
1064 view3d->SetProj( D.X(), D.Y(), D.Z() );
1065 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1069 //=======================================================================
1070 // function : MakePrismAndDisplay()
1071 // purpose : P1 and P2 is to define a vector for prism
1072 //=======================================================================
1073 void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 )
1076 GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
1077 GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ;
1078 if( BaseShape->_is_nil() ) {
1079 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1083 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ;
1084 if (result->_is_nil()) {
1085 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1089 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1090 Standard_CString type;
1091 GetShapeTypeString(S,type);
1092 result->NameType( type );
1094 if ( Display( result, "") )
1095 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1097 catch (const SALOME::SALOME_Exception& S_ex) {
1098 QtCatchCorbaException(S_ex);
1104 //=====================================================================================
1105 // function : MakeLineAndDisplay()
1106 // purpose : Create an infinite oriented line (linear edge in fact)
1107 //=====================================================================================
1108 void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint )
1112 GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ;
1113 Standard_Real length = InitPoint.Distance(LastPoint) ;
1114 if( length <= Precision::Confusion() ) {
1115 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1119 Standard_Real coeff = 1E6 / length ;
1121 /* To create a line with length = 1E6 */
1122 /* Precision::Infinite() is 1E100 in OCC */
1123 P1.SetX( InitPoint.X() - (coeff * dx) ) ;
1124 P1.SetY( InitPoint.Y() - (coeff * dy) ) ;
1125 P1.SetZ( InitPoint.Z() - (coeff * dz) ) ;
1127 P2.SetX( LastPoint.X() + (coeff * dx) ) ;
1128 P2.SetY( LastPoint.Y() + (coeff * dy) ) ;
1129 P2.SetZ( LastPoint.Z() + (coeff * dz) ) ;
1132 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ;
1133 GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ;
1134 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1136 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ;
1137 if(result->_is_nil()) {
1138 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1141 result->NameType(tr("GEOM_LINE"));
1143 if ( Display( result, "") )
1144 myDesktop->putInfo(tr("GEOM_PRP_READY"));
1146 catch (const SALOME::SALOME_Exception& S_ex) {
1147 QtCatchCorbaException(S_ex);
1154 //=======================================================================
1155 // function : MakeBooleanAndDisplay()
1157 //=======================================================================
1158 void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation )
1161 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ;
1162 if (result->_is_nil()) {
1163 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1167 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1168 Standard_CString type;
1169 GetShapeTypeString(S,type);
1170 result->NameType( type );
1172 if ( Display( result, "") )
1173 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1175 catch (const SALOME::SALOME_Exception& S_ex) {
1176 QtCatchCorbaException(S_ex);
1182 //=====================================================================================
1183 // function : MakeSphere()
1185 //=====================================================================================
1186 void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius )
1189 if( aRadius <= Precision::Confusion() ) {
1190 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"),
1191 tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") );
1194 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius);
1195 result->NameType(tr("GEOM_SPHERE"));
1196 if ( Display( result, "") )
1197 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1199 catch (const SALOME::SALOME_Exception& S_ex) {
1200 QtCatchCorbaException(S_ex);
1206 //=====================================================================================
1207 // function : MakeConeAndDisplay()
1209 //=====================================================================================
1210 void GeometryGUI::MakeConeAndDisplay( const gp_Pnt BasePoint,
1212 const double Radius1,
1213 const double Radius2,
1214 const double aHeight )
1217 if( ( Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion() ) || aHeight <= Precision::Confusion() )
1219 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1220 GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1221 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1223 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ;
1224 if ( result->_is_nil() ) {
1225 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1228 result->NameType(tr("GEOM_CONE"));
1229 if ( Display( result, "") )
1230 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1232 catch (const SALOME::SALOME_Exception& S_ex) {
1233 QtCatchCorbaException(S_ex);
1239 //=====================================================================================
1240 // function : MakeCylinderAndDisplay()
1242 //=====================================================================================
1243 void GeometryGUI::MakeCylinderAndDisplay( const gp_Pnt BasePoint,
1245 const double Radius,
1246 const double aHeight )
1249 if( Radius <= Precision::Confusion() || aHeight <= Precision::Confusion() )
1251 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1252 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1253 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1255 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ;
1256 if ( result->_is_nil() ) {
1257 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1260 result->NameType(tr("GEOM_CYLINDER"));
1261 if ( Display( result, "") )
1262 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1264 catch (const SALOME::SALOME_Exception& S_ex) {
1265 QtCatchCorbaException(S_ex);
1271 //=====================================================================================
1272 // function : MakeTorusAndDisplay()
1274 //=====================================================================================
1275 void GeometryGUI::MakeTorusAndDisplay( const gp_Pnt BasePoint,
1277 const double Radius1,
1278 const double Radius2 )
1281 if( Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion() )
1284 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
1285 GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
1286 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1288 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ;
1289 if ( result->_is_nil() ) {
1290 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1293 result->NameType(tr("GEOM_TORUS"));
1294 if ( Display( result, "") )
1295 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1297 catch (const SALOME::SALOME_Exception& S_ex) {
1298 QtCatchCorbaException(S_ex);
1304 //=====================================================================================
1305 // function : MakePipeAndDisplay()
1307 //=====================================================================================
1308 void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase )
1311 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase);
1312 if ( !result->_is_nil() && Display( result, "") ) {
1314 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1315 Standard_CString type;
1316 GetShapeTypeString(S,type);
1317 result->NameType( type );
1319 myDesktop->putInfo( tr("GEOM_PRP_DONE") );
1322 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1325 catch (const SALOME::SALOME_Exception& S_ex) {
1326 QtCatchCorbaException(S_ex);
1332 //=====================================================================================
1333 // function : MakeFillingAndDisplay()
1335 //=====================================================================================
1336 void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape,
1341 const short nbiter )
1344 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape,
1346 tol3d, tol2d, nbiter );
1347 if (result->_is_nil()) {
1348 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1352 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1353 Standard_CString type;
1354 GetShapeTypeString(S,type);
1355 result->NameType( type );
1357 if ( Display( result, "") )
1358 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1361 catch (const SALOME::SALOME_Exception& S_ex) {
1362 QtCatchCorbaException(S_ex);
1368 //=====================================================================================
1369 // function : MakeMirrorAndDisplay()
1371 //=====================================================================================
1372 void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 )
1375 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 );
1376 if (result->_is_nil()) {
1377 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1380 result->NameType( Shape1->NameType() );
1381 if ( Display( result, "") )
1382 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1384 catch (const SALOME::SALOME_Exception& S_ex) {
1385 QtCatchCorbaException(S_ex);
1391 //=====================================================================================
1392 // function : MakeSewingAndDisplay()
1394 //=====================================================================================
1395 void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1396 const Standard_Real precision )
1399 GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ;
1400 if( result->_is_nil() ) {
1401 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1405 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1406 Standard_CString type;
1407 GetShapeTypeString(S,type);
1408 result->NameType( type );
1410 if( Display( result, "") )
1411 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1414 catch (const SALOME::SALOME_Exception& S_ex) {
1415 QtCatchCorbaException(S_ex);
1420 //=====================================================================================
1421 // function : MakeCompoundAndDisplay()
1423 //=====================================================================================
1424 void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1427 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ;
1428 if( result->_is_nil() ) {
1429 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1432 result->NameType(tr("GEOM_COMPOUND"));
1433 if( Display( result, "" ))
1434 myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
1436 catch (const SALOME::SALOME_Exception& S_ex) {
1437 QtCatchCorbaException(S_ex);
1443 //=====================================================================================
1444 // function : MakeFaceAndDisplay()
1446 //=====================================================================================
1447 void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar )
1450 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ;
1451 if( result->_is_nil() ) {
1452 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1456 result->NameType(tr("GEOM_PLANE"));
1458 result->NameType(tr("GEOM_FACE"));
1459 if( Display( result, "") )
1460 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1462 catch (const SALOME::SALOME_Exception& S_ex) {
1463 QtCatchCorbaException(S_ex);
1470 //=====================================================================================
1471 // function : MakeLinearEdgeAndDisplay()
1473 //=====================================================================================
1474 void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
1477 GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
1478 GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
1479 GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ;
1480 if( result->_is_nil() ) {
1481 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1484 result->NameType(tr("GEOM_EDGE"));
1485 if( Display( result, "") )
1486 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1488 catch(const SALOME::SALOME_Exception& S_ex) {
1489 QtCatchCorbaException(S_ex);
1495 //=====================================================================================
1496 // function : MakeOrientationChangeAndDisplay()
1498 //=====================================================================================
1499 void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape )
1502 GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ;
1503 if( result->_is_nil() ) {
1504 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1507 result->NameType( Shape->NameType() );
1508 if ( Display( result, "" ))
1509 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1512 catch (const SALOME::SALOME_Exception& S_ex) {
1513 QtCatchCorbaException(S_ex);
1518 //=====================================================================================
1519 // function : MakeScaleAndDisplay()
1521 //=====================================================================================
1522 void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor )
1525 GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ;
1526 GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ;
1527 // result->NameType(tr("GEOM_SCALE"));
1528 result->NameType( Shape->NameType() );
1529 if ( Display( result, "") )
1530 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1532 myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
1534 catch (const SALOME::SALOME_Exception& S_ex) {
1535 QtCatchCorbaException(S_ex);
1541 //=======================================================================================
1542 // function : MakeRevolutionAndDisplay()
1544 //=======================================================================================
1545 void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle )
1548 GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1549 GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ;
1550 if ( result->_is_nil() ) {
1551 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1555 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
1556 Standard_CString type;
1557 GetShapeTypeString(S,type);
1558 result->NameType( type );
1560 if ( Display( result ) )
1561 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1563 catch (const SALOME::SALOME_Exception& S_ex) {
1564 QtCatchCorbaException(S_ex);
1570 //=======================================================================================
1571 // function : MakeRotationAndDisplay()
1573 //=======================================================================================
1574 void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape,
1577 const Standard_Real angle )
1580 const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
1581 GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle);
1582 if ( result->_is_nil() ) {
1583 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1586 result->NameType( Shape->NameType() );
1587 if ( Display( result ) )
1588 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1590 catch (const SALOME::SALOME_Exception& S_ex) {
1591 QtCatchCorbaException(S_ex);
1597 //=================================================================================
1598 // function : MakeTranslationAndDisplay()
1599 // purpose : Translate a shape
1600 //=================================================================================
1601 void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V )
1604 GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ;
1605 if ( result->_is_nil() ) {
1606 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1609 result->NameType( Shape->NameType() );
1610 if ( Display( result ) )
1611 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1613 catch (const SALOME::SALOME_Exception& S_ex) {
1614 QtCatchCorbaException(S_ex);
1619 //=================================================================================
1620 // function : MakeMultiTranslation1DAndDisplay()
1621 // purpose : Multi-Translate a shape
1622 //=================================================================================
1623 void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes )
1626 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1627 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1629 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes );
1630 if ( result->_is_nil() ) {
1631 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1634 result->NameType( tr("GEOM_COMPOUND") );
1635 if ( Display( result ) )
1636 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1638 catch (const SALOME::SALOME_Exception& S_ex) {
1639 QtCatchCorbaException(S_ex);
1645 //=================================================================================
1646 // function : MakeMultiTranslation2DAndDisplay()
1647 // purpose : Multi-Translate a shape
1648 //=================================================================================
1649 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 )
1652 GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ;
1653 GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ;
1654 GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ;
1655 GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ;
1657 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 );
1658 if ( result->_is_nil() ) {
1659 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1662 result->NameType( tr("GEOM_COMPOUND") );
1663 if ( Display( result ) )
1664 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1666 catch (const SALOME::SALOME_Exception& S_ex) {
1667 QtCatchCorbaException(S_ex);
1673 //=================================================================================
1674 // function : MakeMultiRotation1DAndDisplay()
1675 // purpose : Multi-Rotate a shape
1676 //=================================================================================
1677 void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes )
1680 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1681 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1682 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1684 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes );
1685 if ( result->_is_nil() ) {
1686 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1689 result->NameType( tr("GEOM_COMPOUND") );
1690 if ( Display( result ) )
1691 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1693 catch (const SALOME::SALOME_Exception& S_ex) {
1694 QtCatchCorbaException(S_ex);
1700 //=================================================================================
1701 // function : MakeMultiRotation2DAndDisplay()
1702 // purpose : Multi-Rotate a shape
1703 //=================================================================================
1704 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 )
1707 GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
1708 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1709 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
1711 GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 );
1712 if ( result->_is_nil() ) {
1713 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1716 result->NameType( tr("GEOM_COMPOUND") );
1717 if ( Display( result ) )
1718 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1720 catch (const SALOME::SALOME_Exception& S_ex) {
1721 QtCatchCorbaException(S_ex);
1728 //=======================================================================================
1729 // function : MakeArcAndDisplay()
1730 // purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
1731 //=======================================================================================
1732 void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint )
1734 gp_Vec v1( CirclePoint, InitPoint ) ;
1735 gp_Vec v2( CirclePoint, EndPoint ) ;
1736 if( v1.IsParallel(v2, Precision::Angular() ) )
1740 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() );
1741 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() );
1742 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() );
1743 GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ;
1744 if ( result->_is_nil() ) {
1745 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
1748 result->NameType(tr("GEOM_ARC"));
1749 if ( Display( result ) )
1750 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1752 catch (const SALOME::SALOME_Exception& S_ex) {
1753 QtCatchCorbaException(S_ex);
1759 //=====================================================================================
1760 // function : MakeCircleAndDisplay()
1762 //=====================================================================================
1763 void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius )
1766 GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
1767 GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
1768 GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
1770 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ;
1771 if ( result->_is_nil() ) {
1772 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
1775 result->NameType(tr("GEOM_CIRCLE"));
1776 if ( Display( result ) )
1777 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
1779 catch (const SALOME::SALOME_Exception& S_ex) {
1780 QtCatchCorbaException(S_ex);
1787 //=====================================================================================
1788 // function : MakeWireAndDisplay()
1790 //=====================================================================================
1791 void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
1794 GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ;
1795 if( result->_is_nil() ) {
1796 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1799 result->NameType(tr("GEOM_WIRE"));
1800 if( Display( result, "") )
1801 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1803 catch (const SALOME::SALOME_Exception& S_ex) {
1804 QtCatchCorbaException(S_ex);
1810 //=====================================================================================
1811 // function : MakePartitionAndDisplay()
1813 //=====================================================================================
1814 void GeometryGUI::MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
1815 const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
1816 const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
1817 const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
1818 const GEOM::shape_type limit)
1821 GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR,
1825 (CORBA::Short) limit);
1826 if( result->_is_nil() ) {
1827 myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
1830 result->NameType(tr("GEOM_PARTITION"));
1831 if( Display( result, "") )
1832 myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
1835 catch (const SALOME::SALOME_Exception& S_ex) {
1836 QtCatchCorbaException(S_ex);
1840 //=======================================================================
1841 // function : SetState()
1842 // purpose : Sets myState = aState a private field indicating which methode is active
1843 //=======================================================================
1844 void GeometryGUI::SetState(int aState )
1845 { this->myState = aState ; return ; }
1848 //=======================================================================
1849 // function : ResetState()
1850 // purpose : Sets myState = -1 a private field indicating which methode is active
1851 //=======================================================================
1852 void GeometryGUI::ResetState()
1853 { this->myState = -1 ; return ; }
1856 //=======================================================================
1857 // function : EmitSignalDeactivateDialog()
1858 // purpose : Emit a signal to deactivate the active dialog Box
1859 //=======================================================================
1860 void GeometryGUI::EmitSignalDeactivateDialog()
1862 emit this->SignalDeactivateActiveDialog() ;
1866 //=======================================================================
1867 // function : EmitSignalCloseAllDialogs()
1868 // purpose : Emit a signal to deactivate all non modal dialogs box
1869 //=======================================================================
1870 void GeometryGUI::EmitSignalCloseAllDialogs()
1872 emit this->SignalCloseAllDialogs() ;
1877 //=======================================================================
1878 // function : GetActiveDialogBox()
1880 //=======================================================================
1881 QDialog* GeometryGUI::GetActiveDialogBox()
1883 return this->myActiveDialogBox ;
1887 //=======================================================================
1888 // function : SetActiveDialogBox()
1890 //=======================================================================
1891 void GeometryGUI::SetActiveDialogBox(QDialog* aDlg)
1893 this->myActiveDialogBox = (QDialog*)aDlg ;
1898 //=======================================================================
1899 // function : GetActiveStudy()
1901 //=======================================================================
1902 QAD_Study* GeometryGUI::GetActiveStudy()
1904 return this->myActiveStudy ;
1908 //=======================================================================
1909 // function : GetActiveDesktop()
1911 //=======================================================================
1912 QAD_Desktop* GeometryGUI::GetDesktop()
1914 return this->myDesktop ;
1918 //=====================================================================================
1919 // function : OnSubShapeGetAll()
1920 // purpose : Explode a shape in all sub shapes with a SubShapeType
1921 //=====================================================================================
1922 bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
1924 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1925 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
1926 if ( theObj->_is_nil() ) {
1927 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
1931 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1932 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
1933 SALOMEDS::GenericAttribute_var anAttr;
1934 SALOMEDS::AttributeName_var aName;
1935 SALOMEDS::AttributeIOR_var anIOR;
1936 SALOMEDS::AttributePixMap_var aPixmap;
1938 /* We create a sub object for each sub shape as attribute of the main object */
1939 /* Each sub object contains list (length=1) containing its index in the main shape */
1940 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
1941 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
1942 GEOM::GEOM_Shape_var aResult ;
1945 listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType );
1946 if( listGeomShapes->length() < 1 ) {
1947 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1951 catch (const SALOME::SALOME_Exception& S_ex) {
1952 QtCatchCorbaException(S_ex);
1955 /* open transaction */
1956 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
1959 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
1960 TopoDS_Shape mainShape;
1963 if ( aShape->IsMainShape() ) {
1964 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
1967 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
1970 /* Loop on each sub shape created */
1971 /* int i = 1 ; /* index for the nameType */
1972 for( int j=0; j<listGeomShapes->length(); j++) {
1974 /* Get each sub shape extracted CORBA and OCC */
1975 aResult = listGeomShapes[j] ;
1976 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
1979 myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1983 // NRI : Following lines are commented according to bugID SAL695 (see history)
1984 // BRepCheck_Analyzer anAnalyzer(S);
1985 // if(!anAnalyzer.IsValid()) {
1986 // myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
1987 // MESSAGE("#### An exploded shape number "<< j << " is not valid");
1992 /* Set the nameType of sub shape */
1993 char* nameG = (char *)malloc(20);
1994 Standard_CString Type;
1995 if ( GetShapeTypeString(S, Type) ) {
1996 aResult->NameType( Type );
1997 sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) );
2000 aResult->NameType( tr("GEOM_SHAPE") );
2001 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2003 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2005 bool allreadyexist = false;
2007 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2008 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2009 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2011 Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG );
2012 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2014 MESSAGE ( "SO->_is_nil() " << SO->_is_nil() )
2016 if ( SO->_is_nil() ) {
2017 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2018 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2019 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2020 aName->SetValue(nameG);
2021 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2022 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2023 anIOR->SetValue(aResult->Name());
2025 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2026 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2027 MESSAGE( " Type " << S.ShapeType() )
2028 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2029 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2030 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2031 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2032 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2033 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2034 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2035 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2036 } else if ( S.ShapeType() == TopAbs_FACE ) {
2037 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2038 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2039 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2040 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2041 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2042 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2043 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2046 MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() )
2048 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2049 aStudyBuilder->Addreference(newObj1, newObj);
2050 IO->setEntry(newObj->GetID());
2052 aResult->StudyShapeId( newObj->GetID() );
2054 allreadyexist = true;
2055 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2056 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2057 aStudyBuilder->Addreference(newObj1, SO);
2058 IO->setEntry(SO->GetID());
2059 aResult->StudyShapeId( SO->GetID() );
2063 result->setIO( IO );
2064 result->setName( nameG );
2065 if ( !allreadyexist )
2066 ic->Display(result);
2068 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2069 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
2071 int themode = myRenderInter->GetDisplayMode();
2072 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2073 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
2075 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM");
2077 if ( SO->_is_nil() ) {
2078 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2079 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2080 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2081 anIOR->SetValue(aResult->Name());
2082 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2083 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2084 aName->SetValue(nameG);
2086 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2087 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2088 if ( S.ShapeType() == TopAbs_COMPOUND ) {
2089 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2090 } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
2091 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2092 } else if ( S.ShapeType() == TopAbs_SOLID ) {
2093 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2094 } else if ( S.ShapeType() == TopAbs_SHELL ) {
2095 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2096 } else if ( S.ShapeType() == TopAbs_FACE ) {
2097 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2098 } else if ( S.ShapeType() == TopAbs_WIRE ) {
2099 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2100 } else if ( S.ShapeType() == TopAbs_EDGE ) {
2101 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2102 } else if ( S.ShapeType() == TopAbs_VERTEX ) {
2103 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2106 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2107 aStudyBuilder->Addreference(newObj1, newObj);
2108 IO->setEntry(newObj->GetID());
2110 allreadyexist = true;
2111 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2112 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2113 aStudyBuilder->Addreference(newObj1, SO);
2114 IO->setEntry(SO->GetID());
2118 if ( !allreadyexist ) {
2119 vtkActorCollection* theActors =
2120 GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
2121 theActors->InitTraversal();
2122 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
2123 while(!(anActor==NULL)) {
2124 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
2125 GActor->setIO( IO );
2126 GActor->setName( nameG );
2127 theRenderer->AddActor(GActor);
2129 anActor = (vtkActor*)theActors->GetNextActor();
2135 /* commit transaction */
2138 myActiveStudy->updateObjBrowser();
2139 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2145 //=====================================================================================
2146 // function : GetIndexSubShapeSelected()
2147 // purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType
2148 // : Method used by Dialogs
2149 //=====================================================================================
2150 bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
2151 const int SubShapeType,
2152 GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
2153 Standard_Integer& aLocalContextId,
2154 bool& myUseLocalContext )
2156 //* Test the type of viewer */
2157 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2161 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2162 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2165 int nbSelected = ic->NbSelected();
2166 ListOfID.length(nbSelected);
2169 //***************** DEFINE INDEX OF EACH SELECTION *********************//
2171 ic->InitSelected(); /* to restart */
2172 while( ic->MoreSelected() ) {
2174 /* Find index of sub shape into main shape */
2175 TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) );
2177 bool found = false ;
2178 while ( Exp.More() ) {
2179 if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) {
2187 /* Manage local context from DialogBox */
2188 ic->CloseLocalContext(aLocalContextId) ;
2189 myUseLocalContext = false ;
2192 ListOfID[i] = index ;
2196 //***************** END *********************//
2198 /* Manage local context from DialogBox */
2199 ic->CloseLocalContext(aLocalContextId) ;
2200 myUseLocalContext = false ;
2206 //=====================================================================================
2207 // function : OnSubShapeGetSelected()
2209 //=====================================================================================
2210 bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
2211 const char* ShapeTopoIOR,
2212 const int SubShapeType,
2213 Standard_Integer& aLocalContextId,
2214 bool& myUseLocalContext )
2216 //* Test the type of viewer */
2217 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2221 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2222 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2223 if ( theObj->_is_nil() ) {
2224 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2229 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2230 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2232 if( myUseLocalContext == false ) {
2233 /* local context is from DialogBox */
2234 MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
2238 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2239 TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
2241 TopoDS_Shape mainShape;
2244 if ( aShape->IsMainShape() ) {
2245 mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
2248 aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
2251 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2253 int nbSelected = ic->NbSelected();
2254 ListOfID->length(nbSelected);
2256 TopoDS_Compound compound;
2257 ic->InitSelected(); /* to init again */
2259 B.MakeCompound( compound );
2262 /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
2263 /* the compound is homogenous by selection */
2264 while(ic->MoreSelected()) {
2265 int index = GetIndex( ic->SelectedShape(), mainShape, SubShapeType );
2266 ListOfID[i] = index ;
2267 B.Add( compound, ic->SelectedShape() );
2272 /* Test if user has selected sub shapes */
2273 if( ListOfID->length() < 1 )
2276 GEOM::GEOM_Shape_var aResult ;
2278 aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID );
2280 catch (const SALOME::SALOME_Exception& S_ex) {
2281 QtCatchCorbaException(S_ex);
2284 /* local context from DialogBox */
2285 ic->CloseLocalContext(aLocalContextId) ;
2286 myUseLocalContext = false ;
2288 char* nameG = (char *)malloc(20);
2289 Standard_CString Type;
2291 Handle(GEOM_AISShape) result;
2292 Handle(GEOM_InteractiveObject) IO ;
2294 // if ( ! SObjectExist(theObj, aResult->Name()) ) {
2295 if ( nbSelected == 1 ) {
2296 TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) );
2298 if ( GetShapeTypeString(Exp.Current(),Type) ) {
2299 aResult->NameType( Type );
2300 sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) );
2302 aResult->NameType( tr("GEOM_SHAPE") );
2303 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2305 result = new GEOM_AISShape( Exp.Current(), nameG );
2306 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2310 if ( GetShapeTypeString(compound,Type) ) {
2311 aResult->NameType( Type );
2312 sprintf (nameG, "%s_%d", Type, this->myNbGeom++ );
2314 aResult->NameType( tr("GEOM_SHAPE") );
2315 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2317 result = new GEOM_AISShape( compound, nameG );
2318 IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
2321 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
2323 /* open transaction */
2324 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
2327 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2328 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
2329 SALOMEDS::GenericAttribute_var anAttr;
2330 SALOMEDS::AttributeName_var aName;
2331 SALOMEDS::AttributeIOR_var anIOR;
2332 SALOMEDS::AttributePixMap_var aPixmap;
2334 bool allreadyexist = false;
2336 if ( SO->_is_nil() ) {
2337 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
2338 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
2339 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2340 anIOR->SetValue(aResult->Name());
2341 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
2342 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2343 aName->SetValue(result->getName());
2345 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
2346 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2347 if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) {
2348 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
2349 } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) {
2350 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
2351 } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) {
2352 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
2353 } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) {
2354 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
2355 } else if ( result->Shape().ShapeType() == TopAbs_FACE ) {
2356 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
2357 } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) {
2358 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
2359 } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) {
2360 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
2361 } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) {
2362 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
2365 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
2366 aStudyBuilder->Addreference(newObj1, newObj);
2368 IO->setEntry(newObj->GetID());
2369 aResult->StudyShapeId(newObj->GetID());
2371 allreadyexist = true;
2372 if ( ! SObjectExist(theObj, aResult->Name()) ) {
2373 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
2374 aStudyBuilder->Addreference(newObj1, SO);
2376 IO->setEntry(SO->GetID());
2377 aResult->StudyShapeId(SO->GetID());
2381 /* commit transaction */
2384 result->setIO( IO );
2385 result->setName( nameG );
2387 if ( !allreadyexist )
2388 ic->Display(result);
2390 this->OnDisplayAll(true);
2391 myActiveStudy->updateObjBrowser();
2392 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2398 //=====================================================================================
2399 // function : OnSuppressFaces()
2400 // purpose : To suppress faces from a shape
2401 // : The result is one or more shells/faces as main shapes !
2402 //=====================================================================================
2403 bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
2404 const char* ShapeTopoIOR,
2405 const Standard_Integer& aLocalContextId,
2406 bool& myUseLocalContext )
2408 /* Test the type of viewer */
2409 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2413 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2414 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
2415 if ( theObj->_is_nil() ) {
2416 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
2420 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2421 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
2423 if( myUseLocalContext == false ) {
2424 /* local context is from DialogBox */
2425 MESSAGE("Error : No local context opened for suppress faces method" << endl ) ;
2429 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
2431 int nbSelected = ic->NbSelected();
2432 ListOfID->length(nbSelected);
2434 /* Create a list of indices of faces to be suppressed */
2436 const int SubShapeType = 4 ; /* GEOM::FACE type */
2437 ic->InitSelected(); /* to repositioning at beginning */
2438 while( ic->MoreSelected() ) {
2439 int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
2440 ListOfID[i] = index ;
2445 /* Close local context opened in DialogBox */
2446 ic->CloseLocalContext(aLocalContextId) ;
2447 myUseLocalContext = false ;
2449 /* Here is the main shape */
2450 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2451 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
2453 /* Call geom method that return a list of shells/faces as result of suppress */
2455 listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID );
2457 catch (const SALOME::SALOME_Exception& S_ex) {
2458 QtCatchCorbaException(S_ex);
2461 /* Test list of shells/faces */
2462 if( listGeomShapes->length() < 1 ) {
2466 /* Loop on each object created */
2467 for( int i=0; i<listGeomShapes->length(); i++ ) {
2469 GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ;
2470 TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace );
2476 char* nameG = (char *)malloc(20);
2477 Standard_CString Type;
2478 if ( GetShapeTypeString(S, Type) ) {
2479 aShellOrFace->NameType( Type );
2480 sprintf (nameG, "%s_%d", Type, this->myNbGeom++);
2483 aShellOrFace->NameType( tr("GEOM_SHAPE") );
2484 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
2487 /* Display with name */
2488 if( !Display( aShellOrFace, nameG) ) {
2489 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
2494 myDesktop->putInfo (tr("GEOM_PRP_READY"));
2499 //=====================================================================================
2500 // function : OnSuppressHole()
2501 // purpose : To suppress an hole on a shape 'ShapeTopo'.
2502 // : 'ListOfIdEndFace' may be an empty list.
2503 // : This means that hole do not traverse ShapeTopo.
2504 // : Warning : the hole to be suppressed must be defined by one or two single closed wires !
2505 //=====================================================================================
2506 bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR,
2507 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
2508 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
2509 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace )
2511 /* Test the type of viewer */
2512 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2517 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2518 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ;
2520 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2521 Standard_CString type;
2522 GetShapeTypeString(S,type);
2523 aResult->NameType( type );
2525 if ( Display( aResult, "" ) )
2526 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2528 catch (const SALOME::SALOME_Exception& S_ex) {
2529 QtCatchCorbaException(S_ex);
2535 //=====================================================================================
2536 // function : OnSuppressHolesInFaceOrShell()
2537 // purpose : To suppress one or more holes on a face
2538 // : 'ListOfIdWires' contains indices or wires/holes.
2539 //=====================================================================================
2540 bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
2541 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires )
2543 /* Test the type of viewer */
2544 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
2549 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
2550 GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ;
2552 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
2553 Standard_CString type;
2554 GetShapeTypeString(S,type);
2555 aResult->NameType( type );
2557 if ( Display( aResult, "") )
2558 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
2560 catch (const SALOME::SALOME_Exception& S_ex) {
2561 QtCatchCorbaException(S_ex);
2568 //=======================================================================
2569 // function : activeStudyChanged()
2571 //=======================================================================
2572 void GeometryGUI::activeStudyChanged( QAD_Desktop* parent )
2574 MESSAGE ("GeometryGUI::activeStudyChanged init.")
2575 /* Create or retrieve an object GeomGUI */
2576 GeometryGUI::GetOrCreateGeometryGUI(parent);
2579 if (GeomGUI->myState == CURRENT_SKETCH) {
2580 GeomGUI->mySketcher.Clear();
2581 GeomGUI->ResetState();
2584 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2585 bool ViewOCC = false;
2586 if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
2589 Mb->setItemEnabled( 312, ViewOCC); //Sketch
2590 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
2591 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
2593 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2594 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2596 GeomGUI->EraseSimulationShape() ;
2597 GeomGUI->EmitSignalCloseAllDialogs() ;
2601 // GeomGUI->SetSettings( parent );
2602 // MESSAGE ("GeometryGUI::activeStudyChanged done.")
2607 //=======================================================================
2608 // function : DefineDlgPosition()
2609 // purpose : Define x and y the default position for a dialog box
2610 //=======================================================================
2611 bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
2613 /* Here the position is on the bottom right corner - 10 */
2614 QAD_Desktop* PP = QAD_Application::getDesktop() ;
2615 x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
2616 y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
2620 //=======================================================================
2621 // function : OnGUIEvent() [static]
2622 // purpose : manage all events on GUI
2623 //=======================================================================
2624 bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
2626 /* Create or retrieve an object GeomGUI */
2627 GeometryGUI::GetOrCreateGeometryGUI(parent);
2629 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
2630 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
2632 OCCViewer_Viewer3d* v3d;
2633 Handle(AIS_InteractiveContext) ic;
2634 vtkRenderer* Renderer;
2636 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
2638 bool ViewOCC = false;
2640 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2641 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
2642 ic = v3d->getAISContext();
2644 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2645 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2646 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2648 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2649 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2651 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2652 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
2654 // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER,
2655 Mb->setItemEnabled( 312, ViewOCC);//Sketch
2656 Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
2657 Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
2659 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
2660 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
2665 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)
2668 switch (theCommandID)
2671 GeomGUI->OnEditCopy();
2675 GeomGUI->OnEditDelete();
2680 GeomGUI->SetState(111);
2682 GeomGUI->ResetState();
2687 GeomGUI->SetState(112);
2689 GeomGUI->ResetState();
2692 case 113: // IMPORT STEP
2694 GeomGUI->SetState(113);
2696 GeomGUI->ResetState();
2700 case 121: // EXPORT BREP
2702 GeomGUI->SetState(121);
2704 GeomGUI->ResetState();
2708 case 122: // EXPORT IGES
2710 GeomGUI->SetState(122);
2712 GeomGUI->ResetState();
2716 case 123: // EXPORT STEP
2718 GeomGUI->SetState(123);
2720 GeomGUI->ResetState();
2724 case 303: // EXPLODE : use ic
2726 GeomGUI->EmitSignalDeactivateDialog() ;
2727 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2728 GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ;
2732 case 304: // GEOM::EDGE
2734 GeomGUI->EmitSignalDeactivateDialog() ;
2735 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2736 GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ;
2740 case 305: // GEOM::WIRE
2742 GeomGUI->EmitSignalDeactivateDialog() ;
2743 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2744 GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ;
2748 case 306: // GEOM::FACE
2750 GeomGUI->EmitSignalDeactivateDialog() ;
2751 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2752 GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ;
2756 case 308: // GEOM::COMPOUND
2758 GeomGUI->EmitSignalDeactivateDialog() ;
2759 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2760 GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ;
2764 case 309: // SUPPRESS FACES : use ic
2766 GeomGUI->EmitSignalDeactivateDialog() ;
2767 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2768 GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ;
2772 case 314: // SUPPRESS HOLES : use ic
2774 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
2775 GeomGUI->EmitSignalDeactivateDialog() ;
2776 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2777 GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ;
2780 GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
2786 GeomGUI->EmitSignalDeactivateDialog() ;
2787 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2788 GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ;
2792 case 502: // ORIENTATION
2794 GeomGUI->EmitSignalDeactivateDialog() ;
2795 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2796 GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ;
2800 case 601: // PROPERTIES (Length, surface, volume)
2802 GeomGUI->EmitSignalDeactivateDialog() ;
2803 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2804 GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ;
2808 case 604: // CDG : Center of mass
2810 GeomGUI->EmitSignalDeactivateDialog() ;
2811 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2812 GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ;
2816 case 605: // INERTIA
2818 GeomGUI->EmitSignalDeactivateDialog() ;
2819 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2820 GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ;
2824 case 607: // MAXTOLERANCE
2826 GeomGUI->EmitSignalDeactivateDialog() ;
2827 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2828 GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ;
2834 GeomGUI->EmitSignalDeactivateDialog() ;
2835 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2836 GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ;
2840 case 609: // CHECKSHAPE
2842 GeomGUI->EmitSignalDeactivateDialog() ;
2843 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
2844 GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ;
2848 case 701: // SETTINGS - COPY
2851 QMenuItem* item = parent->menuBar()->findItem(701,&pp);
2852 bool check = !pp->isItemChecked(701);
2853 pp->setItemChecked(701,check);
2854 Settings_Copy = check;
2855 QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy );
2859 case 702: // SETTINGS - ADD IN STUDY
2862 QMenuItem* item = parent->menuBar()->findItem(702,&pp);
2863 bool check = !pp->isItemChecked(702);
2864 pp->setItemChecked(702,check);
2865 Settings_AddInStudy = check;
2867 QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy );
2871 case 703: // SETTINGS - SHADING COLOR
2873 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2876 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
2877 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
2878 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
2880 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) {
2881 color = QColor (SCr.toInt(),
2885 Quantity_Color Default = Quantity_Color();
2886 color = QColor ( (int)Default.Red() * 255.0,
2887 (int)Default.Green()* 255.0,
2888 (int)Default.Blue() * 255.0 );
2891 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
2892 if ( c.isValid() ) {
2893 GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0,
2898 AIS_ListOfInteractive List;
2899 ic->DisplayedObjects(List);
2900 AIS_ListOfInteractive List1;
2901 ic->ObjectsInCollector(List1);
2904 AIS_ListIteratorOfListOfInteractive ite(List);
2905 while (ite.More()) {
2906 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
2907 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
2908 aSh->SetShadingColor( GeomGUI->myShadingColor );
2909 ic->Redisplay( aSh, Standard_True, Standard_True);
2914 ic->UpdateCurrentViewer();
2916 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() );
2917 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() );
2918 QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() );
2924 case 704: // SETTINGS - ISOS
2926 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2929 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
2930 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
2931 if ( !IsoU.isEmpty() )
2932 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
2935 if ( !IsoV.isEmpty() )
2936 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
2940 GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(),
2941 tr("GEOM_MEN_ISOS"), TRUE );
2942 int UIso = IsoU.toInt();
2943 int VIso = IsoV.toInt();
2945 NbIsosDlg->SpinBoxU->setValue(UIso) ;
2946 NbIsosDlg->SpinBoxV->setValue(VIso) ;
2948 if ( NbIsosDlg->exec() ) {
2949 UIso = NbIsosDlg->SpinBoxU->text().toInt() ;
2950 VIso = NbIsosDlg->SpinBoxV->text().toInt() ;
2952 ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
2953 ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
2954 QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */
2955 QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */
2958 AIS_ListOfInteractive List;
2959 ic->DisplayedObjects(List);
2960 AIS_ListOfInteractive List1;
2961 ic->ObjectsInCollector(List1);
2964 AIS_ListIteratorOfListOfInteractive ite(List);
2966 if ( ic->NbCurrents() )
2967 while (ite.More()) {
2968 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
2970 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
2971 Handle (AIS_Drawer) CurDrawer;
2972 CurDrawer = aSh->Attributes();
2973 CurDrawer->UIsoAspect()->SetNumber( UIso );
2974 CurDrawer->VIsoAspect()->SetNumber( VIso );
2975 ic->SetLocalAttributes(aSh, CurDrawer);
2980 ic->UpdateCurrentViewer();
2984 case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES
2986 //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
2989 QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
2990 if( step.isEmpty() )
2993 Standard_Boolean res = false ;
2994 double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ;
2996 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ;
2998 /* Emit signal to GeometryGUI_SpinBoxes */
2999 GeomGUI->SignalDefaultStepValueChanged( dd ) ;
3002 parent->putInfo(tr("GEOM_PRP_ABORT"));
3007 case 801: // ADD IN STUDY - POPUP VIEWER
3009 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3010 const SALOME_ListIO& ListSelected = Sel->StoredIObjects();
3011 SALOME_ListIteratorOfListIO It( ListSelected );
3012 for ( ; It.More(); It.Next() ) {
3013 Handle(SALOME_InteractiveObject) IObject = It.Value();
3014 GeomGUI->AddInStudy(true, IObject);
3016 /* Is set on the dialog box */
3017 QApplication::restoreOverrideCursor();
3023 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3024 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3025 for ( ; It.More(); It.Next() ) {
3026 Handle(SALOME_InteractiveObject) IObject = It.Value();
3028 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3029 SALOMEDS::GenericAttribute_var anAttr;
3030 SALOMEDS::AttributeName_var aName;
3031 if ( !obj->_is_nil() ) {
3032 if (obj->FindAttribute(anAttr, "AttributeName")) {
3033 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3035 QString nm = QString( aName->Value() );
3036 nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
3037 if ( !nm.isEmpty() ) {
3038 QApplication::setOverrideCursor( Qt::waitCursor );
3039 GeomGUI->myActiveStudy->renameIObject( IObject, nm );
3040 QApplication::restoreOverrideCursor();
3048 case 903: // DISPLAY OBJECT BROWSER
3050 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3052 QApplication::setOverrideCursor( Qt::waitCursor );
3054 SALOMEDS::SObject_var fatherSF =
3055 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3057 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3058 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3060 for(;It.More();It.Next()) {
3061 Handle(SALOME_InteractiveObject) IObject = It.Value();
3062 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3064 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3066 SALOMEDS::GenericAttribute_var anAttr;
3067 SALOMEDS::AttributeName_var aName;
3068 SALOMEDS::AttributeIOR_var anIOR;
3070 if(myRenderInter->isInViewer(IObject)) {
3071 myRenderInter->Display(IObject);
3075 if ( !obj->_is_nil() ) {
3076 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3077 // this SObject may be GEOM module root SObject
3078 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3079 bool useSubItems = false;
3080 while (anIter->More() && !useSubItems) {
3081 SALOMEDS::SObject_var subobj = anIter->Value();
3082 SALOMEDS::GenericAttribute_var aTmpAttr;
3083 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3087 } else anIter->Next();
3090 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3091 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3092 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3093 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3095 if (obj->FindAttribute(anAttr, "AttributeName")) {
3096 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3098 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3099 vtkActorCollection* theAllActors = theRenderer->GetActors();
3100 theAllActors->InitTraversal();
3101 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3102 Handle(SALOME_InteractiveObject) anIObj;
3103 // don't create new study object if it already exists
3104 bool isDisplayed = false;
3105 while(!(actor==NULL)) {
3106 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3108 if (Gactor->hasIO()) {
3109 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3111 anIObj = Gactor->getIO();
3112 if (!anIObj.IsNull()) myRenderInter->Display(anIObj);
3116 actor=(vtkActor*)(theAllActors->GetNextActor());
3120 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3123 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3124 aStudyBuilder->Addreference(newObj1, obj);
3125 // commit transaction
3128 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
3129 int themode = myRenderInter->GetDisplayMode();
3131 vtkActorCollection* theActors =
3132 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
3133 theActors->InitTraversal();
3134 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
3135 while(!(anActor==NULL)) {
3136 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
3137 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
3138 IO->setEntry(obj->GetID());
3139 GActor->setIO( IO );
3140 GActor->setName( IObject->getName() );
3142 theRenderer->AddActor(GActor);
3144 anActor = (vtkActor*)theActors->GetNextActor();
3148 // next item iteration
3151 anAttr = SALOMEDS::GenericAttribute::_nil();
3152 while (anIter->More() && anAttr->_is_nil()) {
3153 SALOMEDS::SObject_var subobject = anIter->Value();
3154 SALOMEDS::GenericAttribute_var aTmpAttribute;
3155 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3156 anAttr = aTmpAttribute;
3158 } else anIter->Next();
3160 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3166 GeomGUI->myActiveStudy->updateObjBrowser( true );
3167 QApplication::restoreOverrideCursor();
3169 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3170 QApplication::setOverrideCursor( Qt::waitCursor );
3172 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3173 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3174 for(;It.More();It.Next()) {
3175 Handle(SALOME_InteractiveObject) IObject = It.Value();
3177 SALOMEDS::SObject_var fatherSF =
3178 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
3179 SALOMEDS::GenericAttribute_var anAttr;
3180 SALOMEDS::AttributeName_var aName;
3181 SALOMEDS::AttributeIOR_var anIOR;
3183 if ( v3d->isInViewer( IObject, true ) ) {
3184 Standard_Boolean found;
3185 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3188 ic->AddOrRemoveCurrentObject(aSh, true);
3192 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
3193 if ( !obj->_is_nil() ) {
3194 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3195 // this SObject may be GEOM module root SObject
3196 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3197 bool useSubItems = false;
3198 while (anIter->More() && !useSubItems) {
3199 SALOMEDS::SObject_var subobj = anIter->Value();
3200 SALOMEDS::GenericAttribute_var aTmpAttr;
3201 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3205 } else anIter->Next();
3207 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3208 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3209 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3210 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3211 if (obj->FindAttribute(anAttr, "AttributeName")) {
3212 aName = SALOMEDS::AttributeName::_narrow(anAttr);
3213 // searchin for already displayed objects with the same shape
3214 AIS_ListOfInteractive aDisplayed;
3215 ic->DisplayedObjects(aDisplayed);
3216 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3217 Handle(AIS_Shape) anAISShape;
3218 for(;anIObjects.More();anIObjects.Next()) {
3219 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3220 if (!anAISShape.IsNull()) {
3221 if (anAISShape->Shape().IsSame(Shape)) break;
3222 anAISShape.Nullify();
3225 if (!anAISShape.IsNull()) {
3226 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape);
3230 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
3233 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
3234 aStudyBuilder->Addreference(newObj1, obj);
3235 // commit transaction
3239 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
3240 aSh->SetShadingColor( GeomGUI->myShadingColor );
3241 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
3244 IO->setEntry(obj->GetID());
3246 aSh->setName( aName->Value() );
3248 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true);
3251 // next item iteration
3254 anAttr=SALOMEDS::GenericAttribute::_nil();
3255 while (anIter->More() && anAttr->_is_nil()) {
3256 SALOMEDS::SObject_var subobject = anIter->Value();
3257 SALOMEDS::GenericAttribute_var aTmpAttribute;
3258 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3259 anAttr = aTmpAttribute;
3261 } else anIter->Next();
3263 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3269 GeomGUI->myActiveStudy->updateObjBrowser( true );
3270 QApplication::restoreOverrideCursor();
3277 GeomGUI->EmitSignalDeactivateDialog() ;
3278 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3279 GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ;
3285 GeomGUI->EmitSignalDeactivateDialog() ;
3286 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3287 GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ;
3291 case 3013: // CIRCLE
3293 GeomGUI->EmitSignalDeactivateDialog() ;
3294 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3295 GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ;
3301 GeomGUI->EmitSignalDeactivateDialog() ;
3302 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3303 GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ;
3307 case 3016: // VECTOR
3309 GeomGUI->EmitSignalDeactivateDialog() ;
3310 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3311 GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ;
3317 GeomGUI->EmitSignalDeactivateDialog() ;
3318 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3319 GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ;
3323 case 3018: // WORKING PLANE
3325 GeomGUI->EmitSignalDeactivateDialog() ;
3326 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3327 GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ;
3331 case 312: // SKETCHER
3333 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
3336 GeomGUI->EmitSignalDeactivateDialog() ;
3338 ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
3340 GeomGUI->mySketcher = Sketch( v3d->getViewer3d() );
3341 GeomGUI->SetState(CURRENT_SKETCH);
3343 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3346 QMenuItem* item = Mb->findItem(10010,&pp);
3347 GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
3348 item = Mb->findItem(10011,&pp);
3349 GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
3350 item = Mb->findItem(10012,&pp);
3351 GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
3352 item = Mb->findItem(10013,&pp);
3353 GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
3354 item = Mb->findItem(10014,&pp);
3355 GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
3357 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3358 item = Mb->findItem(3133,&pp);
3359 pp->setItemChecked(3133,false);
3360 item = Mb->findItem(3134,&pp);
3361 pp->setItemChecked(3134,false);
3367 GeomGUI->EmitSignalDeactivateDialog() ;
3368 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3369 GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ;
3373 case 3022: // CYLINDER
3375 GeomGUI->EmitSignalDeactivateDialog() ;
3376 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3377 GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ;
3381 case 3023: // SPHERE
3383 GeomGUI->EmitSignalDeactivateDialog() ;
3384 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3385 GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ;
3391 GeomGUI->EmitSignalDeactivateDialog() ;
3392 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3393 GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ;
3399 GeomGUI->EmitSignalDeactivateDialog() ;
3400 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3401 GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ;
3410 case 3133: // sketcher
3412 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3414 QMenuItem* item = Mb->findItem(3133,&pp);
3415 pp->setItemChecked(3133,!pp->isItemChecked(3133));
3416 if (pp->isItemChecked(3133) == true)
3417 GeomGUI->mySketcher.SetTransitionStatus(TANGENT);
3419 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3421 pp->setItemChecked(3134,false);
3425 case 3134: // sketcher
3427 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
3429 QMenuItem* item = Mb->findItem(3134,&pp);
3430 pp->setItemChecked(3134,!pp->isItemChecked(3134));
3431 if (pp->isItemChecked(3134) == true)
3432 GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR);
3434 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
3436 pp->setItemChecked(3133,false);
3442 GeomGUI->EmitSignalDeactivateDialog() ;
3443 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3444 GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ;
3448 case 4012: // COMMON
3450 GeomGUI->EmitSignalDeactivateDialog() ;
3451 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3452 GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ;
3458 GeomGUI->EmitSignalDeactivateDialog() ;
3459 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3460 GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ;
3464 case 4014: // SECTION
3466 GeomGUI->EmitSignalDeactivateDialog() ;
3467 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3468 GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ;
3472 case 4021: // TRANSLATION
3474 GeomGUI->EmitSignalDeactivateDialog() ;
3475 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3476 GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ;
3480 case 4022: // ROTATION
3482 GeomGUI->EmitSignalDeactivateDialog() ;
3483 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3484 GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ;
3488 case 4030: // MULTI TRANSLATION
3490 GeomGUI->EmitSignalDeactivateDialog() ;
3491 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3492 GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ;
3496 case 4040: // MULTI ROTATION
3498 GeomGUI->EmitSignalDeactivateDialog() ;
3499 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3500 GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ;
3504 case 4023: // MIRROR
3506 GeomGUI->EmitSignalDeactivateDialog() ;
3507 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3508 GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ;
3514 GeomGUI->EmitSignalDeactivateDialog() ;
3515 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3516 GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ;
3520 case 4025: // PARTITION
3522 GeomGUI->EmitSignalDeactivateDialog() ;
3523 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3524 GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ;
3528 case 4026: // ARCHIMEDE
3530 GeomGUI->EmitSignalDeactivateDialog() ;
3531 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3532 GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ;
3536 case 4027: // FILLET
3538 GeomGUI->EmitSignalDeactivateDialog() ;
3539 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3540 GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ;
3544 case 4028: // CHAMFER
3546 GeomGUI->EmitSignalDeactivateDialog() ;
3547 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3548 GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ;
3554 GeomGUI->EmitSignalDeactivateDialog() ;
3555 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3556 GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ;
3562 GeomGUI->EmitSignalDeactivateDialog() ;
3563 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3564 GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ;
3568 case 4033: // FILLING
3570 GeomGUI->EmitSignalDeactivateDialog() ;
3571 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3572 GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ;
3578 GeomGUI->EmitSignalDeactivateDialog() ;
3579 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3580 GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ;
3584 case 5001: // CHECK GEOMETRY
3586 QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor();
3587 PyEditor->setText("from GEOM_usinggeom import *\n");
3588 PyEditor->setText(">>> ");
3589 PyEditor->handleReturn();
3593 case 6021: // SHADING - WIREFRAME
3595 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3596 VTKViewer_RenderWindowInteractor* myRenderInter=
3597 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3599 QApplication::setOverrideCursor(waitCursor);
3601 int themode = myRenderInter->GetDisplayMode();
3603 myRenderInter->SetDisplayMode(1);
3604 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3606 myRenderInter->SetDisplayMode(0);
3607 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3610 QApplication::restoreOverrideCursor();
3612 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3613 AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode();
3614 QApplication::setOverrideCursor( Qt::waitCursor );
3615 AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
3617 AIS_ListOfInteractive List;
3618 ic->DisplayedObjects(List);
3619 AIS_ListOfInteractive List1;
3620 ic->ObjectsInCollector(List1);
3623 AIS_ListIteratorOfListOfInteractive ite(List);
3624 while (ite.More()) {
3625 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
3626 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
3627 ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
3632 ic->SetDisplayMode( newmode, Standard_False);
3634 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
3636 GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
3638 QApplication::restoreOverrideCursor();
3643 case 6022: // DISPLAY ALL
3645 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3647 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll();
3648 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
3649 GeomGUI->OnDisplayAll();
3653 case 6023: // DISPLAY ONLY
3654 case 8023: // DISPLAY ONLY - POPUP VIEWER
3656 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3658 GeomGUI->OnVTKDisplayOnly();
3660 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
3661 GeomGUI->OnDisplayOnly();
3665 case 6024: // ERASE ALL
3667 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3669 ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
3671 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3672 ic->EraseAll(Standard_True, Standard_False);
3673 ic->Display(v3d->getTrihedron());
3676 //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3677 //NRI Sel->ClearInteractiveObjects();
3681 case 6025 : // ERASE ONLY
3682 case 8022 : // ERASE - POPUP VIEWER
3684 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3685 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
3687 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3688 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3689 Handle(SALOME_InteractiveObject) anIObject;
3690 for(;It.More();It.Next()) {
3691 anIObject = It.Value();
3692 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3694 if(myRenderInter->isInViewer(anIObject)) {
3695 myRenderInter->Erase(anIObject);
3697 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3698 SALOMEDS::GenericAttribute_var anAttr;
3699 SALOMEDS::AttributeIOR_var anIOR;
3700 if ( !obj->_is_nil() ) {
3701 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3702 // this SObject may be GEOM module root SObject
3703 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3704 bool useSubItems = false;
3705 while (anIter->More() && !useSubItems) {
3706 SALOMEDS::SObject_var subobj = anIter->Value();
3707 SALOMEDS::GenericAttribute_var aTmpAttr;
3708 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3712 } else anIter->Next();
3715 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3716 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3717 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3718 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3719 if (obj->FindAttribute(anAttr, "AttributeName")) {
3720 // searchin for already displayed objects with the same shape
3721 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
3722 vtkActorCollection* theAllActors = theRenderer->GetActors();
3723 theAllActors->InitTraversal();
3724 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
3725 Handle(SALOME_InteractiveObject) anIObj;
3726 // don't create new study object if it already exists
3727 bool isDisplayed = false;
3728 while(!(actor==NULL)) {
3729 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
3731 if (Gactor->hasIO()) {
3732 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
3734 anIObj = Gactor->getIO();
3735 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
3739 actor=(vtkActor*)(theAllActors->GetNextActor());
3744 anAttr=SALOMEDS::GenericAttribute::_nil();
3745 while (anIter->More() && anAttr->_is_nil()) {
3746 SALOMEDS::SObject_var subobject = anIter->Value();
3747 SALOMEDS::GenericAttribute_var aTmpAttribute;
3748 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3749 anAttr = aTmpAttribute;
3751 } else anIter->Next();
3753 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3759 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3760 // for(;It.More();It.Next()) {
3761 // Handle(SALOME_InteractiveObject) IOS = It.Value();
3762 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
3764 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
3766 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3767 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3768 Handle(SALOME_InteractiveObject) anIObject;
3769 for(;It.More();It.Next()) {
3770 anIObject = It.Value();
3771 if ( v3d->isInViewer( anIObject, true ) ) {
3772 Standard_Boolean found;
3773 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
3776 ic->AddOrRemoveCurrentObject(aSh, true);
3779 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
3780 SALOMEDS::GenericAttribute_var anAttr;
3781 SALOMEDS::AttributeIOR_var anIOR;
3782 if ( !obj->_is_nil() ) {
3783 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
3784 // this SObject may be GEOM module root SObject
3785 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
3786 bool useSubItems = false;
3787 while (anIter->More() && !useSubItems) {
3788 SALOMEDS::SObject_var subobj = anIter->Value();
3789 SALOMEDS::GenericAttribute_var aTmpAttr;
3790 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
3794 } else anIter->Next();
3797 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
3798 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3799 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
3800 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
3801 if (obj->FindAttribute(anAttr, "AttributeName")) {
3802 // searchin for already displayed objects with the same shape
3803 AIS_ListOfInteractive aDisplayed;
3804 ic->DisplayedObjects(aDisplayed);
3805 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
3806 Handle(AIS_Shape) anAISShape;
3807 for(;anIObjects.More();anIObjects.Next()) {
3808 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
3809 if (!anAISShape.IsNull()) {
3810 if (anAISShape->Shape().IsSame(Shape)) break;
3811 anAISShape.Nullify();
3814 if (!anAISShape.IsNull()) {
3815 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
3820 anAttr=SALOMEDS::GenericAttribute::_nil();
3821 while (anIter->More() && anAttr->_is_nil()) {
3822 SALOMEDS::SObject_var subobject = anIter->Value();
3823 SALOMEDS::GenericAttribute_var aTmpAttribute;
3824 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
3825 anAttr = aTmpAttribute;
3827 } else anIter->Next();
3829 } else anAttr = SALOMEDS::GenericAttribute::_nil();
3836 Sel->ClearIObjects();
3841 case 6060: // BOUNDING BOX
3843 GeomGUI->EmitSignalDeactivateDialog() ;
3844 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3845 GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ;
3849 case 6061: // MIN DISTANCE
3851 GeomGUI->EmitSignalDeactivateDialog() ;
3852 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3853 GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ;
3857 case 8021: // WIREFRAME-SHADING
3859 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3861 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3863 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3864 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3866 QApplication::setOverrideCursor( Qt::waitCursor );
3867 for(;It.More();It.Next()) {
3868 Handle(SALOME_InteractiveObject) IOS = It.Value();
3869 myRenderInter->SwitchRepresentation(IOS, false);
3871 myRenderInter->Render();
3872 QApplication::restoreOverrideCursor();
3874 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3875 QApplication::setOverrideCursor( Qt::waitCursor );
3876 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3877 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3878 for(;It.More();It.Next()) {
3879 Handle(SALOME_InteractiveObject) IObject = It.Value();
3880 Standard_Boolean found;
3881 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
3882 if (!Shape.IsNull()) {
3883 AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode();
3885 mode = ( AIS_DisplayMode )ic->DisplayMode();
3887 QApplication::setOverrideCursor( Qt::waitCursor );
3888 ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
3890 QApplication::restoreOverrideCursor();
3892 ic->UpdateCurrentViewer();
3894 QApplication::restoreOverrideCursor();
3898 case 8031: // COLOR - POPUP VIEWER
3900 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3902 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
3904 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3905 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
3907 Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject();
3908 if(!FirstIOS.IsNull()) {
3910 QColor initcolor = myRenderInter->GetColor(FirstIOS);
3912 QColor c = QColorDialog::getColor( initcolor,
3913 QAD_Application::getDesktop() );
3915 if ( c.isValid() ) {
3916 QApplication::setOverrideCursor( Qt::waitCursor );
3917 for(;It.More();It.Next()) {
3918 Handle(SALOME_InteractiveObject) IOS = It.Value();
3919 myRenderInter->SetColor(IOS,c);
3922 QApplication::restoreOverrideCursor();
3925 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
3926 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3927 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
3928 Standard_Boolean found;
3929 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true);
3931 Quantity_Color CSFColor;
3932 Shape->Color( CSFColor );
3934 QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0,
3935 CSFColor.Green()* 255.0,
3936 CSFColor.Blue() * 255.0 ),
3937 QAD_Application::getDesktop() );
3939 if ( c.isValid() ) {
3940 CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
3941 QApplication::setOverrideCursor( Qt::waitCursor );
3943 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
3944 for(;It.More();It.Next()) {
3945 Handle(SALOME_InteractiveObject) IObject = It.Value();
3946 Standard_Boolean found;
3947 Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
3949 Shape->SetColor ( CSFColor );
3950 Shape->SetShadingColor ( CSFColor );
3956 QApplication::restoreOverrideCursor();
3960 case 8032: // TRANSPARENCY - POPUP VIEWER
3962 GeomGUI->EmitSignalDeactivateDialog() ;
3963 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
3964 GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ;
3968 case 8033: // ISOS - POPUP VIEWER
3970 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
3974 if ( ic->MoreCurrent() ) {
3975 Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
3976 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
3977 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
3979 if ( !IsoU.isEmpty() )
3980 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
3983 if ( !IsoV.isEmpty() )
3984 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
3988 GeometryGUI_NbIsosDlg * NbIsosDlg =
3989 new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE );
3991 NbIsosDlg->SpinBoxU->setValue(IsoU.toInt());
3992 NbIsosDlg->SpinBoxV->setValue(IsoV.toInt());
3994 if ( NbIsosDlg->exec() ) {
3995 QApplication::setOverrideCursor( Qt::waitCursor );
3996 for ( ; ic->MoreCurrent (); ic->NextCurrent () ) {
3997 Handle (AIS_Drawer) CurDrawer;
3999 CurDrawer = ic->Current()->Attributes();
4000 CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() );
4001 CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() );
4003 ic->SetLocalAttributes(CurObject, CurDrawer);
4004 ic->Redisplay(CurObject);
4009 QApplication::restoreOverrideCursor();
4013 case 9022 : // ERASE - OBJBROSER POPUP
4015 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4016 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
4018 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4019 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4020 Handle(SALOME_InteractiveObject) anIObject;
4021 for(;It.More();It.Next()) {
4022 anIObject = It.Value();
4023 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4025 // Handle(SALOME_InteractiveObject) IObject;
4026 if(myRenderInter->isInViewer(anIObject)) {
4027 myRenderInter->Erase(anIObject);
4029 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4030 SALOMEDS::GenericAttribute_var anAttr;
4031 SALOMEDS::AttributeIOR_var anIOR;
4032 if ( !obj->_is_nil() ) {
4033 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4034 // this SObject may be GEOM module root SObject
4035 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4036 bool useSubItems = false;
4037 while (anIter->More() && !useSubItems) {
4038 SALOMEDS::SObject_var subobj = anIter->Value();
4039 SALOMEDS::GenericAttribute_var aTmpAttr;
4040 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4044 } else anIter->Next();
4047 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4048 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4049 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4050 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4051 if (obj->FindAttribute(anAttr, "AttributeName")) {
4052 // searchin for already displayed objects with the same shape
4053 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4054 vtkActorCollection* theAllActors = theRenderer->GetActors();
4055 theAllActors->InitTraversal();
4056 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
4057 Handle(SALOME_InteractiveObject) anIObj;
4058 // don't create new study object if it already exists
4059 bool isDisplayed = false;
4060 while(!(actor==NULL)) {
4061 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
4063 if (Gactor->hasIO()) {
4064 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
4066 anIObj = Gactor->getIO();
4067 if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
4071 actor=(vtkActor*)(theAllActors->GetNextActor());
4076 anAttr=SALOMEDS::GenericAttribute::_nil();
4077 while (anIter->More() && anAttr->_is_nil()) {
4078 SALOMEDS::SObject_var subobject = anIter->Value();
4079 SALOMEDS::GenericAttribute_var aTmpAttribute;
4080 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4081 anAttr = aTmpAttribute;
4083 } else anIter->Next();
4085 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4090 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4091 // for(;It.More();It.Next()) {
4092 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4093 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4095 // SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
4096 // for(;It.More();It.Next()) {
4097 // Handle(SALOME_InteractiveObject) IOS = It.Value();
4098 // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
4101 else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
4103 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4104 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4105 Handle(SALOME_InteractiveObject) anIObject;
4106 for(;It.More();It.Next()) {
4107 anIObject = It.Value();
4108 if ( v3d->isInViewer( anIObject, true ) ) {
4109 Standard_Boolean found;
4110 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
4113 ic->AddOrRemoveCurrentObject(aSh, true);
4116 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4117 SALOMEDS::GenericAttribute_var anAttr;
4118 SALOMEDS::AttributeIOR_var anIOR;
4119 if ( !obj->_is_nil() ) {
4120 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
4121 // this SObject may be GEOM module root SObject
4122 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4123 bool useSubItems = false;
4124 while (anIter->More() && !useSubItems) {
4125 SALOMEDS::SObject_var subobj = anIter->Value();
4126 SALOMEDS::GenericAttribute_var aTmpAttr;
4127 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
4131 } else anIter->Next();
4134 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4135 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4136 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4137 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4138 if (obj->FindAttribute(anAttr, "AttributeName")) {
4139 // searchin for already displayed objects with the same shape
4140 AIS_ListOfInteractive aDisplayed;
4141 ic->DisplayedObjects(aDisplayed);
4142 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
4143 Handle(AIS_Shape) anAISShape;
4144 for(;anIObjects.More();anIObjects.Next()) {
4145 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
4146 if (!anAISShape.IsNull()) {
4147 if (anAISShape->Shape().IsSame(Shape)) break;
4148 anAISShape.Nullify();
4151 if (!anAISShape.IsNull()) {
4152 if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
4157 anAttr=SALOMEDS::GenericAttribute::_nil();
4158 while (anIter->More() && anAttr->_is_nil()) {
4159 SALOMEDS::SObject_var subobject = anIter->Value();
4160 SALOMEDS::GenericAttribute_var aTmpAttribute;
4161 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
4162 anAttr = aTmpAttribute;
4164 } else anIter->Next();
4166 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4172 // QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC();
4173 // Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4174 // myContext->EraseSelected();
4177 Sel->ClearIObjects();
4181 case 9023 : // DISPLAY ONLY - OBJBROSER POPUP
4183 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
4184 GeomGUI->OnVTKDisplayOnly();
4185 else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
4186 GeomGUI->OnDisplayOnly();
4190 case 9024 : // OPEN - OBJBROSER POPUP
4192 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4193 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4194 Handle(SALOME_InteractiveObject) anIObject;
4195 for(;It.More();It.Next()) {
4196 anIObject = It.Value();
4197 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
4198 SALOMEDS::AttributePersistentRef_var aPersist;
4199 SALOMEDS::AttributeIOR_var anIOR;
4200 if ( !obj->_is_nil() ) {
4201 // this SObject may be GEOM module root SObject
4202 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4203 SALOMEDS::GenericAttribute_var anAttr;
4204 bool useSubItems = false;
4205 while (anIter->More() && !useSubItems) {
4206 SALOMEDS::SObject_var subobj = anIter->Value();
4207 if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
4211 else anIter->Next();
4213 obj->FindAttribute(anAttr, "AttributePersistentRef");
4215 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
4216 if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
4217 obj->FindAttribute(anAttr, "AttributePersistentRef")) {
4219 Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","Geometry");
4220 if (!CORBA::is_nil(comp)) {
4221 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
4224 SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder();
4225 aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver);
4228 MESSAGE("Component is null");
4233 obj = anIter->Value();
4234 } else anAttr = SALOMEDS::GenericAttribute::_nil();
4241 case 10000 : // SKETCH Segment
4243 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4245 GeomGUI->OnSketchSegment();
4248 case 10001 : // SKETCH Arc
4250 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4252 GeomGUI->OnSketchArc();
4255 case 10002 : // SKETCH Set Angle
4257 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4259 GeomGUI->OnSketchSetAngle();
4262 case 10003 : // SKETCH Set X
4264 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4266 GeomGUI->OnSketchSetx();
4269 case 10004 : // SKETCH Set Y
4271 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4273 GeomGUI->OnSketchSety();
4276 case 10006 : // SKETCH Delete
4278 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4280 GeomGUI->OnSketchDelete();
4283 case 10007 : // SKETCH End
4285 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4287 GeomGUI->OnSketchEnd();
4290 case 10008 : // SKETCH Close
4292 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4294 GeomGUI->OnSketchClose();
4297 case 10010 : // SKETCH OptionsOnofflengthdimension
4299 GeomGUI->OnSketchOptionsOnofflengthdimension();
4302 case 10011 : // SKETCH OptionsOnoffangledimension
4304 GeomGUI->OnSketchOptionsOnoffangledimension();
4307 case 10012 : // SKETCH OptionsOnoffradiusdimension
4309 GeomGUI->OnSketchOptionsOnoffradiusdimension();
4312 case 10013 : // SKETCH OptionsOnoffxdimension
4314 GeomGUI->OnSketchOptionsOnoffxdimension();
4317 case 10014 : // SKETCH OptionsOnoffydimension
4319 GeomGUI->OnSketchOptionsOnoffydimension();
4325 parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) );
4333 //=======================================================================
4334 // function : ConvertClickToPoint()
4335 // purpose : Returns the point clicked in 3D view
4336 //=======================================================================
4337 gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x,
4339 Handle(V3d_View) aView )
4341 V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
4342 aView->Eye(XEye, YEye, ZEye);
4344 aView->At(XAt, YAt, ZAt);
4345 gp_Pnt EyePoint(XEye, YEye, ZEye);
4346 gp_Pnt AtPoint(XAt, YAt, ZAt);
4348 gp_Vec EyeVector(EyePoint, AtPoint);
4349 gp_Dir EyeDir(EyeVector);
4351 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
4352 Standard_Real X, Y, Z;
4353 aView->Convert(x, y, X, Y, Z);
4354 gp_Pnt ConvertedPoint(X, Y, Z);
4356 gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint);
4357 gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
4358 ConvertedPointOnPlane.Y(),
4366 //==================================================================================
4367 // function : 0nMousePress()
4368 // purpose : [static] manage mouse events
4369 //==================================================================================
4370 bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4372 MESSAGE ( "GeometryGUI::OnMousePress")
4373 GeometryGUI::GetOrCreateGeometryGUI(parent);
4375 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4378 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4379 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4380 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4382 /* Get the clicked or selected point */
4385 if ( GeomGUI->myState == CURRENT_SKETCH) {
4386 GeomGUI->mySketcher.ValidateEdge();
4387 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
4388 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
4390 QMenuItem* item = Mb->findItem(313,&pp);
4391 pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS
4393 } else if( GeomGUI->myState == POINT_METHOD ) {
4395 GeomGUI->EraseSimulationShape() ;
4396 GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ;
4398 if ( DialogPt->UseLocalContext() ) {
4400 if ( pe->state() == Qt::ShiftButton )
4401 v3d->getAISSelector()->shiftSelect(); /* Append selection */
4403 v3d->getAISSelector()->select(); /* New selection */
4405 if ( ic->MoreSelected() ) {
4406 thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) );
4409 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4412 thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
4414 if( DialogPt != 0 ) {
4415 DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */
4418 // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ;
4419 GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
4427 //=======================================================================
4428 // function : OnMouseMove()
4429 // purpose : [static] manage mouse events
4430 //=======================================================================
4431 bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4433 GeometryGUI::GetOrCreateGeometryGUI(parent);
4435 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4438 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4439 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4440 OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
4442 if ( GeomGUI->myState == CURRENT_SKETCH)
4443 GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
4449 //================================================================================
4450 // function : SetDisplayedObjectList()
4452 //================================================================================
4453 void GeometryGUI::SetDisplayedObjectList()
4455 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4458 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4459 ListDisplayedObject.Clear();
4461 Handle (AIS_InteractiveContext) aContext = v3d->getAISContext();
4462 aContext->DisplayedObjects( ListDisplayedObject );
4467 //=====================================================================================
4468 // function : OnDisplayAll()
4470 //=====================================================================================
4471 void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
4473 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4476 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4477 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4479 myContext->Display(v3d->getTrihedron());
4481 if ( !onlyPreviousDisplayedObject ) {
4482 AIS_ListOfInteractive List1;
4483 myContext->ObjectsInCollector(List1);
4484 AIS_ListIteratorOfListOfInteractive ite1(List1);
4485 while (ite1.More()) {
4486 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4487 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4488 if ( aSh->hasIO() ) {
4489 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4490 if ( v3d->isInViewer(GIO, true) ) {
4491 myContext->Display(aSh);
4498 AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject);
4499 while (ite.More()) {
4500 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4501 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4502 if ( aSh->hasIO() ) {
4503 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4504 if ( v3d->isInViewer(GIO,true) ) {
4505 myContext->Display(aSh);
4517 //=====================================================================================
4518 // function : OnVTKDisplayOnly()
4520 //=====================================================================================
4521 void GeometryGUI::OnVTKDisplayOnly()
4524 // Erase all not selected actors
4526 QApplication::setOverrideCursor( Qt::waitCursor );
4528 vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4529 vtkActorCollection* theActors = aren->GetActors();
4530 theActors->InitTraversal();
4531 vtkActor *ac = theActors->GetNextActor();
4532 while(!(ac==NULL)) {
4533 if ( ac->IsA("SALOME_Actor") ) {
4534 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
4535 if(!anActor->isHighlighted()) anActor->VisibilityOff();
4537 ac = theActors->GetNextActor();
4540 // Display selection
4541 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4542 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4543 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
4544 SALOMEDS::GenericAttribute_var anAttr;
4545 SALOMEDS::AttributeName_var aName;
4546 SALOMEDS::AttributeIOR_var anIOR;
4548 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
4549 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4551 for(;It.More();It.Next()) {
4552 Handle(SALOME_InteractiveObject) IObject = It.Value();
4553 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4555 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
4557 if(myRenderInter->isInViewer(IObject)) {
4558 myRenderInter->Display(IObject);
4562 if ( !obj->_is_nil() ) {
4563 if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
4565 // If selected object contains displayable subobjects, then do nothing
4566 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
4567 SALOMEDS::GenericAttribute_var aTmpAttr;
4569 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4570 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
4571 if (CORBA::is_nil(aShape)) continue;
4572 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
4574 if (obj->FindAttribute(anAttr, "AttributeName")) {
4575 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4577 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
4580 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4581 aStudyBuilder->Addreference(newObj1, obj);
4582 // commit transaction
4585 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
4586 int themode = myRenderInter->GetDisplayMode();
4587 vtkActorCollection* theActors =
4588 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
4589 theActors->InitTraversal();
4590 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
4591 while(!(anActor==NULL)) {
4592 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
4593 GActor->setIO( IObject );
4594 GActor->setName( IObject->getName() );
4596 theRenderer->AddActor(GActor);
4597 vtkRenderWindow *renWin
4598 = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
4600 anActor = (vtkActor*)theActors->GetNextActor();
4606 GeomGUI->myActiveStudy->updateObjBrowser( true );
4607 QApplication::restoreOverrideCursor();
4612 //=====================================================================================
4613 // function : OnDisplayOnly()
4615 //=====================================================================================
4616 void GeometryGUI::OnDisplayOnly()
4618 if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4621 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4622 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4623 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4625 AIS_ListOfInteractive List;
4626 ic->DisplayedObjects(List);
4627 AIS_ListIteratorOfListOfInteractive ite(List);
4628 while (ite.More()) {
4629 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4630 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
4631 if (!ic->IsSelected( aSh )) {
4632 ic->Erase( aSh, Standard_True, Standard_True );
4638 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4639 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4641 SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
4642 for(;It1.More();It1.Next()) {
4643 Handle(SALOME_InteractiveObject) IObject = It1.Value();
4646 SALOMEDS::SObject_var fatherSF =
4647 aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
4648 if ( v3d->isInViewer( IObject, true ) ) {
4649 AIS_ListOfInteractive List1;
4650 ic->ObjectsInCollector(List1);
4651 AIS_ListIteratorOfListOfInteractive ite1(List1);
4652 while (ite1.More()) {
4653 if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
4654 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
4655 if ( aSh->hasIO() ) {
4656 Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
4657 if ( IObject->isSame( GIO ) ) {
4659 ic->AddOrRemoveCurrentObject(aSh, true);
4667 if ( IObject->hasEntry() ) {
4668 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4669 SALOMEDS::GenericAttribute_var anAttr;
4670 SALOMEDS::AttributeName_var aName;
4671 SALOMEDS::AttributeIOR_var anIOR;
4672 if ( !obj->_is_nil() ) {
4673 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
4674 // this SObject may be GEOM module root SObject
4676 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4677 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
4678 if (CORBA::is_nil(aShape)) continue;
4679 TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape);
4681 if (obj->FindAttribute(anAttr, "AttributeName")) {
4682 aName = SALOMEDS::AttributeName::_narrow(anAttr);
4684 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4687 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
4688 aStudyBuilder->Addreference(newObj1, obj);
4689 // commit transaction
4693 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
4694 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
4696 IO->setEntry(obj->GetID());
4698 aSh->setName( aName->Value() );
4700 ic->AddOrRemoveCurrentObject(aSh, true);
4709 //===============================================================================
4710 // function : OnEditDelete()
4712 //===============================================================================
4713 void GeometryGUI::OnEditDelete()
4715 if ( QAD_MessageBox::warn2
4716 ( QAD_Application::getDesktop(),
4717 tr ("GEOM_WRN_WARNING"),
4718 tr ("GEOM_REALLY_DELETE"),
4719 tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 )
4722 int nbSf = myActiveStudy->getStudyFramesCount();
4724 Standard_Boolean found;
4725 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4726 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4727 SALOMEDS::GenericAttribute_var anAttr;
4728 SALOMEDS::AttributeIOR_var anIOR;
4730 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4731 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
4732 for(;It.More();It.Next()) {
4733 Handle(SALOME_InteractiveObject) IObject = It.Value();
4734 if ( IObject->hasEntry() ) {
4735 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
4736 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
4738 /* Erase child graphical objects */
4739 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
4740 for (; it->More();it->Next()) {
4741 SALOMEDS::SObject_var CSO= it->Value();
4742 if (CSO->FindAttribute(anAttr, "AttributeIOR") ) {
4743 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4744 /* Delete child(s) shape in Client : */
4745 const TCollection_AsciiString ASCior(anIOR->Value()) ;
4746 ShapeReader.RemoveShapeFromBuffer( ASCior ) ;
4748 for ( int i = 0; i < nbSf; i++ ) {
4749 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4750 if ( sf->getTypeView() == VIEW_OCC ) {
4751 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4752 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4753 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found );
4755 myContext->Erase( Result, true, false );
4756 } else if ( sf->getTypeView() == VIEW_VTK ) {
4757 //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
4758 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4759 GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found );
4761 //Renderer->RemoveActor(ac);
4763 myRenderInter->Remove( ac->getIO() );
4770 /* Erase main graphical object */
4771 for ( int i = 0; i < nbSf; i++ ) {
4772 QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
4773 if ( sf->getTypeView() == VIEW_OCC ) {
4774 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
4775 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
4776 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found );
4778 myContext->Erase( Result, true, false );
4779 } else if ( sf->getTypeView() == VIEW_VTK ) {
4780 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
4781 myRenderInter->Remove( IObject );
4785 /* Delete main shape in Client : */
4786 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
4787 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
4788 const TCollection_AsciiString ASCIor(anIOR->Value()) ;
4789 ShapeReader.RemoveShapeFromBuffer( ASCIor ) ;
4792 /* Erase objects in Study */
4793 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
4794 if ( !obj->_is_nil() ) {
4795 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
4797 aStudyBuilder->RemoveObject(obj);
4801 } /* IObject->hasEntry() */
4804 /* Clear any previous selection */
4805 Sel->ClearIObjects() ;
4806 myActiveStudy->updateObjBrowser();
4810 //==============================================================================
4811 // function : OnEditCopy()
4813 //==============================================================================
4814 void GeometryGUI::OnEditCopy()
4816 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
4817 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
4819 const SALOME_ListIO& List = Sel->StoredIObjects();
4821 GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR);
4823 Sel->ClearIObjects();
4825 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
4826 GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]);
4828 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ;
4829 result->NameType( aShapeInit->NameType() );
4830 this->Display(result);
4832 catch (const SALOME::SALOME_Exception& S_ex) {
4833 QtCatchCorbaException(S_ex);
4837 myDesktop->putInfo(tr("GEOM_PRP_READY"));
4842 //=====================================================================================
4843 // function : OnKeyPress()
4844 // purpose : [static]
4845 //=====================================================================================
4846 bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
4848 GeometryGUI::GetOrCreateGeometryGUI(parent);
4850 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
4858 //=====================================================================================
4859 // function : DisplaySimulationShape()
4860 // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
4861 //=====================================================================================
4862 void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S)
4867 //NRI DEBUG : 14/02/2002
4868 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
4871 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
4872 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4875 /* erase any previous */
4876 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4877 ic->ClearPrs( this->mySimulationShape );
4878 this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ;
4879 this->mySimulationShape->Set( S ) ;
4880 this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ;
4881 ic->Deactivate( this->mySimulationShape );
4882 ic->Display( this->mySimulationShape, Standard_False );
4883 ic->UpdateCurrentViewer();
4885 catch(Standard_Failure) {
4886 MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ;
4888 this->mySimulationShape->UnsetColor() ;
4894 //==================================================================================
4895 // function : EraseSimulationShape()
4896 // purpose : Clears the display of 'mySimulationShape' a pure graphical shape
4897 //==================================================================================
4898 void GeometryGUI::EraseSimulationShape()
4900 int count = myActiveStudy->getStudyFramesCount();
4901 for ( int i = 0; i < count; i++ ) {
4902 if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
4903 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
4904 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
4905 ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
4906 ic->ClearPrs( this->mySimulationShape );
4907 ic->UpdateCurrentViewer();
4909 } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK
4912 // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " )
4917 //=====================================================================================
4918 // function : Import
4919 // purpose : BRep, Iges, Step
4920 //=====================================================================================
4921 bool GeometryGUI::Import( )
4923 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
4924 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
4926 GEOM::GEOM_Shape_var aShape;
4928 QStringList filtersList ;
4930 switch ( GeomGUI->myState )
4932 case 111 : // Import BREP
4934 filtersList.append( tr("GEOM_MEN_IMPORT_BREP") );
4935 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4937 file = QAD_FileDlg::getFileName(myDesktop,
4940 tr("GEOM_MEN_IMPORT"),
4942 if ( !file.isEmpty() ) {
4943 QApplication::setOverrideCursor( Qt::waitCursor );
4945 aShape = myComponentGeom->ImportBREP( file.latin1() );
4947 catch (const SALOME::SALOME_Exception& S_ex) {
4948 QtCatchCorbaException(S_ex);
4953 case 112 : // Import IGES
4955 filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ;
4956 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4958 file = QAD_FileDlg::getFileName(myDesktop,
4961 tr("GEOM_MEN_IMPORT"),
4963 if ( !file.isEmpty() ) {
4964 QApplication::setOverrideCursor( Qt::waitCursor );
4966 aShape = myComponentGeom->ImportIGES( file.latin1() );
4968 catch (const SALOME::SALOME_Exception& S_ex) {
4969 QtCatchCorbaException(S_ex);
4974 case 113 : // Import STEP
4976 filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ;
4977 filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
4979 file = QAD_FileDlg::getFileName(myDesktop,
4982 tr("GEOM_MEN_IMPORT"),
4984 if ( !file.isEmpty() ) {
4985 QApplication::setOverrideCursor( Qt::waitCursor );
4987 aShape = myComponentGeom->ImportSTEP( file.latin1() );
4989 catch (const SALOME::SALOME_Exception& S_ex) {
4990 QtCatchCorbaException(S_ex);
4997 if ( !file.isEmpty() ) {
4998 myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) );
5000 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5001 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry());
5002 SALOMEDS::GenericAttribute_var anAttr;
5003 SALOMEDS::AttributeName_var aName;
5004 SALOMEDS::AttributePixMap_var aPixmap;
5005 int aLocked = false;
5006 if (father->_is_nil()) {
5007 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5009 aLocked = aStudy->GetProperties()->IsLocked();
5010 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5011 father = aStudyBuilder->NewComponent("GEOM");
5012 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5013 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5014 aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5015 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5016 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5017 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5018 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5021 // if (aLocked) return false;
5022 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5023 father->ComponentIOR( Fatherior );
5025 QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++);
5027 if ( Display ( aShape, strdup(nameShape.latin1())) ) {
5028 myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) );
5029 myDesktop->putInfo( tr("GEOM_PRP_READY"));
5032 QApplication::restoreOverrideCursor();
5037 //=====================================================================================
5038 // function : Export
5039 // purpose : BRep, Iges, Step
5040 //=====================================================================================
5041 bool GeometryGUI::Export( )
5043 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5044 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5046 GEOM::GEOM_Shape_var aShape;
5048 static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"),
5049 tr("GEOM_MEN_IMPORT_IGES"),
5050 tr("GEOM_MEN_IMPORT_STEP") };
5052 SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
5053 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5055 switch ( GeomGUI->myState )
5059 for(;It.More();It.Next()) {
5060 QApplication::restoreOverrideCursor();
5061 Handle(SALOME_InteractiveObject) IObject = It.Value();
5062 Standard_Boolean found;
5063 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5064 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5066 QString file = QAD_FileDlg::getFileName(myDesktop,
5067 QString( IObject->getName() ) + ".brep",
5068 tr("GEOM_MEN_IMPORT_BREP"),
5069 tr("GEOM_MEN_EXPORT"),
5071 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5072 QApplication::setOverrideCursor( Qt::waitCursor );
5073 // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) );
5075 GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape);
5077 catch (const SALOME::SALOME_Exception& S_ex) {
5078 QtCatchCorbaException(S_ex);
5087 for(;It.More();It.Next()) {
5088 QApplication::restoreOverrideCursor();
5089 Handle(SALOME_InteractiveObject) IObject = It.Value();
5090 Standard_Boolean found;
5091 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5092 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5094 QString file = QAD_FileDlg::getFileName(myDesktop,
5095 QString( IObject->getName() ) + ".igs",
5096 tr("GEOM_MEN_IMPORT_IGES"),
5097 tr("GEOM_MEN_EXPORT"),
5099 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5100 QApplication::setOverrideCursor( Qt::waitCursor );
5102 GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape);
5104 catch (const SALOME::SALOME_Exception& S_ex) {
5105 QtCatchCorbaException(S_ex);
5107 // //VRV: OCC 4.0 migration
5108 // IGESControl_Controller::Init();
5109 // IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
5110 // Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
5111 // //VRV: OCC 4.0 migration
5113 // ICW.AddShape (Shape->Shape());
5114 // ICW.ComputeModel();
5115 // Standard_Boolean result = ICW.Write( strdup(file.latin1()) );
5124 // bool test = false ;
5125 // IFSelect_ReturnStatus status ;
5126 // //VRV: OCC 4.0 migration
5127 // STEPControl_Writer aWriter;
5128 // //VRV: OCC 4.0 migration
5131 for( ; It.More(); It.Next() ) {
5132 // GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5133 QApplication::restoreOverrideCursor();
5134 Handle(SALOME_InteractiveObject) IObject = It.Value();
5135 Standard_Boolean found;
5136 GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
5137 // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
5139 file = QAD_FileDlg::getFileName(myDesktop,
5140 QString( IObject->getName() ) + ".stp",
5141 tr("GEOM_MEN_IMPORT_STEP"),
5142 tr("GEOM_MEN_EXPORT"),
5144 if ( !file.isEmpty() && !aShape->_is_nil() ) {
5146 QApplication::setOverrideCursor( Qt::waitCursor ) ;
5148 GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape);
5150 catch (const SALOME::SALOME_Exception& S_ex) {
5151 QtCatchCorbaException(S_ex);
5153 // //VRV: OCC 4.0 migration
5154 // status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ;
5155 // //VRV: OCC 4.0 migration
5157 // if ( status != IFSelect_RetDone ) {
5158 // QApplication::restoreOverrideCursor() ;
5165 // status = aWriter.Write( strdup(file.latin1()) ) ;
5166 // QApplication::restoreOverrideCursor() ;
5173 QApplication::restoreOverrideCursor() ;
5177 //=====================================================================================
5178 // function : Display()
5179 // purpose : Displays a CORBA shape
5180 //=====================================================================================
5181 bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
5182 Standard_CString name)
5184 // MESSAGE ( "GeometryGUI::Display init ")
5185 Handle(GEOM_InteractiveObject) IO;
5186 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5187 Sel->ClearIObjects();
5189 if( aShape->_is_nil() ) {
5190 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
5191 tr ("GEOM_WRN_WARNING"),
5192 tr ("GEOM_PRP_ABORT"),
5193 tr ("GEOM_BUT_OK") );
5197 TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape);
5199 if ( shape.IsNull() )
5202 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5203 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5204 SALOMEDS::GenericAttribute_var anAttr;
5205 SALOMEDS::AttributeName_var aName;
5206 SALOMEDS::AttributePixMap_var aPixmap;
5208 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5209 int aLocked = false;
5210 if (father->_is_nil()) {
5211 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5213 aLocked = aStudy->GetProperties()->IsLocked();
5214 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5215 father = aStudyBuilder->NewComponent("GEOM");
5216 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5217 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5218 aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5219 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5220 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5221 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5222 myActiveStudy->updateObjBrowser();
5223 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5226 // if (aLocked) return false;
5228 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5229 father->ComponentIOR( Fatherior );
5231 TCollection_AsciiString nameG("");
5232 Standard_CString Type;
5233 if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) {
5234 if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) {
5235 Standard_CString type;
5236 GetShapeTypeString(shape,type);
5237 aShape->NameType( type );
5238 nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") +
5239 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5241 nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") +
5242 TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
5244 nameG = TCollection_AsciiString(name);
5247 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5248 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5250 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5251 int themode = myRenderInter->GetDisplayMode();
5253 vtkActorCollection* theActors =
5254 GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True);
5255 theActors->InitTraversal();
5256 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
5258 IO = new GEOM_InteractiveObject(aShape->Name(),
5261 while(!(anActor==NULL)) {
5262 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
5263 GActor->setIO( IO );
5264 GActor->setName( nameG.ToCString() );
5266 theRenderer->AddActor(GActor);
5267 anActor = (vtkActor*)theActors->GetNextActor();
5271 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5272 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5273 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5274 Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() );
5275 theResult->SetShadingColor( myShadingColor );
5276 IO = new GEOM_InteractiveObject(aShape->Name(),
5279 theResult->setIO( IO );
5280 theResult->setName( nameG.ToCString() );
5282 /* Precaution : close any local context to permit the display */
5283 if ( ic->HasOpenedContext() ) {
5284 ic->CloseAllContexts();
5288 // theResult->SetInfiniteState() ;
5290 ic->Display(theResult);
5293 Sel->AddIObject( IO, false );
5294 myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
5295 if ( Settings_AddInStudy )
5296 GeomGUI->AddInStudy( false, IO );
5302 //=====================================================================================
5303 // function : AddInStudy()
5304 // purpose : anIOShape or a selected shape
5305 //=====================================================================================
5306 bool GeometryGUI::AddInStudy( bool selection,
5307 const Handle(SALOME_InteractiveObject)& anIO)
5309 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
5310 if ( !( !Settings_AddInStudy || selection ) ) {
5311 Sel->ClearIObjects();
5314 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
5315 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
5316 SALOMEDS::GenericAttribute_var anAttr;
5317 SALOMEDS::AttributeName_var aName;
5318 SALOMEDS::AttributePixMap_var aPixmap;
5319 SALOMEDS::AttributeIOR_var anIOR;
5320 SALOMEDS::AttributeSelectable_var aSelAttr;
5322 SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
5323 int aLocked = false;
5324 if (father->_is_nil()) {
5325 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5327 aLocked = aStudy->GetProperties()->IsLocked();
5328 if (aLocked) aStudy->GetProperties()->SetLocked(false);
5329 father = aStudyBuilder->NewComponent("GEOM");
5330 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
5331 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5332 aName->SetValue( tr("GEOM_MEN_COMPONENT") );
5333 anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
5334 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5335 aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
5336 if (aLocked) aStudy->GetProperties()->SetLocked(true);
5339 // if (aLocked) return false;
5341 aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
5342 father->ComponentIOR( Fatherior );
5344 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
5346 Handle(GEOM_AISShape) GAISShape;
5348 Handle(GEOM_InteractiveObject) GIO;
5352 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5353 vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
5355 vtkActorCollection* theActors = Renderer->GetActors();
5356 theActors->InitTraversal();
5357 vtkActor *ac = theActors->GetNextActor();
5358 while(!(ac==NULL)) {
5359 if ( ac->IsA("GEOM_Actor") ) {
5360 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
5361 if ( anActor->hasIO() ) {
5362 Handle(SALOME_InteractiveObject) IO = anActor->getIO();
5363 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5364 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5365 if ( anIO->isSame( GIO ) ) {
5373 ac = theActors->GetNextActor();
5380 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5381 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5382 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5384 AIS_ListOfInteractive List;
5385 ic->DisplayedObjects(List);
5386 AIS_ListIteratorOfListOfInteractive ite(List);
5387 while (ite.More()) {
5388 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
5389 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
5390 if ( aSh->hasIO() ) {
5391 Handle(SALOME_InteractiveObject) IO = aSh->getIO();
5392 if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
5393 GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
5394 if ( anIO->isSame( GIO ) ) {
5409 if ( !Settings_AddInStudy || selection ) {
5410 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() );
5411 if ( !Name.isEmpty() ) {
5413 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5414 GActor->setName( strdup(Name.latin1()) );
5417 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5418 GAISShape->setName( strdup(Name.latin1()) );
5426 QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
5429 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father);
5431 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() );
5433 /* For the shape inserted into the study we set its field 'studyshapeid' */
5434 /* so the shape will contain its corresponding entry in the study Ocaf doc. */
5435 aShape->StudyShapeId(newObj->GetID()) ;
5437 GIO->setEntry(newObj->GetID());
5439 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
5440 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5441 anIOR->SetValue(aShape->Name());
5443 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
5444 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5446 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
5447 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
5448 if ( aShape->ShapeType() == GEOM::COMPOUND ) {
5449 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
5450 } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
5451 aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
5452 } else if ( aShape->ShapeType() == GEOM::SOLID ) {
5453 aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
5454 } else if ( aShape->ShapeType() == GEOM::SHELL ) {
5455 aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
5456 } else if ( aShape->ShapeType() == GEOM::FACE ) {
5457 aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
5458 } else if ( aShape->ShapeType() == GEOM::WIRE ) {
5459 aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
5460 } else if ( aShape->ShapeType() == GEOM::EDGE ) {
5461 aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
5462 } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
5463 aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
5467 if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5468 GActor->setIO( GIO );
5469 aName->SetValue(GActor->getName());
5472 else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5473 GAISShape->setIO( GIO );
5474 aName->SetValue(GAISShape->getName());
5477 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
5478 aStudyBuilder->Addreference(newObj1,newObj);
5480 GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
5481 listIOR = myComponentGeom->GetReferencedObjects(aShape);
5483 if (listIOR->length()>0) {
5484 SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj);
5485 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName");
5486 aName = SALOMEDS::AttributeName::_narrow(anAttr);
5487 aName->SetValue(tr("GEOM_ARGUMENTS"));
5488 anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable");
5489 aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
5490 aSelAttr->SetSelectable(false);
5492 bool ObjectReferenced = false;
5493 for (unsigned int ind = 0; ind < listIOR->length();ind++) {
5494 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]);
5496 if ( !theObj->_is_nil() ) {
5497 SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments);
5498 aStudyBuilder->Addreference(RefObject, theObj);
5499 ObjectReferenced = true;
5503 if ( !ObjectReferenced )
5504 aStudyBuilder->RemoveObject(Arguments);
5510 if ( !Settings_AddInStudy || selection ) {
5511 myActiveStudy->updateObjBrowser();
5513 myActiveStudy->updateObjBrowser(false);
5514 Sel->AddIObject( GIO );
5517 // MESSAGE ( " highlihght done" )
5523 //=====================================================================================
5524 // function : GetShapeFromIOR()
5525 // purpose : exist also as static method !
5526 //=====================================================================================
5527 TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR )
5529 TopoDS_Shape result;
5530 if( IOR.stripWhiteSpace().isEmpty() )
5532 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
5533 CORBA::ORB_var& _orb = init.orb() ;
5534 CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) );
5535 if ( CORBA::is_nil( obj ) )
5537 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR );
5538 if (!aShape->_is_nil()) {
5539 result = ShapeReader.GetShape( myComponentGeom, aShape );
5545 //=====================================================================================
5546 // function : SetSettings()
5547 // purpose : [static]
5548 //=====================================================================================
5549 bool GeometryGUI::SetSettings( QAD_Desktop* parent )
5551 /* Create or retrieve an object GeomGUI */
5552 GeometryGUI::GetOrCreateGeometryGUI(parent);
5554 //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING
5555 //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS
5556 //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY
5557 parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS
5558 parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN
5561 QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
5562 QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
5563 QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
5564 if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
5565 GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255.,
5568 /* Wireframe or Shading */
5569 int DisplayMode = 0;
5570 if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
5571 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
5572 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
5573 DisplayMode = ic->DisplayMode();
5574 } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
5575 VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5576 DisplayMode = myRenderInter->GetDisplayMode();
5579 if ( DisplayMode == 1 )
5580 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
5582 parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
5585 // QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy");
5586 // if ( !Copy.isEmpty() ) {
5587 // Settings_Copy = Copy.toInt();
5589 // parent->menuBar()->findItem(701,&pp);
5590 // pp->setItemChecked(701, Settings_Copy);
5593 if ( parent->menuBar()->findItem(701,&pp) )
5594 pp->removeItem(701);
5597 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
5598 if ( !AddInStudy.isEmpty() )
5599 Settings_AddInStudy = AddInStudy.toInt();
5601 Settings_AddInStudy = 1;
5602 parent->menuBar()->findItem(702,&pp);
5603 pp->setItemChecked(702, Settings_AddInStudy);
5606 QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
5608 QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" );
5611 QAD_Study* ActiveStudy = parent->getActiveStudy();
5612 int count = ActiveStudy->getStudyFramesCount();
5614 bool ViewOCC = false;
5615 for ( int i = 0; i < count; i++ ) {
5616 if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
5617 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
5618 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5620 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
5621 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
5622 if ( !IsoU.isEmpty() )
5623 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
5624 if ( !IsoV.isEmpty() )
5625 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
5631 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
5633 Mb->setItemEnabled( 312, ViewOCC); //Sketch
5634 Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
5635 Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
5637 Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
5638 Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
5644 //=====================================================================================
5645 // function : DefinePopup()
5646 // purpose : [static]
5647 //=====================================================================================
5648 void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
5650 /* Create or retrieve an object GeomGUI */
5651 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
5652 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5655 if ( Sel->IObjectCount() == 1 )
5657 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
5660 SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
5661 if (!sobj->_is_nil())
5663 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
5664 if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
5666 // component is selected
5667 theObject = "Component";
5673 if ( ( theParent.compare("Viewer")==0 ) )
5675 if ( GeomGUI->myState == CURRENT_SKETCH )
5676 theContext = "Sketch";
5679 if ( Sel->IObjectCount() > 0 )
5682 theContext = "NothingSelected";
5690 //=====================================================================================
5691 // function : CustomPopup()
5692 // purpose : [static]
5693 //=====================================================================================
5694 bool GeometryGUI::CustomPopup( QAD_Desktop* parent,
5696 const QString& theContext,
5697 const QString& theParent,
5698 const QString& theObject )
5700 /* Create or retrieve an object GeomGUI */
5701 GeometryGUI::GetOrCreateGeometryGUI(parent);
5703 /* Deactivate any non modal dialog box to get the neutral point */
5704 GeomGUI->EmitSignalDeactivateDialog() ;
5706 SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
5707 int nbSel = Sel->IObjectCount();
5709 if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) )
5713 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
5715 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->
5716 getRightFrame()->getViewFrame())->getViewer();
5717 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
5718 if ( theParent.compare("Viewer")==0 )
5720 if ( theContext.compare("Sketch")==0 )
5722 SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus();
5723 popup->setCheckable(TRUE);
5726 popup->setItemChecked(10000,true);
5727 popup->setItemChecked(10001,false);
5729 else if (myCS==ARC_CHORD)
5731 popup->setItemChecked(10000,false);
5732 popup->setItemChecked(10001,true);
5738 if (theObject.compare("Component") == 0)
5740 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5745 QFont f = QApplication::font();
5749 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5750 popup->removeItem(QAD_TopLabel_Popup_ID);
5751 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5752 if ( IObject->hasEntry() )
5753 popup->setItemEnabled( 801, false );
5755 popup->setItemEnabled( 801, true );
5757 if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)))
5759 Standard_Boolean found;
5760 Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
5764 if ( Result->DisplayMode() == 1 )
5765 popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") );
5767 popup->changeItem(8021, tr("GEOM_MEN_SHADING") );
5771 if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) )
5772 popup->removeItem(QAD_Erase_Popup_ID);
5774 popup->removeItem(QAD_Display_Popup_ID);
5779 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5780 popup->removeItem(QAD_TopLabel_Popup_ID);
5781 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ),
5782 QAD_TopLabel_Popup_ID, 0 );
5783 popup->setItemEnabled( 801, false );
5789 if ( theParent.compare("ObjectBrowser")==0 )
5791 popup->removeItem(QAD_TopLabel_Popup_ID);
5792 int id = popup->idAt(0); // separator
5793 if (id < 0) popup->removeItem(id);
5795 // checking for GEOM label in the selected list
5796 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5797 Handle(SALOME_InteractiveObject) anIObject;
5799 bool useSubItems = false;
5800 bool needOpen = false;
5801 bool needDisplay = false;
5802 bool needErase = false;
5803 SALOMEDS::GenericAttribute_var aTmpAttr;
5804 for(;It.More();It.Next())
5806 anIObject = It.Value();
5807 if (!anIObject->hasEntry())
5810 if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject))
5814 SALOMEDS::SObject_var obj =
5815 GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
5816 if (!obj->_is_nil())
5818 GEOM::GEOM_Shape_var aShape;
5819 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) {
5820 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5821 if (str && strlen(str))
5822 aShape = GeomGUI->myComponentGeom-> GetIORFromString(str);
5825 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5827 if (aShape->_is_nil())
5829 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->
5830 getStudyDocument()->NewChildIterator(obj);
5831 while (anIter->More())
5833 SALOMEDS::SObject_var subobj = anIter->Value();
5834 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
5841 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5851 // remove useless popup items
5852 if (nbSel != 1) popup->removeItem(901); // rename
5853 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5856 int index = popup->indexOf(9024);
5857 popup->removeItem(9024); // open
5858 popup->removeItemAt(index); // separator under Open
5860 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
5861 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
5862 if (!needDisplay && !needErase)
5864 int id = popup->idAt(popup->count()-1); // last item
5865 popup->removeItem(id); // separator
5870 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
5871 popup->removeItem(QAD_Display_Popup_ID);
5872 popup->removeItem(QAD_Erase_Popup_ID);
5875 int id = popup->idAt(popup->count()-1); // last item
5876 popup->removeItem(id); // separator
5881 // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ")
5884 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
5886 // MESSAGE ( " CUSTOM POPUP VIEWER VTK ")
5887 if ( ( theParent.compare("Viewer")==0 ) )
5890 popup->setItemEnabled( 8033, false );
5891 if (theObject.compare("Component") == 0)
5893 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5897 //int id = popup->idAt(0);
5898 QFont f = QApplication::font();
5903 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
5904 popup->removeItem(QAD_TopLabel_Popup_ID);
5905 popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
5906 if ( IObject->hasEntry() )
5908 popup->setItemEnabled( 801, false );
5909 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
5910 SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
5911 SALOMEDS::GenericAttribute_var anAttr;
5912 SALOMEDS::AttributeIOR_var anIOR;
5913 if ( !SO->_is_nil() )
5915 if (SO->FindAttribute(anAttr, "AttributeIOR") )
5917 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
5918 Standard_Boolean found;
5919 GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true);
5922 if ( Result->getDisplayMode() == 1 )
5923 popup->changeItem(8021, "Wireframe" );
5925 popup->changeItem(8021, "Shading" );
5927 if ( !Result->GetVisibility() )
5928 popup->removeItem(QAD_Erase_Popup_ID);
5930 popup->removeItem(QAD_Display_Popup_ID);
5933 popup->removeItem(QAD_Erase_Popup_ID);
5938 popup->setItemEnabled( 801, true );
5942 popup->removeItem(QAD_DisplayOnly_Popup_ID);
5943 popup->removeItem(QAD_TopLabel_Popup_ID);
5944 popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 );
5945 popup->setItemEnabled( 801, false );
5950 if ( theParent.compare("ObjectBrowser")==0 )
5952 popup->removeItem(QAD_TopLabel_Popup_ID);
5953 int id = popup->idAt(0); // separator
5954 if (id < 0) popup->removeItem(id);
5956 // checking for GEOM label in the selected list
5957 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
5958 Handle(SALOME_InteractiveObject) anIObject;
5960 bool useSubItems = false;
5961 bool needOpen = false;
5962 bool needDisplay = false;
5963 bool needErase = false;
5964 SALOMEDS::GenericAttribute_var aTmpAttr;
5965 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->
5966 getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
5967 for(;It.More();It.Next())
5969 anIObject = It.Value();
5970 if ( !anIObject->hasEntry() )
5973 if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject))
5978 SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument()
5979 ->FindObjectID( anIObject->getEntry() );
5980 if (!obj->_is_nil()) {
5981 GEOM::GEOM_Shape_var aShape;
5982 if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){
5983 char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
5984 if (str && strlen(str))
5985 aShape = GeomGUI->myComponentGeom->GetIORFromString(str);
5988 if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
5990 if (aShape->_is_nil())
5992 SALOMEDS::ChildIterator_var anIter =
5993 GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
5994 while (anIter->More())
5996 SALOMEDS::SObject_var subobj = anIter->Value();
5997 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
6004 if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
6014 // remove useless popup items
6015 if (nbSel != 1) popup->removeItem(901); // rename
6016 if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6019 int index = popup->indexOf(9024);
6020 popup->removeItem(9024); // open
6021 popup->removeItemAt(index); // separator under Open
6023 if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
6024 if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
6025 if (!needDisplay && !needErase)
6027 int id = popup->idAt(popup->count()-1); // last item
6028 popup->removeItem(id); // separator
6033 popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
6034 popup->removeItem(QAD_Display_Popup_ID);
6035 popup->removeItem(QAD_Erase_Popup_ID);
6038 int id = popup->idAt(popup->count()-1); // last item
6039 popup->removeItem(id); // separator
6043 // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.")
6046 { // other viewer types not supported.
6049 int id = popup->idAt(0);
6050 if (id <= QAD_TopLabel_Popup_ID && id != -1)
6051 popup->removeItemAt(0);
6055 popup->removeItem(QAD_DisplayOnly_Popup_ID);
6056 popup->removeItem(QAD_Display_Popup_ID);
6057 popup->removeItem(QAD_Erase_Popup_ID);
6058 int id = popup->idAt(popup->count()-1); // last item
6059 if (id < 0 && id != -1) popup->removeItem(id); // separator
6065 void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
6067 /* Create or retrieve an object GeomGUI */
6068 GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
6070 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6071 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
6073 OCCViewer_Viewer3d* v3d;
6074 Handle(AIS_InteractiveContext) ic;
6075 vtkRenderer* Renderer;
6077 if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6078 v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6079 ic = v3d->getAISContext();
6080 } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6081 Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6086 MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
6088 if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
6091 SALOMEDS::SObject_var fatherSF =
6092 aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6094 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6096 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
6098 SALOMEDS::GenericAttribute_var anAttr;
6099 SALOMEDS::AttributeName_var aName;
6100 SALOMEDS::AttributeIOR_var anIOR;
6102 if(myRenderInter->isInViewer(theIO)) {
6103 myRenderInter->Display(theIO, false);
6107 if ( !obj->_is_nil() ) {
6108 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6109 // this SObject may be GEOM module root SObject
6111 bool useSubItems = false;
6112 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6113 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6114 while (anIter->More() && !useSubItems) {
6115 SALOMEDS::SObject_var subobj = anIter->Value();
6116 SALOMEDS::GenericAttribute_var aTmpAttr;
6117 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6118 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6122 } else anIter->Next();
6123 } else anIter->Next();
6127 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6128 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6129 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6130 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6132 if (obj->FindAttribute(anAttr, "AttributeName")) {
6133 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6135 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
6136 vtkActorCollection* theAllActors = theRenderer->GetActors();
6137 theAllActors->InitTraversal();
6138 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
6139 Handle(SALOME_InteractiveObject) anIObj;
6140 // don't create new study object if it already exists
6141 bool isDisplayed = false;
6142 while(!(actor==NULL)) {
6143 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
6145 if (Gactor->hasIO()) {
6146 if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
6148 anIObj = Gactor->getIO();
6149 if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
6153 actor=(vtkActor*)(theAllActors->GetNextActor());
6157 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6160 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6161 aStudyBuilder->Addreference(newObj1, obj);
6162 // commit transaction
6165 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
6166 int themode = myRenderInter->GetDisplayMode();
6168 vtkActorCollection* theActors =
6169 GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
6170 theActors->InitTraversal();
6171 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
6172 while(!(anActor==NULL)) {
6173 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
6174 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
6175 IO->setEntry(obj->GetID());
6176 GActor->setIO( IO );
6177 GActor->setName( theIO->getName() );
6179 theRenderer->AddActor(GActor);
6180 // renWin->Render();
6181 anActor = (vtkActor*)theActors->GetNextActor();
6185 // next item iteration
6188 anAttr = SALOMEDS::GenericAttribute::_nil();
6189 while (anIter->More() && anAttr->_is_nil()) {
6190 SALOMEDS::SObject_var subobject = anIter->Value();
6191 SALOMEDS::GenericAttribute_var aTmpAttribute;
6192 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6193 anAttr = aTmpAttribute;
6195 } else anIter->Next();
6197 } else anAttr = SALOMEDS::GenericAttribute::_nil();
6202 // No viewer update should be done here!
6203 //myRenderInter->Render();
6204 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6205 } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
6206 SALOMEDS::SObject_var fatherSF =
6207 aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
6208 SALOMEDS::GenericAttribute_var anAttr;
6209 SALOMEDS::AttributeName_var aName;
6210 SALOMEDS::AttributeIOR_var anIOR;
6212 if ( v3d->isInViewer( theIO, true ) ) {
6213 Standard_Boolean found;
6214 Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true );
6216 ic->Display(aSh, false);
6217 ic->AddOrRemoveCurrentObject(aSh, false);
6221 SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
6222 if ( !obj->_is_nil() ) {
6223 MESSAGE("BuildPresentation(): SObject not null")
6224 if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
6225 MESSAGE("BuildPresentation(): SObject has IOR")
6226 // this SObject may be GEOM module root SObject
6228 bool useSubItems = false;
6229 SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
6230 if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
6231 while (anIter->More() && !useSubItems) {
6232 SALOMEDS::SObject_var subobj = anIter->Value();
6233 SALOMEDS::GenericAttribute_var aTmpAttr;
6234 if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
6235 if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
6239 } else anIter->Next();
6240 } else anIter->Next();
6244 while(useSubItems?anIter->More():!anAttr->_is_nil()) {
6245 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6246 GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
6247 TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
6249 MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
6250 if (obj->FindAttribute(anAttr, "AttributeName")) {
6251 MESSAGE("BuildPresentation(): SObject has Name")
6252 aName = SALOMEDS::AttributeName::_narrow(anAttr);
6253 // searchin for already displayed objects with the same shape
6254 AIS_ListOfInteractive aDisplayed;
6255 ic->DisplayedObjects(aDisplayed);
6256 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
6257 Handle(AIS_Shape) anAISShape;
6258 for(;anIObjects.More();anIObjects.Next()) {
6259 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
6260 if (!anAISShape.IsNull()) {
6261 if (anAISShape->Shape().IsSame(Shape)) break;
6262 anAISShape.Nullify();
6265 if (!anAISShape.IsNull()) {
6266 if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false);
6270 QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
6272 if (fatherSF->_is_nil())
6273 MESSAGE("BuildPresentation(): fatherSF is nil!")
6274 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
6275 aStudyBuilder->Addreference(newObj1, obj);
6276 // commit transaction
6279 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
6280 aSh->SetShadingColor( GeomGUI->myShadingColor );
6281 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
6284 IO->setEntry(obj->GetID());
6286 aSh->setName( aName->Value() );
6287 ic->Display (aSh, false);
6288 if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false);
6291 // next item iteration
6294 anAttr=SALOMEDS::GenericAttribute::_nil();
6295 while (anIter->More() && anAttr->_is_nil()) {
6296 SALOMEDS::SObject_var subobject = anIter->Value();
6297 SALOMEDS::GenericAttribute_var aTmpAttribute;
6298 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
6299 anAttr = aTmpAttribute;
6301 } else anIter->Next();
6304 anAttr = SALOMEDS::GenericAttribute::_nil();
6309 // No viewer update should be done here!
6310 //GeomGUI->myActiveStudy->updateObjBrowser( true );
6311 //ic->UpdateCurrentViewer();
6315 //=======================================================================
6316 // function : Parameter()
6317 // purpose : return a parameter (float) from a dialog box
6319 // avalue1 : is a float or integer used as a default value displayed
6320 // aTitle1 : is the title for aValue1
6321 // aTitle : is the main title
6322 // bottom : maximum value to be entered
6323 // top : minimum value to be entered
6324 // decimals : number of decimals
6325 //=======================================================================
6326 double GeometryGUI::Parameter( Standard_Boolean& res,
6327 const char* aValue1,
6328 const char* aTitle1,
6330 const double bottom,
6332 const int decimals )
6334 GeometryGUI_aParameterDlg * Dialog =
6335 new GeometryGUI_aParameterDlg(aValue1,
6337 QAD_Application::getDesktop(),
6344 int r = Dialog->exec() ;
6346 if ( r == QDialog::Accepted ) {
6347 res = Standard_True;
6348 X = Dialog->getValue();
6350 res = Standard_False;
6356 //=======================================================================
6357 // function : OnSketchSegment()
6359 //=======================================================================
6360 void GeometryGUI::OnSketchSegment()
6362 this->mySketcher.ChangeMode(SEGMENT);
6366 //=======================================================================
6367 // function : OnSketchArc()
6369 //=======================================================================
6370 void GeometryGUI::OnSketchArc()
6372 this->mySketcher.ChangeMode(ARC_CHORD);
6375 //=======================================================================
6376 // function : OnSketchSetAngle()
6378 //=======================================================================
6379 void GeometryGUI::OnSketchSetAngle()
6381 Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180;
6382 Sketch::fitInResol(anAngle);
6383 Standard_Boolean res = false ;
6384 QString Value = QString("%1").arg( anAngle );
6385 anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ;
6388 this->mySketcher.SetSegmentAngle(anAngle);
6389 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6391 QMenuItem* item = Mb->findItem(3133,&pp);
6392 pp->setItemChecked(3133,false);
6393 item = Mb->findItem(3134,&pp);
6394 pp->setItemChecked(3134,false);
6400 //=======================================================================
6401 // function : OnSketchSetx()
6403 //=======================================================================
6404 void GeometryGUI::OnSketchSetx()
6406 Standard_Boolean res = false;
6407 double X = Parameter( res,
6410 tr("GEOM_MEN_SKETCHER_X"),
6411 2.0 * Precision::Confusion(),
6415 this->mySketcher.SetXDimension(X);
6416 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6418 QMenuItem* item = Mb->findItem(3133,&pp);
6419 pp->setItemChecked(3133,false);
6420 item = Mb->findItem(3134,&pp);
6421 pp->setItemChecked(3134,false);
6424 //=======================================================================
6425 // function : OnSketchSety()
6427 //=======================================================================
6428 void GeometryGUI::OnSketchSety()
6430 Standard_Boolean res = false;
6431 double Y = Parameter( res,
6434 tr("GEOM_MEN_SKETCHER_Y"),
6435 2.0 * Precision::Confusion(),
6439 this->mySketcher.SetYDimension(Y);
6440 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6442 QMenuItem* item = Mb->findItem(3133,&pp);
6443 pp->setItemChecked(3133,false);
6444 item = Mb->findItem(3134,&pp);
6445 pp->setItemChecked(3134,false);
6449 //=======================================================================
6450 // function : OnSketchDelete()
6452 //=======================================================================
6453 void GeometryGUI::OnSketchDelete()
6455 if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
6456 QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
6458 QMenuItem* item = Mb->findItem(313,&pp);
6459 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6460 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6463 if (this->mySketcher.Delete())
6464 GeomGUI->ResetState();
6468 //=======================================================================
6469 // function : OnSketchClose()
6471 //=======================================================================
6472 void GeometryGUI::OnSketchClose()
6474 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6475 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6477 TopoDS_Wire W = this->mySketcher.Close();
6478 if ( !W.IsNull() ) {
6480 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6481 listShapes->length(0);
6484 BRepTools_WireExplorer Ex(W);
6485 while ( Ex.More() ) {
6486 TopoDS_Edge E = Ex.Current();
6489 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6490 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6493 Handle(Geom_Curve) Curve;
6494 Handle(Geom_Circle) Circle;
6496 Standard_Real First,Last;
6498 Curve = BRep_Tool::Curve(E,First,Last);
6499 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6500 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6501 Circ = Circle->Circ(); // gp_Circ
6503 Curve->D0( (First + Last) / 2. , CenterPoint );
6505 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6506 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6507 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6509 GEOM::GEOM_Shape_var arc;
6512 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6514 catch (const SALOME::SALOME_Exception& S_ex) {
6515 QtCatchCorbaException(S_ex);
6518 listShapes->length(i+1);
6519 listShapes[i] = strdup(arc->Name());
6522 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6523 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6524 GEOM::GEOM_Shape_var segment;
6527 segment = myComponentGeom->MakeEdge(pI,pE) ;
6529 catch (const SALOME::SALOME_Exception& S_ex) {
6530 QtCatchCorbaException(S_ex);
6533 listShapes->length(i+1);
6534 listShapes[i] = strdup(segment->Name());
6539 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6540 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6541 Standard_CString type;
6542 GetShapeTypeString(S,type);
6543 Wire->NameType( type );
6545 if ( Display(Wire, "" )) {
6546 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6549 GeomGUI->ResetState();
6550 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6552 QMenuItem* item = Mb->findItem(313,&pp);
6553 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6554 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6559 //=======================================================================
6560 // function : OnSketchEnd()
6562 //=======================================================================
6563 void GeometryGUI::OnSketchEnd()
6565 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6566 Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
6568 TopoDS_Wire W = this->mySketcher.End();
6571 GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
6572 listShapes->length(0);
6575 BRepTools_WireExplorer Ex(W);
6576 while ( Ex.More() ) {
6577 TopoDS_Edge E = TopoDS::Edge( Ex.Current() );
6580 pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
6581 pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
6584 Handle(Geom_Curve) Curve;
6585 Handle(Geom_Circle) Circle;
6587 Standard_Real First,Last;
6589 Curve = BRep_Tool::Curve(E,First,Last);
6590 if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
6591 Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
6592 Circ = Circle->Circ(); // gp_Circ
6594 Curve->D0( (First + Last) / 2. , CenterPoint );
6596 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6597 GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
6598 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6600 GEOM::GEOM_Shape_var arc;
6603 arc = myComponentGeom->MakeArc(pI, pC, pE) ;
6605 catch (const SALOME::SALOME_Exception& S_ex) {
6606 QtCatchCorbaException(S_ex);
6609 listShapes->length(i+1);
6610 listShapes[i] = strdup(arc->Name());
6613 GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
6614 GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
6615 GEOM::GEOM_Shape_var segment;
6618 segment = myComponentGeom->MakeEdge(pI,pE) ;
6620 catch (const SALOME::SALOME_Exception& S_ex) {
6621 QtCatchCorbaException(S_ex);
6624 listShapes->length(i+1);
6625 listShapes[i] = strdup(segment->Name());
6631 GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
6632 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
6633 Standard_CString type;
6634 GetShapeTypeString(S,type);
6635 Wire->NameType( type );
6637 if ( Display(Wire, "") ) {
6638 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6641 GeomGUI->ResetState();
6642 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6644 QMenuItem* item = Mb->findItem(313,&pp);
6645 pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
6646 GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6649 //=======================================================================
6650 // function : OnSettingsNoconstraint()
6652 //=======================================================================
6653 void GeometryGUI::OnSettingsNoconstraint()
6655 this->mySketcher.SetTransitionStatus(NOCONSTRAINT);
6658 //=======================================================================
6659 // function : OnSettingsPerpendicular()
6661 //=======================================================================
6662 void GeometryGUI::OnSettingsPerpendicular()
6664 this->mySketcher.SetTransitionStatus(PERPENDICULAR);
6667 //=======================================================================
6668 // function : OnSettingsTangent()
6670 //=======================================================================
6671 void GeometryGUI::OnSettingsTangent()
6673 this->mySketcher.SetTransitionStatus(TANGENT);
6676 //=======================================================================
6677 // function : OnSketchOptionsOnoffangledimension()
6679 //=======================================================================
6680 void GeometryGUI::OnSketchOptionsOnoffangledimension()
6682 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6684 QMenuItem* item = Mb->findItem(10011,&pp);
6685 pp->setItemChecked(10011,!pp->isItemChecked(10011));
6686 this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
6689 //=======================================================================
6690 // function : OnSketchOptionsOnofflengthdimension()
6692 //=======================================================================
6693 void GeometryGUI::OnSketchOptionsOnofflengthdimension()
6695 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6697 QMenuItem* item = Mb->findItem(10010,&pp);
6698 pp->setItemChecked(10010,!pp->isItemChecked(10010));
6699 this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
6702 //=======================================================================
6703 // function : OnSketchOptionsOnoffradiusdimension()
6705 //=======================================================================
6706 void GeometryGUI::OnSketchOptionsOnoffradiusdimension()
6708 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6710 QMenuItem* item = Mb->findItem(10012,&pp);
6711 pp->setItemChecked(10012,!pp->isItemChecked(10012));
6712 this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
6716 //=======================================================================
6717 // function : OnSketchOptionsOnoffxdimension()
6719 //=======================================================================
6720 void GeometryGUI::OnSketchOptionsOnoffxdimension()
6722 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6724 QMenuItem* item = Mb->findItem(10013,&pp);
6725 pp->setItemChecked(10013,!pp->isItemChecked(10013));
6726 this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
6729 //=======================================================================
6730 // function : OnSketchOptionsOnoffydimension()
6732 //=======================================================================
6733 void GeometryGUI::OnSketchOptionsOnoffydimension()
6735 QMenuBar* Mb = this->myDesktop->getMainMenuBar();
6737 QMenuItem* item = Mb->findItem(10014,&pp);
6738 pp->setItemChecked(10014,!pp->isItemChecked(10014));
6739 this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
6743 //=======================================================================
6744 // function : Archimede()
6746 //=======================================================================
6747 void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO,
6748 const double aWeight,
6749 const double aWaterDensity,
6750 const double aMeshingDeflection )
6753 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
6754 Handle(GEOM_InteractiveObject) GIO =
6755 Handle(GEOM_InteractiveObject)::DownCast( IO );
6756 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() );
6758 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6759 Result->NameType(tr("GEOM_PLANE"));
6760 if ( Display(Result, "") ) {
6761 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6765 if ( IO->hasEntry() ) {
6766 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
6767 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
6768 SALOMEDS::GenericAttribute_var anAttr;
6769 SALOMEDS::AttributeIOR_var anIOR;
6770 if ( !obj->_is_nil() ) {
6771 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
6772 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
6773 GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() );
6774 GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
6775 Result->NameType(tr("GEOM_PLANE"));
6776 if ( Display(Result, "") ) {
6777 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
6784 catch (const SALOME::SALOME_Exception& S_ex) {
6785 QtCatchCorbaException(S_ex);
6790 //=====================================================================================
6792 //=====================================================================================
6795 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
6797 return GeometryGUI::OnGUIEvent(theCommandID, parent);
6800 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6802 return GeometryGUI::OnKeyPress (pe, parent, studyFrame);
6805 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6807 return GeometryGUI::OnMousePress (pe, parent, studyFrame);
6810 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
6812 return GeometryGUI::OnMouseMove (pe, parent, studyFrame);
6815 bool SetSettings ( QAD_Desktop* parent )
6817 return GeometryGUI::SetSettings( parent );
6820 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
6821 const QString & theParent, const QString & theObject )
6823 return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
6826 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
6828 GeometryGUI::DefinePopup( theContext, theParent, theObject );
6831 bool activeStudyChanged ( QAD_Desktop* parent )
6833 GeometryGUI::activeStudyChanged( parent );
6836 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
6838 GeometryGUI::BuildPresentation(theIO);
6841 void supportedViewType(int* buffer, int bufferSize)
6843 if (!buffer || !bufferSize) return;
6844 buffer[0] = (int)VIEW_OCC;
6845 if (--bufferSize) buffer[1] = (int)VIEW_VTK;
6849 //=====================================================================================
6850 // function : OnFilletGetAll()
6852 //=====================================================================================
6853 bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR)
6855 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6856 ListOfID->length(0);
6858 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6859 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6860 if ( theObj->_is_nil() ) {
6861 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6866 if( Radius <= Precision::Confusion() )
6869 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6870 GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ;
6871 if ( result->_is_nil() ) {
6872 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6875 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
6876 Standard_CString type;
6877 GetShapeTypeString(S,type);
6878 result->NameType( type );
6880 if ( Display( result, "" ))
6881 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6883 catch (const SALOME::SALOME_Exception& S_ex) {
6884 QtCatchCorbaException(S_ex);
6889 //=====================================================================================
6890 // function : OnFilletGetSelected()
6892 //=====================================================================================
6893 bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
6894 const char* ShapeTopoIOR,
6895 const double Radius,
6896 const int SubShapeType,
6897 Standard_Integer& aLocalContextId,
6898 bool& myUseLocalContext )
6900 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
6904 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
6905 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
6907 if( myUseLocalContext == false ) {
6908 /* No local context opened for fillet method */
6909 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
6913 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6915 int nbSelected = ic->NbSelected();
6919 while(ic->MoreSelected()) {
6920 TopoDS_Shape s = ic->SelectedShape();
6921 if ( s.ShapeType() == TopAbs_FACE ) {
6922 TopExp_Explorer Exp( s, TopAbs_EDGE );
6923 TopTools_MapOfShape M ;
6924 while ( Exp.More() ) {
6925 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
6926 ListOfID->length( i + 1 );
6927 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
6934 ListOfID->length( i + 1 );
6935 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
6941 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6942 GEOM::GEOM_Shape_var aResult ;
6944 aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID );
6946 /* local context from DialogBox */
6947 ic->CloseLocalContext(aLocalContextId) ;
6948 myUseLocalContext = false ;
6950 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
6951 Standard_CString type;
6952 GetShapeTypeString(S,type);
6953 aResult->NameType( type );
6955 if ( Display( aResult, "") )
6956 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
6958 catch (const SALOME::SALOME_Exception& S_ex) {
6959 QtCatchCorbaException(S_ex);
6962 if ( myUseLocalContext ) {
6963 /* local context from DialogBox */
6964 ic->CloseLocalContext(aLocalContextId) ;
6965 myUseLocalContext = false ;
6968 this->OnDisplayAll(true);
6969 myActiveStudy->updateObjBrowser();
6970 myDesktop->putInfo (tr("GEOM_PRP_READY"));
6975 //=====================================================================================
6976 // function : OnChamferGetAll()
6978 //=====================================================================================
6979 bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR)
6981 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
6982 ListOfID->length(0);
6984 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
6985 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
6986 if ( theObj->_is_nil() ) {
6987 myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
6992 if( D1 <= Precision::Confusion() )
6994 if( D2 <= Precision::Confusion() )
6997 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
6998 GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ;
6999 if ( result->_is_nil() ) {
7000 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7004 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
7005 Standard_CString type;
7006 GetShapeTypeString(S,type);
7007 result->NameType( type );
7009 if ( Display( result, "") )
7010 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7012 catch (const SALOME::SALOME_Exception& S_ex) {
7013 QtCatchCorbaException(S_ex);
7018 //=====================================================================================
7019 // function : OnChamferGetSelected()
7021 //=====================================================================================
7022 bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
7023 const char* ShapeTopoIOR,
7024 const double D1, const double D2, const int SubShapeType,
7025 Standard_Integer& aLocalContextId,
7026 bool& myUseLocalContext)
7028 if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
7032 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
7033 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
7035 if( myUseLocalContext == false ) {
7036 /* No local context opened for chamfer method */
7037 myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
7041 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
7043 int nbSelected = ic->NbSelected();
7047 while(ic->MoreSelected()) {
7048 TopoDS_Shape s = ic->SelectedShape();
7049 if ( s.ShapeType() == TopAbs_FACE ) {
7050 TopExp_Explorer Exp( s, TopAbs_EDGE );
7051 TopTools_MapOfShape M ;
7052 while ( Exp.More() ) {
7053 if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
7054 ListOfID->length( i + 1 );
7055 ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
7062 ListOfID->length( i + 1 );
7063 ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ;
7069 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
7070 GEOM::GEOM_Shape_var aResult ;
7072 aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID );
7074 /* local context from DialogBox */
7075 ic->CloseLocalContext(aLocalContextId) ;
7076 myUseLocalContext = false ;
7078 TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
7079 Standard_CString type;
7080 GetShapeTypeString(S,type);
7081 aResult->NameType( type );
7083 if ( Display( aResult, "") )
7084 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7086 catch (const SALOME::SALOME_Exception& S_ex) {
7087 QtCatchCorbaException(S_ex);
7090 if ( myUseLocalContext ) {
7091 /* local context from DialogBox */
7092 ic->CloseLocalContext(aLocalContextId) ;
7093 myUseLocalContext = false ;
7096 this->OnDisplayAll(true);
7097 myActiveStudy->updateObjBrowser();
7098 myDesktop->putInfo (tr("GEOM_PRP_READY"));
7103 //=====================================================================================
7104 // function : MakeCDGAndDisplay()
7106 //=====================================================================================
7107 void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
7110 GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape );
7111 if ( result->_is_nil() ) {
7112 myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
7115 result->NameType( tr("GEOM_POINT") );
7116 if ( Display( result ) )
7117 myDesktop->putInfo(tr("GEOM_PRP_DONE"));
7119 catch (const SALOME::SALOME_Exception& S_ex) {
7120 QtCatchCorbaException(S_ex);
7125 bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) {
7126 SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
7127 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
7128 SALOMEDS::SObject_var RefSO;
7129 SALOMEDS::GenericAttribute_var anAttr;
7130 SALOMEDS::AttributeIOR_var anIOR;
7131 for (; it->More();it->Next()) {
7132 SALOMEDS::SObject_var SO= it->Value();
7133 if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
7134 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7135 if ( strcmp( anIOR->Value(), IOR ) == 0 )
7138 if ( SO->ReferencedObject( RefSO ) ) {
7139 if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) {
7140 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
7141 if ( strcmp( anIOR->Value(), IOR ) == 0 )