1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "EntityGUI_PolylineDlg.h"
24 #include <CurveCreator_Curve.hxx>
25 #include <CurveCreator_Displayer.hxx>
26 #include <CurveCreator_Utils.hxx>
27 #include <CurveCreator_Widget.h>
29 #include <GeometryGUI.h>
32 #include "utilities.h"
34 #include <OCCViewer_ViewManager.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <SalomeApp_Application.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_Session.h>
39 #include "utilities.h"
41 #include <BRep_Tool.hxx>
42 #include <Geom_Surface.hxx>
43 #include <GeomLib_IsPlanarSurface.hxx>
44 #include <Prs3d_LineAspect.hxx>
48 #include <QVBoxLayout>
52 //=================================================================================
53 // function : Constructor
55 //=================================================================================
56 EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
57 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
58 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
66 myPolylineSelButton (0),
68 myEditCurrentArgument (0),
72 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
73 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
75 setWindowTitle(tr("POLYLINE_DLG_TITLE"));
77 /***************************************************************/
78 mainFrame()->GroupConstructors->setTitle(tr("POLYLINE_TITLE"));
79 mainFrame()->RadioButton1->setIcon(image0);
80 mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
81 mainFrame()->RadioButton2->close();
82 mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
83 mainFrame()->RadioButton3->close();
85 QGroupBox *aGroupBox1 = new QGroupBox(this);
86 QGridLayout *aPlaneLayout = new QGridLayout(aGroupBox1);
88 aPlaneLayout->setSpacing(6);
89 aPlaneLayout->setMargin(11);
91 myPlnComboBox = new QComboBox(aGroupBox1);
92 aPlaneLayout->addWidget(myPlnComboBox, 0, 0, 1, 3);
94 myPlnButton = new QPushButton (aGroupBox1);
95 myPlnButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
96 aPlaneLayout->addWidget(myPlnButton, 0, 3);
102 myPlnComboBox->setVisible( isCS );
103 myPlnButton->setVisible( isCS );
106 QLabel *aPlaneLbl = new QLabel(tr("GEOM_PLANE"), aGroupBox1);
108 myPlnSelButton = new QPushButton (aGroupBox1);
109 myPlnSelButton->setIcon(image1);
110 myWPlaneLineEdit = new QLineEdit (aGroupBox1);
111 myWPlaneLineEdit->setReadOnly(true);
114 QLabel *aPolylineLbl = new QLabel(tr("POLYLINE_IMPORT"), aGroupBox1);
116 myPolylineSelButton = new QPushButton (aGroupBox1);
117 myPolylineSelButton->setIcon(image1);
118 myPolylineSelButton->setCheckable(true);
119 myPolylineEdit = new QLineEdit (aGroupBox1);
120 myPolylineEdit->setReadOnly(true);
123 aPlaneLayout->addWidget(aPlaneLbl, 1, 0);
124 aPlaneLayout->addWidget(myPlnSelButton, 1, 1);
125 aPlaneLayout->addWidget(myWPlaneLineEdit, 1, 2, 1, 2);
127 aPlaneLayout->addWidget(aPolylineLbl, 2, 0);
128 aPlaneLayout->addWidget(myPolylineSelButton, 2, 1);
129 aPlaneLayout->addWidget(myPolylineEdit, 2, 2, 1, 2);
131 aPlaneLayout->setColumnStretch(2, 1);
133 myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
134 myEditorWidget = new CurveCreator_Widget (centralWidget(), myCurve);
135 myAddElementBox = new QGroupBox (tr("POLYLINE_ADD_SECTION"), centralWidget());
137 QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
139 anAddElementLayout->setMargin( 0 );
140 anAddElementLayout->setSpacing( 6 );
142 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
144 layout->setMargin( 0 );
145 layout->setSpacing( 6 );
146 layout->addWidget( aGroupBox1 );
147 layout->addWidget( myEditorWidget );
148 layout->addWidget( myAddElementBox );
150 /***************************************************************/
152 setHelpFileName( "create_polyline_page.html" );
154 /* Initializations */
158 //=================================================================================
159 // function : Destructor
161 //=================================================================================
162 EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg()
165 myEditorWidget->SetViewer2DMode(false);
168 //=================================================================================
171 //=================================================================================
172 void EntityGUI_PolylineDlg::Init()
174 initName(tr("POLYLINE_NAME"));
176 SalomeApp_Application *anApp = myGeomGUI->getApp();
177 OCCViewer_ViewManager *aViewManager = dynamic_cast<OCCViewer_ViewManager*>
178 (anApp->getViewManager(OCCViewer_Viewer::Type(), true));
179 LightApp_SelectionMgr *aSelMgr = myGeomGUI->getApp()->selectionMgr();
181 myEditorWidget->setOCCViewer(aViewManager ? aViewManager->getOCCViewer() : 0);
182 setPreviewManager( aViewManager );
184 // Init the list of local coordinate system
185 gp_Pnt aPnt(0., 0., 0.);
186 gp_Dir aDirN(0., 0., 1.);
187 gp_Dir aDirX(1., 0., 0.);
188 gp_Ax3 aLCS(aPnt, aDirN, aDirX);
191 myPlnComboBox->addItem(tr("GEOM_GCS"), false);
192 myWPlaneList.push_back(GEOM::GeomObjPtr());
193 myLCSList.push_back(aLCS);
196 connect( myPlnSelButton, SIGNAL(toggled(bool)),
197 this, SLOT(SetEditCurrentArgument(bool)) );
199 connect( myPolylineSelButton, SIGNAL(toggled(bool)),
200 this, SLOT(SetEditCurrentArgument(bool)) );
201 connect( aSelMgr, SIGNAL(currentSelectionChanged()),
202 this, SLOT(SelectionIntoArgument()) );
203 connect( myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)),
204 this, SLOT(processStartedSubOperation(QWidget*, bool)) );
205 connect( myEditorWidget, SIGNAL(subOperationFinished(QWidget*)),
206 this, SLOT(processFinishedSubOperation(QWidget*)) );
208 connect( myPlnComboBox, SIGNAL(activated(int)),
209 this, SLOT(ActivateLocalCS()) );
210 connect( myPlnButton, SIGNAL(clicked()),
211 this, SLOT(ActivateLocalCS()) );
213 connect( buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()) );
214 connect( buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()) );
216 myAddElementBox->hide();
218 // Processing of the selected object
219 myPolylineSelButton->setChecked( true );
220 SelectionIntoArgument( true );
223 //=================================================================================
226 //=================================================================================
227 void EntityGUI_PolylineDlg::Clear()
231 myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
232 myEditorWidget->setCurve(myCurve);
235 //=================================================================================
236 // function : GetCurveParams
238 //=================================================================================
239 void EntityGUI_PolylineDlg::GetCurveParams(GEOM::ListOfListOfDouble &theCoords,
240 GEOM::string_array &theNames,
241 GEOM::short_array &theTypes,
242 GEOM::ListOfBool &theCloseds)
244 const int aNbSec = myCurve->getNbSections();
248 theCoords.length(aNbSec);
249 theNames.length(aNbSec);
250 theTypes.length(aNbSec);
251 theCloseds.length(aNbSec);
253 for (i = 0; i < aNbSec; ++i) {
255 CurveCreator::Coordinates aCoords = myCurve->getPoints(i);
256 const int aNbPoints = aCoords.size();
258 theCoords[i].length(aNbPoints);
260 for (j = 0; j < aNbPoints; ++j) {
261 theCoords[i][j] = aCoords[j];
265 const CurveCreator::SectionType aType = myCurve->getSectionType(i);
268 case CurveCreator::Spline:
269 theTypes[i] = GEOM::Interpolation;
271 case CurveCreator::Polyline:
273 theTypes[i] = GEOM::Polyline;
277 // Set section names and closed flags.
278 theNames[i] = CORBA::string_dup(myCurve->getSectionName(i).c_str());
279 theCloseds[i] = myCurve->isClosed(i);
283 //=================================================================================
284 // function : createOperation
286 //=================================================================================
287 GEOM::GEOM_IOperations_ptr EntityGUI_PolylineDlg::createOperation()
289 return getGeomEngine()->GetICurvesOperations( getStudyId() );
292 //=================================================================================
293 // function : isValid
295 //=================================================================================
296 bool EntityGUI_PolylineDlg::isValid( QString& msg )
301 //=================================================================================
302 // function : execute
304 //=================================================================================
305 bool EntityGUI_PolylineDlg::execute( ObjectList& objects )
307 GEOM::GEOM_ICurvesOperations_var anOper =
308 GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
310 // Get the polyline creation parameters.
311 GEOM::ListOfListOfDouble aCoords;
312 GEOM::string_array aNames;
313 GEOM::short_array aTypes;
314 GEOM::ListOfBool aCloseds;
316 GetCurveParams(aCoords, aNames, aTypes, aCloseds);
318 // Get Working Plane.
319 int ind = myPlnComboBox->currentIndex();
322 bool isPlane = myPlnComboBox->itemData(ind).toBool();
323 GEOM::GEOM_Object_var anObj;
327 anObj = anOper->MakePolyline2DOnPlane
328 (aCoords, aNames, aTypes, aCloseds, myWPlaneList.at(ind).get());
330 gp_Ax3 anAxis = myLCSList.at(ind);
331 GEOM::ListOfDouble aPlane;
334 aPlane[0] = anAxis.Location().X();
335 aPlane[1] = anAxis.Location().Y();
336 aPlane[2] = anAxis.Location().Z();
337 aPlane[3] = anAxis.Direction().X();
338 aPlane[4] = anAxis.Direction().Y();
339 aPlane[5] = anAxis.Direction().Z();
340 aPlane[6] = anAxis.XDirection().X();
341 aPlane[7] = anAxis.XDirection().Y();
342 aPlane[8] = anAxis.XDirection().Z();
344 anObj = anOper->MakePolyline2D
345 (aCoords, aNames, aTypes, aCloseds, aPlane);
348 if (!anObj->_is_nil()) {
349 objects.push_back(anObj._retn());
356 //=================================================================================
357 // function : ClickOnOk()
359 //=================================================================================
360 void EntityGUI_PolylineDlg::ClickOnOk()
362 setIsApplyAndClose( true );
368 //=================================================================================
369 // function : ClickOnApply()
371 //=================================================================================
372 bool EntityGUI_PolylineDlg::ClickOnApply()
380 myEditorWidget->reset();
385 //=================================================================================
386 // function : processStartedSubOperation
388 //=================================================================================
389 void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
391 myEditorWidget->setEnabled( false );
393 myAddElementBox->setTitle( theIsEdit ? tr( "POLYLINE_EDIT_SECTION" ) : tr( "POLYLINE_ADD_SECTION" ) );
394 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
395 anAddElementLayout->addWidget( theWidget );
398 myAddElementBox->show();
402 //=================================================================================
403 // function : processFinishedSubOperation
405 //=================================================================================
406 void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
408 myEditorWidget->setEnabled( true );
410 QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
411 anAddElementLayout->removeWidget( theWidget );
414 myAddElementBox->hide();
417 //=================================================================================
418 // function : deleteSelected
419 // purpose : Redirect the delete action to editor widget
420 //=================================================================================
421 void EntityGUI_PolylineDlg::deleteSelected()
423 myEditorWidget->removeSelected();
426 //=================================================================================
427 // function : deleteEnabled
428 // purpose : Checks whether there are some to delete
429 //=================================================================================
430 bool EntityGUI_PolylineDlg::deleteEnabled()
432 return myEditorWidget->removeEnabled();
435 //=================================================================================
436 // function : SelectionIntoArgument
437 // purpose : Called when selection is changed
438 //=================================================================================
439 void EntityGUI_PolylineDlg::SelectionIntoArgument( bool isForced )
441 bool isModified = isForced;
442 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
445 if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) &&
448 QString aName = GEOMBase::GetName(aSelectedObject.get());
450 if ( myEditCurrentArgument == myPolylineEdit && isCheckToSelect() )
453 CurveCreator_Curve *aNewCurve =
454 new CurveCreator_Curve(CurveCreator::Dim2d);
457 if (CurveCreator_Utils::constructCurve(aShape, aNewCurve, aLocalCS)) {
458 // Change the current curve be the new one.
459 myEditorWidget->setCurve(aNewCurve);
463 myPolylineEdit->setText(aName);
465 AddLocalCS(aSelectedObject.get(), false, aLocalCS);
466 myWPlaneLineEdit->clear();
467 myPlnSelButton->setChecked(false);
469 myPolylineSelButton->setChecked(false);
471 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
472 myGeomGUI->getApp()->selectionMgr()->clearSelected();
473 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
474 this, SLOT(SelectionIntoArgument()));
476 // Does nothing, just clears selection.
481 else if ( myEditCurrentArgument == myWPlaneLineEdit && isCheckToSelect() )
483 // Import planar face.
484 if (aShape.ShapeType() == TopAbs_FACE) {
485 // Check if the face is planar
486 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
487 GeomLib_IsPlanarSurface aPlanarCheck(aSurf, Precision::Confusion());
489 if (aPlanarCheck.IsPlanar()) {
490 myWPlaneLineEdit->setText(aName);
491 myPolylineEdit->clear();
492 AddLocalCS(aSelectedObject.get(), true,
493 WPlaneToLCS(aSelectedObject.get()));
495 myPlnSelButton->setChecked(false);
496 myPolylineSelButton->setChecked(false);
501 myEditCurrentArgument->setText(tr("GEOM_SKETCHER_WPLANE"));
511 myPlnSelButton->setChecked(false);
513 myPolylineSelButton->setChecked(false);
519 // Does nothing, just clears selection.
520 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
521 myGeomGUI->getApp()->selectionMgr()->clearSelected();
522 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
523 this, SLOT(SelectionIntoArgument()));
529 //=================================================================================
530 // function : SetEditCurrentArgument()
532 //=================================================================================
533 void EntityGUI_PolylineDlg::SetEditCurrentArgument( bool isChecked )
535 if (sender() == myPlnSelButton)
538 myEditCurrentArgument = myWPlaneLineEdit;
539 myEditCurrentArgument->setFocus();
540 myPolylineSelButton->blockSignals(true);
541 myPolylineSelButton->setChecked(false);
542 myPolylineSelButton->blockSignals(false);
545 else if (sender() == myPolylineSelButton)
547 myEditCurrentArgument = myPolylineEdit;
548 myEditCurrentArgument->setFocus();
550 myPlnSelButton->blockSignals(true);
551 myPlnSelButton->setChecked(false);
552 myPlnSelButton->blockSignals(false);
557 //=================================================================================
558 // function : ActivateThisDialog
560 //=================================================================================
561 void EntityGUI_PolylineDlg::ActivateThisDialog()
563 GEOMBase_Skeleton::ActivateThisDialog();
565 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
566 this, SLOT(SelectionIntoArgument()));
569 //=================================================================================
570 // function : enterEvent()
572 //=================================================================================
573 void EntityGUI_PolylineDlg::enterEvent (QEvent*)
575 if (!mainFrame()->GroupConstructors->isEnabled())
576 ActivateThisDialog();
579 //=================================================================================
580 // function : ActivateLocalCS
581 // purpose : Activate & Fit Working plane
582 //=================================================================================
583 void EntityGUI_PolylineDlg::ActivateLocalCS()
585 const int ind = myPlnComboBox->currentIndex();
590 myWPlaneLineEdit->clear();
592 myPolylineEdit->clear();
593 } else if (ind > 0) { // Skip 0 as it is default
594 // Update text on line edits.
595 QString aName = GEOMBase::GetName(GetActiveWPlane().get());
596 bool isPlane = myPlnComboBox->itemData(ind).toBool();
600 myWPlaneLineEdit->setText(aName);
602 myPolylineEdit->clear();
604 myPolylineEdit->setText(aName);
606 myWPlaneLineEdit->clear();
611 gp_Ax3 anAxis = GetActiveLocalCS();
613 myGeomGUI->SetWorkingPlane(anAxis);
614 myGeomGUI->ActiveWorkingPlane();
617 //=================================================================================
618 // function : GetActiveLocalCS
619 // purpose : Get Working plane
620 //=================================================================================
621 gp_Ax3 EntityGUI_PolylineDlg::GetActiveLocalCS()
623 const int ind = myPlnComboBox->currentIndex();
625 return ind >= 0 ? myLCSList.at(ind) : myGeomGUI->GetWorkingPlane();
628 //=================================================================================
629 // function : GetActiveWPlane
630 // purpose : Get Working plane
631 //=================================================================================
632 GEOM::GeomObjPtr EntityGUI_PolylineDlg::GetActiveWPlane()
634 const int ind = myPlnComboBox->currentIndex();
636 return ind >= 0 ? myWPlaneList.at(ind) : GEOM::GeomObjPtr();
639 //=================================================================================
640 // function : AddLocalCS()
641 // purpose : Add All Coordinates systems in study
642 //=================================================================================
643 void EntityGUI_PolylineDlg::AddLocalCS(GEOM::GeomObjPtr theSelectedObject,
645 const gp_Ax3 &theLCS)
647 QString aName = GEOMBase::GetName(theSelectedObject.get());
649 int index = myPlnComboBox->findText(aName, Qt::MatchExactly);
651 if (index == -1) { // If the working plane hasn't been added yet
652 myWPlaneList.push_back(theSelectedObject);
653 myLCSList.push_back(theLCS);
654 myPlnComboBox->addItem(aName, QVariant(IsPlane));
655 index = myPlnComboBox->count();
656 myPlnComboBox->setCurrentIndex(index - 1);
658 myPlnComboBox->setCurrentIndex(index);
663 //=================================================================================
664 // function : WPlaneToLCS ( aWPlane )
666 //=================================================================================
667 gp_Ax3 EntityGUI_PolylineDlg::WPlaneToLCS(GEOM::GeomObjPtr theGeomObj)
669 TopoDS_Shape aShape =
670 GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), theGeomObj.get());
673 if (theGeomObj || aShape.IsNull()) {
674 MESSAGE("CORBA::is_nil(theGeomObj) || aShape.IsNull()")
677 aLCS.Transform(aShape.Location().Transformation());
679 if (aShape.ShapeType() == TopAbs_FACE) {
680 GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
681 myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId());
682 double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
684 aMeasureOp->GetPosition(theGeomObj.get(), Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
686 if (aMeasureOp->IsDone()) {
687 gp_Pnt aPnt (Ox, Oy, Oz);
688 gp_Dir aDirN (Zx, Zy, Zz);
689 gp_Dir aDirX (Xx, Xy, Xz);
690 aLCS = gp_Ax3(aPnt, aDirN, aDirX);
697 //=================================================================================
698 // function : getSourceObjects
699 // purpose : virtual method to get source objects
700 //=================================================================================
701 QList<GEOM::GeomObjPtr> EntityGUI_PolylineDlg::getSourceObjects()
706 //=================================================================================
707 // function : setPreviewManager ( OCCViewer_ViewManager )
708 // purpose : Sets view manager to control the displayed objects.
709 //=================================================================================
710 void EntityGUI_PolylineDlg::setPreviewManager( OCCViewer_ViewManager* theManager )
712 myPreviewManager = theManager;
714 if ( getPreviewManager() )
716 if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
718 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
721 // Add Z layer to show temporary objects
723 aViewer->getViewer3d()->AddZLayer( aZLayer );
724 setPreviewZLayer( aZLayer );
730 //=================================================================================
731 // function : getPreviewManager()
733 //=================================================================================
734 OCCViewer_ViewManager* EntityGUI_PolylineDlg::getPreviewManager()
736 return myPreviewManager;
739 //=================================================================================
740 // function : setPreviewZLayer( theZLayer )
741 // purpose : Sets Z layer to show temporary objects.
742 //=================================================================================
743 void EntityGUI_PolylineDlg::setPreviewZLayer( int theZLayer )
745 if ( theZLayer != myPreviewZLayer )
746 myPreviewZLayer = theZLayer;
749 //=================================================================================
750 // function : getPreviewZLayer()
752 //=================================================================================
753 int EntityGUI_PolylineDlg::getPreviewZLayer() const
755 return myPreviewZLayer;
758 //=================================================================================
759 // function : displayPreview()
761 //=================================================================================
762 void EntityGUI_PolylineDlg::displayPreview()
764 if ( getPreviewManager() )
766 if ( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
768 // Disable changing of OCCViewer's selection to use vertex of curve selection
769 disconnect(getPreviewManager(), SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
770 aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
772 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
773 if ( !aCtx.IsNull() )
775 CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx, getPreviewZLayer() );
776 myCurve->setDisplayer( aDisplayer );
778 Handle(AIS_InteractiveObject) anAISObj = myCurve->getAISObject( true );
779 aDisplayer->display( anAISObj, true );
781 // Set color for temporary AIS_InteractiveObject
782 anAISObj->Attributes()->WireAspect()->SetColor( Quantity_NOC_VIOLET );
783 aCtx->Redisplay( anAISObj );
789 //=================================================================================
790 // function : erasePreview()
792 //=================================================================================
793 void EntityGUI_PolylineDlg::erasePreview()
795 CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0;
796 if( getPreviewManager() )
798 if( OCCViewer_Viewer* aViewer = getPreviewManager()->getOCCViewer() )
800 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
801 if( !aCtx.IsNull() && aDisplayer )
802 aDisplayer->eraseAll( true );
804 // Enable changing of OCCViewer's selection
805 connect(getPreviewManager(), SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
806 aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
810 setPreviewManager( NULL );
818 //=================================================================================
819 // function : isCheckToSelect()
821 //=================================================================================
822 bool EntityGUI_PolylineDlg::isCheckToSelect()
825 return myPlnSelButton->isChecked();
827 return myPolylineSelButton->isChecked();