Salome HOME
94773a51f227d93cee0598b5eb94db625bef254b
[modules/geom.git] / src / EntityGUI / EntityGUI_PolylineDlg.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "EntityGUI_PolylineDlg.h"
24 #include <CurveCreator_Curve.hxx>
25 #include <CurveCreator_Utils.hxx>
26 #include <CurveCreator_Widget.h>
27 #include <DlgRef.h>
28 #include <GeometryGUI.h>
29 #include <GEOMBase.h>
30
31 #include "utilities.h"
32
33 #include <OCCViewer_ViewManager.h>
34 #include <LightApp_SelectionMgr.h>
35 #include <SalomeApp_Application.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_Session.h>
38 #include "utilities.h"
39
40 #include <BRep_Tool.hxx>
41 #include <Geom_Surface.hxx>
42 #include <GeomLib_IsPlanarSurface.hxx>
43 #include <TopoDS.hxx>
44
45 #include <QGroupBox>
46 #include <QVBoxLayout>
47
48 //#define SET_PLANE
49
50 //=================================================================================
51 // function : Constructor
52 // purpose  :
53 //=================================================================================
54 EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
55         (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
56   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
57     myCurve               (0),
58     myEditorWidget        (0),
59     myAddElementBox       (0),
60     myPlnComboBox         (0),
61     myPlnButton           (0),
62     myPlnSelButton        (0),
63     myWPlaneLineEdit      (0),
64     myPolylineSelButton   (0),
65     myPolylineEdit        (0),
66     myEditCurrentArgument (0)
67 {
68   QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
69   QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
70
71   setWindowTitle(tr("POLYLINE_DLG_TITLE"));
72
73   /***************************************************************/
74   mainFrame()->GroupConstructors->setTitle(tr("POLYLINE_TITLE"));
75   mainFrame()->RadioButton1->setIcon(image0);
76   mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
77   mainFrame()->RadioButton2->close();
78   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
79   mainFrame()->RadioButton3->close();
80
81   QGroupBox   *aGroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
82   QGridLayout *aPlaneLayout = new QGridLayout(aGroupBox1);
83
84   aPlaneLayout->setSpacing(6);
85   aPlaneLayout->setMargin(11);
86
87   myPlnComboBox = new QComboBox(aGroupBox1);
88   aPlaneLayout->addWidget(myPlnComboBox, 0, 0, 1, 3);
89
90   myPlnButton = new QPushButton (aGroupBox1);
91   myPlnButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
92   aPlaneLayout->addWidget(myPlnButton, 0, 3);
93
94 #ifdef SET_PLANE
95   QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1);
96
97   myPlnSelButton = new QPushButton (aGroupBox1);
98   myPlnSelButton->setIcon(image1);
99   myWPlaneLineEdit = new QLineEdit (aGroupBox1);
100   myWPlaneLineEdit->setReadOnly(true);
101 #endif
102
103   QLabel *aPolylineLbl = new QLabel(tr("POLYLINE_IMPORT"), aGroupBox1);
104
105   myPolylineSelButton = new QPushButton (aGroupBox1);
106   myPolylineSelButton->setIcon(image1);
107   myPolylineEdit = new QLineEdit (aGroupBox1);
108   myPolylineEdit->setReadOnly(true);
109
110 #ifdef SET_PLANE
111   aPlaneLayout->addWidget(aPlaneLbl, 1, 0);
112   aPlaneLayout->addWidget(myPlnSelButton, 1, 1);
113   aPlaneLayout->addWidget(myWPlaneLineEdit, 1, 2, 1, 2);
114 #endif
115   aPlaneLayout->addWidget(aPolylineLbl, 2, 0);
116   aPlaneLayout->addWidget(myPolylineSelButton, 2, 1);
117   aPlaneLayout->addWidget(myPolylineEdit, 2, 2, 1, 2);
118   
119   aPlaneLayout->setColumnStretch(2, 1);
120
121   myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
122   myEditorWidget = new CurveCreator_Widget (centralWidget(), myCurve);
123   myAddElementBox = new QGroupBox (tr("POLYLINE_ADD_SECTION"), centralWidget());
124
125   QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
126
127   anAddElementLayout->setMargin( 0 );
128   anAddElementLayout->setSpacing( 6 );
129
130   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
131
132   layout->setMargin( 0 );
133   layout->setSpacing( 6 );
134   layout->addWidget( aGroupBox1 );
135   layout->addWidget( myEditorWidget );
136   layout->addWidget( myAddElementBox );
137
138   /***************************************************************/
139
140   setHelpFileName( "create_polyline_page.html" );
141
142   /* Initialisations */
143   Init();
144 }
145
146 //=================================================================================
147 // function : Destructor
148 // purpose  :
149 //=================================================================================
150 EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg()
151 {
152   delete myCurve;
153 }
154
155 //=================================================================================
156 // function : Init()
157 // purpose  :
158 //=================================================================================
159 void EntityGUI_PolylineDlg::Init()
160 {
161   initName(tr("POLYLINE_NAME"));
162
163   SalomeApp_Application *anApp        = myGeomGUI->getApp();
164   OCCViewer_ViewManager *aViewManager = dynamic_cast<OCCViewer_ViewManager*>
165     (anApp->getViewManager(OCCViewer_Viewer::Type(), true));
166   LightApp_SelectionMgr *aSelMgr = myGeomGUI->getApp()->selectionMgr();
167
168   myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0);
169
170   // Init the list of local coordinate system
171   gp_Pnt aPnt(0., 0., 0.);
172   gp_Dir aDirN(0., 0., 1.);
173   gp_Dir aDirX(1., 0., 0.);
174   gp_Ax3 aLCS(aPnt, aDirN, aDirX);
175
176   //add Global CS
177   myPlnComboBox->addItem(tr("GEOM_GCS"), false);
178   myWPlaneList.push_back(GEOM::GeomObjPtr());
179   myLCSList.push_back(aLCS);
180
181   connect(myGeomGUI,      SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
182   connect(myGeomGUI,      SIGNAL(SignalCloseAllDialogs()),        this, SLOT(ClickOnCancel()));
183
184 #ifdef SET_PLANE
185   connect(myPlnSelButton, SIGNAL(clicked()),
186           this,           SLOT(SetEditCurrentArgument()));
187 #endif
188   connect(myPolylineSelButton, SIGNAL(clicked()),
189           this,                SLOT(SetEditCurrentArgument()));
190   connect(aSelMgr,        SIGNAL(currentSelectionChanged()),
191           this,           SLOT(SelectionIntoArgument()));
192   connect(myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)),
193           this,           SLOT(processStartedSubOperation(QWidget*, bool)));
194   connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)),
195           this,           SLOT(processFinishedSubOperation(QWidget*)));
196   connect(myEditorWidget, SIGNAL(curveModified()),
197           this,           SLOT(onUpdatePreview()));
198 #ifdef SET_PLANE
199   connect(myPlnComboBox,  SIGNAL(activated(int)),
200           this,           SLOT(ActivateLocalCS()));
201   connect(myPlnButton,    SIGNAL(clicked()),
202           this,           SLOT(ActivateLocalCS()));
203 #endif
204   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
205   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
206
207   myAddElementBox->hide();
208   myPolylineSelButton->click();
209   SelectionIntoArgument();
210 }
211
212 //=================================================================================
213 // function : Clear
214 // purpose  :
215 //=================================================================================
216 void EntityGUI_PolylineDlg::Clear()
217 {
218   delete myCurve;
219
220   myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
221   myEditorWidget->setCurve(myCurve);
222 }
223
224 //=================================================================================
225 // function : GetCurveParams
226 // purpose  :
227 //=================================================================================
228 void EntityGUI_PolylineDlg::GetCurveParams(GEOM::ListOfListOfDouble &theCoords,
229                                            GEOM::string_array       &theNames,
230                                            GEOM::short_array        &theTypes,
231                                            GEOM::ListOfBool         &theCloseds)
232 {
233   const int aNbSec = myCurve->getNbSections();
234   int       i;
235   int       j;
236
237   theCoords.length(aNbSec);
238   theNames.length(aNbSec);
239   theTypes.length(aNbSec);
240   theCloseds.length(aNbSec);
241
242   for (i = 0; i < aNbSec; ++i) {
243     // Set coordinates
244     CurveCreator::Coordinates aCoords   = myCurve->getPoints(i);
245     const int                 aNbPoints = aCoords.size();
246
247     theCoords[i].length(aNbPoints);
248
249     for (j = 0; j < aNbPoints; ++j) {
250       theCoords[i][j] = aCoords[j];
251     }
252
253     // Set section type
254     const CurveCreator::SectionType aType = myCurve->getSectionType(i);
255
256     switch (aType) {
257       case CurveCreator::Spline:
258         theTypes[i] = GEOM::Interpolation;
259         break;
260       case CurveCreator::Polyline:
261       default:
262         theTypes[i] = GEOM::Polyline;
263         break;
264     }
265
266     // Set section names and closed flags.
267     theNames[i]   = CORBA::string_dup(myCurve->getSectionName(i).c_str());
268     theCloseds[i] = myCurve->isClosed(i);
269   }
270 }
271
272 //=================================================================================
273 // function : createOperation
274 // purpose  :
275 //=================================================================================
276 GEOM::GEOM_IOperations_ptr EntityGUI_PolylineDlg::createOperation()
277 {
278   return getGeomEngine()->GetICurvesOperations( getStudyId() );
279 }
280
281 //=================================================================================
282 // function : isValid
283 // purpose  :
284 //=================================================================================
285 bool EntityGUI_PolylineDlg::isValid( QString& msg )
286 {
287   return true;
288 }
289
290 //=================================================================================
291 // function : execute
292 // purpose  :
293 //=================================================================================
294 bool EntityGUI_PolylineDlg::execute( ObjectList& objects )
295 {
296   GEOM::GEOM_ICurvesOperations_var anOper =
297     GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
298
299   // Get the polyline creation parameters.
300   GEOM::ListOfListOfDouble aCoords;
301   GEOM::string_array       aNames;
302   GEOM::short_array        aTypes;
303   GEOM::ListOfBool         aCloseds;
304
305   GetCurveParams(aCoords, aNames, aTypes, aCloseds);
306
307   // Get Working Plane.
308   int ind = myPlnComboBox->currentIndex();
309
310   if (ind != -1) {
311     bool                  isPlane = myPlnComboBox->itemData(ind).toBool();
312     GEOM::GEOM_Object_var anObj;
313
314     // Perform operation
315     if (isPlane) {
316       anObj = anOper->MakePolyline2DOnPlane
317         (aCoords, aNames, aTypes, aCloseds, myWPlaneList.at(ind).get());
318     } else {
319       gp_Ax3             anAxis = myLCSList.at(ind);
320       GEOM::ListOfDouble aPlane;
321
322       aPlane.length(9);
323       aPlane[0] = anAxis.Location().X();
324       aPlane[1] = anAxis.Location().Y();
325       aPlane[2] = anAxis.Location().Z();
326       aPlane[3] = anAxis.Direction().X();
327       aPlane[4] = anAxis.Direction().Y();
328       aPlane[5] = anAxis.Direction().Z();
329       aPlane[6] = anAxis.XDirection().X();
330       aPlane[7] = anAxis.XDirection().Y();
331       aPlane[8] = anAxis.XDirection().Z();
332
333       anObj = anOper->MakePolyline2D
334         (aCoords, aNames, aTypes, aCloseds, aPlane);
335     }
336
337     if (!anObj->_is_nil()) {
338       objects.push_back(anObj._retn());
339     }
340   }
341
342   return true;
343 }
344
345 //=================================================================================
346 // function : ClickOnOk()
347 // purpose  :
348 //=================================================================================
349 void EntityGUI_PolylineDlg::ClickOnOk()
350 {
351   setIsApplyAndClose( true );
352
353   if (ClickOnApply())
354     ClickOnCancel();
355 }
356
357 //=================================================================================
358 // function : ClickOnApply()
359 // purpose  :
360 //=================================================================================
361 bool EntityGUI_PolylineDlg::ClickOnApply()
362 {
363   if (!onAccept())
364     return false;
365
366   initName();
367
368   return true;
369 }
370
371 //=================================================================================
372 // function : ClickOnCancel()
373 // purpose  :
374 //=================================================================================
375 void EntityGUI_PolylineDlg::ClickOnCancel()
376 {
377   myEditorWidget->SetViewer2DMode(false);
378   GEOMBase_Skeleton::ClickOnCancel();
379 }
380
381 //=================================================================================
382 // function : processStartedSubOperation
383 // purpose  :
384 //=================================================================================
385 void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
386 {
387   myEditorWidget->setEnabled( false );
388
389   myAddElementBox->setTitle( theIsEdit ? tr( "POLYLINE_EDIT_SECTION" ) : tr( "POLYLINE_ADD_SECTION" ) );
390   QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
391   anAddElementLayout->addWidget( theWidget );
392
393   theWidget->show();
394   myAddElementBox->show();
395 }
396
397
398 //=================================================================================
399 // function : processFinishedSubOperation
400 // purpose  :
401 //=================================================================================
402 void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
403 {
404   myEditorWidget->setEnabled( true );
405
406   QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
407   anAddElementLayout->removeWidget( theWidget );
408
409   theWidget->hide();
410   myAddElementBox->hide();
411 }
412
413 //=================================================================================
414 // function : deleteSelected
415 // purpose  : Redirect the delete action to editor widget
416 //=================================================================================
417 void EntityGUI_PolylineDlg::deleteSelected()
418 {
419   myEditorWidget->removeSelected();
420 }
421
422 //=================================================================================
423 // function : deleteEnabled
424 // purpose  : Checks whether there are some to delete
425 //=================================================================================
426 bool EntityGUI_PolylineDlg::deleteEnabled()
427 {
428   return myEditorWidget->removeEnabled();
429 }
430
431 //=================================================================================
432 // function : SelectionIntoArgument
433 // purpose  : Called when selection is changed
434 //=================================================================================
435 void EntityGUI_PolylineDlg::SelectionIntoArgument()
436 {
437   bool             isModified      = false;
438   GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
439   TopoDS_Shape     aShape;
440
441   if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) &&
442       !aShape.IsNull()) {
443     QString aName = GEOMBase::GetName(aSelectedObject.get()); 
444
445     if (myEditCurrentArgument == myPolylineEdit) {
446       // Import a curve
447       CurveCreator_Curve *aNewCurve = 
448         new CurveCreator_Curve(CurveCreator::Dim2d);
449       gp_Ax3              aLocalCS;
450
451       if (CurveCreator_Utils::constructCurve(aShape, aNewCurve, aLocalCS)) {
452         // Change the current curve be the new one.
453         myEditorWidget->setCurve(aNewCurve);
454         delete myCurve;
455         myCurve = aNewCurve;
456         isModified = true;
457         myPolylineEdit->setText(aName);
458 #ifdef SET_PLANE
459         AddLocalCS(aSelectedObject.get(), false, aLocalCS);
460         myWPlaneLineEdit->clear();
461         myPlnSelButton->setDown(false);
462 #endif
463         myPolylineSelButton->setDown(true);
464       } else {
465         // Does nothing, just clears selection.
466         delete aNewCurve;
467       }
468 #ifdef SET_PLANE
469     } else if (myEditCurrentArgument == myWPlaneLineEdit) {
470       // Import planar face.
471       if (aShape.ShapeType() == TopAbs_FACE) {
472         // Check if the face is planar
473         Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
474         GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
475
476         if (aPlanarCheck.IsPlanar()) {
477           myWPlaneLineEdit->setText(aName);
478           myPolylineEdit->clear();
479           AddLocalCS(aSelectedObject.get(), true, 
480                      WPlaneToLCS(aSelectedObject.get()));
481           isModified = true;
482           myPlnSelButton->setDown(true);
483           myPolylineSelButton->setDown(false);
484         }
485       }
486       
487       if (!isModified) {
488         myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
489       }
490 #endif
491     }
492   }
493
494   if (!isModified) {
495     // Does nothing, just clears selection.
496     disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
497     myGeomGUI->getApp()->selectionMgr()->clearSelected();
498     connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
499             this, SLOT(SelectionIntoArgument()));
500   }
501 }
502
503 //=================================================================================
504 // function : SetEditCurrentArgument()
505 // purpose  :
506 //=================================================================================
507 void EntityGUI_PolylineDlg::SetEditCurrentArgument()
508 {
509   if (sender() == myPlnSelButton) {
510 #ifdef SET_PLANE
511     myEditCurrentArgument = myWPlaneLineEdit;
512     myEditCurrentArgument->setFocus();
513     myPlnSelButton->setDown(true);
514     myPolylineSelButton->setDown(false);
515 #endif
516   } else if (sender() == myPolylineSelButton) {
517     myEditCurrentArgument = myPolylineEdit;
518     myEditCurrentArgument->setFocus();
519 #ifdef SET_PLANE
520     myPlnSelButton->setDown(false);
521 #endif
522     myPolylineSelButton->setDown(true);
523   }
524 }
525
526 //=================================================================================
527 // function : ActivateThisDialog
528 // purpose  :
529 //=================================================================================
530 void EntityGUI_PolylineDlg::ActivateThisDialog()
531 {
532   GEOMBase_Skeleton::ActivateThisDialog();
533
534   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
535            this, SLOT(SelectionIntoArgument()));
536 }
537
538 //=================================================================================
539 // function : enterEvent()
540 // purpose  :
541 //=================================================================================
542 void EntityGUI_PolylineDlg::enterEvent (QEvent*)
543 {
544   if (!mainFrame()->GroupConstructors->isEnabled())
545     ActivateThisDialog();
546 }
547
548 //=================================================================================
549 // function : onUpdatePreview
550 // purpose  : 
551 //=================================================================================
552 void EntityGUI_PolylineDlg::onUpdatePreview()
553 {
554   displayPreview(true);
555 }
556
557 //=================================================================================
558 // function : ActivateLocalCS
559 // purpose  : Activate & Fit Working plane
560 //=================================================================================
561 void EntityGUI_PolylineDlg::ActivateLocalCS()
562 {
563   const int ind = myPlnComboBox->currentIndex();
564
565   if (ind == 0) {
566     // Default plane
567 #ifdef SET_PLANE
568     myWPlaneLineEdit->clear();
569 #endif
570     myPolylineEdit->clear();
571   } else if (ind > 0) { // Skip 0 as it is default
572     // Update text on line edits.
573     QString aName   = GEOMBase::GetName(GetActiveWPlane().get());
574     bool    isPlane = myPlnComboBox->itemData(ind).toBool();
575
576     if (isPlane) {
577 #ifdef SET_PLANE
578       myWPlaneLineEdit->setText(aName);
579 #endif
580       myPolylineEdit->clear();
581     } else {
582       myPolylineEdit->setText(aName);
583 #ifdef SET_PLANE
584       myWPlaneLineEdit->clear();
585 #endif
586     }
587   }
588
589   gp_Ax3 anAxis = GetActiveLocalCS();
590
591   myGeomGUI->SetWorkingPlane(anAxis);
592   myGeomGUI->ActiveWorkingPlane();
593 }
594
595 //=================================================================================
596 // function : GetActiveLocalCS
597 // purpose  : Get Working plane
598 //=================================================================================
599 gp_Ax3 EntityGUI_PolylineDlg::GetActiveLocalCS()
600 {
601   const int ind = myPlnComboBox->currentIndex();
602
603   return ind >= 0 ? myLCSList.at(ind) : myGeomGUI->GetWorkingPlane();
604 }
605
606 //=================================================================================
607 // function : GetActiveWPlane
608 // purpose  : Get Working plane
609 //=================================================================================
610 GEOM::GeomObjPtr EntityGUI_PolylineDlg::GetActiveWPlane()
611 {
612   const int ind = myPlnComboBox->currentIndex();
613
614   return ind >= 0 ? myWPlaneList.at(ind) : GEOM::GeomObjPtr();
615 }
616
617 //=================================================================================
618 // function : AddLocalCS()
619 // purpose  : Add All Coordinates systems in study
620 //=================================================================================
621 void EntityGUI_PolylineDlg::AddLocalCS(GEOM::GeomObjPtr  theSelectedObject,
622                                        const bool        IsPlane,
623                                        const gp_Ax3      &theLCS)
624 {
625   QString aName = GEOMBase::GetName(theSelectedObject.get());
626
627   int index = myPlnComboBox->findText(aName, Qt::MatchExactly);
628
629   if (index == -1) { // If the working plane hasn't been added yet
630     myWPlaneList.push_back(theSelectedObject);
631     myLCSList.push_back(theLCS);
632     myPlnComboBox->addItem(aName, QVariant(IsPlane));
633     index = myPlnComboBox->count();
634     myPlnComboBox->setCurrentIndex(index - 1);
635   } else {
636     myPlnComboBox->setCurrentIndex(index);
637   }
638   ActivateLocalCS();
639 }
640
641 //=================================================================================
642 // function : WPlaneToLCS ( aWPlane )
643 // purpose  : 
644 //=================================================================================
645 gp_Ax3 EntityGUI_PolylineDlg::WPlaneToLCS(GEOM::GeomObjPtr theGeomObj)
646 {
647   TopoDS_Shape aShape =
648     GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), theGeomObj.get());
649   gp_Ax3 aLCS;
650
651   if (theGeomObj || aShape.IsNull()) {
652     MESSAGE("CORBA::is_nil(theGeomObj) || aShape.IsNull()")
653   }
654
655   aLCS.Transform(aShape.Location().Transformation());
656
657   if (aShape.ShapeType() == TopAbs_FACE) {
658     GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
659       myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId());
660     double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
661
662     aMeasureOp->GetPosition(theGeomObj.get(), Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
663
664     if (aMeasureOp->IsDone()) {
665       gp_Pnt aPnt (Ox, Oy, Oz);
666       gp_Dir aDirN (Zx, Zy, Zz);
667       gp_Dir aDirX (Xx, Xy, Xz);
668       aLCS = gp_Ax3(aPnt, aDirN, aDirX);
669     }
670   }
671
672   return aLCS;
673 }
674
675 //=================================================================================
676 // function : getSourceObjects
677 // purpose  : virtual method to get source objects
678 //=================================================================================
679 QList<GEOM::GeomObjPtr> EntityGUI_PolylineDlg::getSourceObjects()
680 {
681   return myWPlaneList;
682 }