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