1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "PartSet_WidgetSketchLabel.h"
22 #include "PartSet_Tools.h"
23 #include "PartSet_Module.h"
24 #include "PartSet_PreviewPlanes.h"
26 #include "SketchPlugin_SketchEntity.h"
28 #include <XGUI_Workshop.h>
29 #include <XGUI_Displayer.h>
30 #include <XGUI_SelectionMgr.h>
31 #include <XGUI_Selection.h>
32 #include <XGUI_ViewerProxy.h>
33 #include <XGUI_ActionsMgr.h>
34 #include <XGUI_Tools.h>
35 #include <XGUI_ModuleConnector.h>
37 #include <ModuleBase_Operation.h>
38 #include <ModuleBase_ViewerPrs.h>
39 #include <ModuleBase_Tools.h>
40 #include <ModuleBase_IModule.h>
42 #include <ModelAPI_ResultBody.h>
43 #include <ModelAPI_Tools.h>
45 #include <GeomAlgoAPI_FaceBuilder.h>
46 #include <GeomAlgoAPI_ShapeTools.h>
47 #include <GeomDataAPI_Point.h>
48 #include <GeomDataAPI_Dir.h>
49 #include <GeomAPI_XYZ.h>
50 #include <GeomAPI_Face.h>
51 #include <GeomAPI_Edge.h>
52 #include <GeomAPI_ShapeExplorer.h>
54 #include <SketchPlugin_Sketch.h>
55 #include <SketcherPrs_Tools.h>
57 #include <Precision.hxx>
61 #include <AIS_Shape.hxx>
62 #include <AIS_DimensionSelectionMode.hxx>
63 #include <Bnd_Box.hxx>
65 #include <Config_WidgetAPI.h>
66 #include <Config_PropManager.h>
69 #include <QApplication>
70 #include <QVBoxLayout>
71 #include <QHBoxLayout>
74 #include <QPushButton>
75 #include <QStackedWidget>
77 #include <QDoubleValidator>
80 #define DBL_MAX 1.7976931348623158e+308
83 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
84 ModuleBase_IWorkshop* theWorkshop,
85 const Config_WidgetAPI* theData,
86 const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints)
87 : ModuleBase_WidgetValidated(theParent, theWorkshop, theData)
89 QVBoxLayout* aLayout = new QVBoxLayout(this);
90 ModuleBase_Tools::zeroMargins(aLayout);
92 myStackWidget = new QStackedWidget(this);
93 myStackWidget->setContentsMargins(0,0,0,0);
94 aLayout->addWidget(myStackWidget);
96 // Define label for plane selection
97 QWidget* aFirstWgt = new QWidget(this);
99 // Size of the View control
100 mySizeOfViewWidget = new QWidget(aFirstWgt);
101 QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
102 aSizeLayout->addWidget(new QLabel("Size of the view", mySizeOfViewWidget));
103 mySizeOfView = new QLineEdit(mySizeOfViewWidget);
105 QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
106 aValidator->setLocale(ModuleBase_Tools::doubleLocale());
107 aValidator->setNotation(QDoubleValidator::StandardNotation);
108 mySizeOfView->setValidator(aValidator);
109 aSizeLayout->addWidget(mySizeOfView);
111 QString aText = QString::fromStdString(theData->getProperty("title"));
112 QLabel* aLabel = new QLabel(aText, aFirstWgt);
113 aLabel->setWordWrap(true);
114 QString aTooltip = QString::fromStdString(theData->getProperty("tooltip"));
115 aLabel->setToolTip(aTooltip);
116 aLabel->setIndent(5);
118 aLayout = new QVBoxLayout(aFirstWgt);
119 ModuleBase_Tools::zeroMargins(aLayout);
120 aLayout->addWidget(mySizeOfViewWidget);
121 aLayout->addWidget(aLabel);
122 aLayout->addStretch(1);
124 myStackWidget->addWidget(aFirstWgt);
126 // Define widget for sketch manmagement
127 QWidget* aSecondWgt = new QWidget(this);
128 aLayout = new QVBoxLayout(aSecondWgt);
129 ModuleBase_Tools::zeroMargins(aLayout);
131 QGroupBox* aViewBox = new QGroupBox(tr("Sketcher plane"), this);
132 QVBoxLayout* aViewLayout = new QVBoxLayout(aViewBox);
134 myViewInverted = new QCheckBox(tr("Reversed"), aViewBox);
135 aViewLayout->addWidget(myViewInverted);
137 QPushButton* aSetViewBtn =
138 new QPushButton(QIcon(":icons/plane_view.png"), tr("Set plane view"), aViewBox);
139 connect(aSetViewBtn, SIGNAL(clicked(bool)), this, SLOT(onSetPlaneView()));
140 aViewLayout->addWidget(aSetViewBtn);
142 aLayout->addWidget(aViewBox);
144 QMap<PartSet_Tools::ConstraintVisibleState, QString> aStates;
145 aStates[PartSet_Tools::Geometrical] = tr("Show geometrical constraints");
146 aStates[PartSet_Tools::Dimensional] = tr("Show dimensional constraints");
147 aStates[PartSet_Tools::Expressions] = tr("Show existing expressions");
149 QMap<PartSet_Tools::ConstraintVisibleState, QString>::const_iterator anIt = aStates.begin(),
150 aLast = aStates.end();
151 for (; anIt != aLast; anIt++) {
152 QCheckBox* aShowConstraints = new QCheckBox(anIt.value(), this);
153 connect(aShowConstraints, SIGNAL(toggled(bool)), this, SLOT(onShowConstraint(bool)));
154 aLayout->addWidget(aShowConstraints);
156 PartSet_Tools::ConstraintVisibleState aState = anIt.key();
157 myShowConstraints[aState] = aShowConstraints;
159 if (toShowConstraints.contains(aState))
160 aShowConstraints->setChecked(toShowConstraints[aState]);
163 myStackWidget->addWidget(aSecondWgt);
164 //setLayout(aLayout);
166 myPreviewPlanes = new PartSet_PreviewPlanes();
169 PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
173 bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
174 const bool theToValidate)
176 // do not use the given selection if the plane of the sketch has been already set.
177 // If this check is absent, a selected plane in the viewer can be set in the sketch
178 // even if the sketch is built on another plane.
182 ModuleBase_ViewerPrsPtr aPrs = theValues.first();
183 bool aDone = setSelectionInternal(theValues, theToValidate);
185 updateByPlaneSelected(aPrs);
189 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
191 QList<QWidget*> aResult;
192 aResult << myStackWidget;
196 void PartSet_WidgetSketchLabel::onSelectionChanged()
198 std::shared_ptr<GeomAPI_Pln> aPlane = plane();
202 QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
204 if (aSelected.empty())
206 ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
207 bool aDone = setSelectionInternal(aSelected, false);
209 updateByPlaneSelected(aPrs);
210 updateObject(myFeature);
214 void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn)
216 QCheckBox* aSenderCheckBox = qobject_cast<QCheckBox*>(sender());
218 QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*>::const_iterator
219 anIt = myShowConstraints.begin(), aLast = myShowConstraints.end();
221 PartSet_Tools::ConstraintVisibleState aState = PartSet_Tools::Geometrical;
223 for (; anIt != aLast && !aFound; anIt++) {
224 aFound = anIt.value() == aSenderCheckBox;
229 emit showConstraintToggled(aState, theOn);
232 void PartSet_WidgetSketchLabel::blockAttribute(const AttributePtr& theAttribute,
233 const bool& theToBlock, bool& isFlushesActived,
234 bool& isAttributeSetInitializedBlocked,
235 bool& isAttributeSendUpdatedBlocked)
237 ModuleBase_WidgetValidated::blockAttribute(theAttribute, theToBlock, isFlushesActived,
238 isAttributeSetInitializedBlocked,
239 isAttributeSendUpdatedBlocked);
240 // We do not restore the previous state of isAttributeSetInitializedBlocked for each of
241 // attributes. It it is necessary, these states should be append to the method attributes
242 // or stored in the widget
244 std::list<AttributePtr> anAttributes = myFeature->data()->attributes("");
245 std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
247 for(; anIt != aLast; anIt++) {
248 AttributePtr anAttribute = *anIt;
250 anAttribute->blockSetInitialized(true);
252 anAttribute->blockSetInitialized(isAttributeSetInitializedBlocked);
256 bool PartSet_WidgetSketchLabel::setSelectionInternal(
257 const QList<ModuleBase_ViewerPrsPtr>& theValues,
258 const bool theToValidate)
261 if (theValues.empty()) {
262 // In order to make reselection possible, set empty object and shape should be done
263 setSelectionCustom(std::shared_ptr<ModuleBase_ViewerPrs>(
264 new ModuleBase_ViewerPrs(ObjectPtr(), GeomShapePtr(), NULL)));
268 // it removes the processed value from the parameters list
269 ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst();
270 if (!theToValidate || isValidInFilters(aValue))
271 aDone = setSelectionCustom(aValue);
277 void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs)
279 // 1. hide main planes if they have been displayed and display sketch preview plane
280 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
282 PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
284 CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
285 bool isSetSizeOfView = false;
286 double aSizeOfView = 0;
287 QString aSizeOfViewStr = mySizeOfView->text();
288 if (!aSizeOfViewStr.isEmpty()) {
289 aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
290 if (isSetSizeOfView && aSizeOfView <= 0) {
291 isSetSizeOfView = false;
295 aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
296 aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
298 aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
300 // 2. if the planes were displayed, change the view projection
301 const GeomShapePtr& aShape = thePrs->shape();
302 std::shared_ptr<GeomAPI_Shape> aGShape;
304 DataPtr aData = feature()->data();
305 AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
306 (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
308 // selection happens in OCC viewer
309 if (aShape.get() && !aShape->isNull()) {
312 else { // selection happens in OCC viewer(on body) of in the OB browser
314 aGShape = aSelAttr->value();
317 // If the selected object is a sketch then use its plane
318 std::shared_ptr<GeomAPI_Pln> aPlane;
319 ObjectPtr aObj = thePrs->object();
320 // obsolete as selected sketch is stored in external attribute
322 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
323 if (aFeature.get() && (aFeature != feature())) {
324 if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
325 CompositeFeaturePtr aSketch =
326 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
327 aPlane = PartSet_Tools::sketchPlane(aSketch);
331 if (aGShape.get() != NULL) {
332 // get plane parameters
334 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aGShape));
335 aPlane = aFace->getPlane();
339 std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
340 gp_XYZ aXYZ = aDir->impl<gp_Dir>().XYZ();
343 // orienting projection is not needed: it is done in GeomAlgoAPI_FaceBuilder::plane
344 /*if (aGShape->impl<TopoDS_Shape>().Orientation() == TopAbs_REVERSED) {
348 // Rotate view if the sketcher plane is selected only from preview planes
349 // Preview planes are created only if there is no any shape
350 bool aRotate = Config_PropManager::boolean(SKETCH_TAB_NAME, "rotate_to_plane");
352 myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist);
354 PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
356 aModule->onViewTransformed();
358 // 3. Clear text in the label
359 myStackWidget->setCurrentIndex(1);
360 //myLabel->setText("");
361 //myLabel->setToolTip("");
362 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
363 // 4. deactivate face selection filter
364 activateFilters(false);
366 // 5. Clear selection mode and define sketching mode
367 emit planeSelected(plane());
368 // after the plane is selected in the sketch, the sketch selection should be activated
369 // it can not be performed in the sketch label widget because, we don't need to switch off
370 // the selection by any label deactivation, but need to switch it off by stop the sketch
371 activateSelection(true);
373 // 6. Update sketcher actions
374 XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
376 myWorkshop->updateCommandStatus();
377 aWorkshop->selector()->clearSelection();
378 myWorkshop->viewer()->update();
381 std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
383 CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
384 return PartSet_Tools::sketchPlane(aSketch);
387 bool PartSet_WidgetSketchLabel::focusTo()
389 ModuleBase_Tools::setFocus(myStackWidget, "PartSet_WidgetSketchLabel::focusTo()");
393 void PartSet_WidgetSketchLabel::enableFocusProcessing()
395 myStackWidget->installEventFilter(this);
398 void PartSet_WidgetSketchLabel::storeAttributeValue(const AttributePtr& theAttribute)
400 ModuleBase_WidgetValidated::storeAttributeValue(theAttribute);
403 void PartSet_WidgetSketchLabel::restoreAttributeValue(const AttributePtr& theAttribute,
406 ModuleBase_WidgetValidated::restoreAttributeValue(theAttribute, theValid);
408 // it is not necessary to save the previous plane value because the plane is chosen once
409 DataPtr aData = feature()->data();
410 AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
411 (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
413 ResultPtr anEmptyResult;
414 GeomShapePtr anEmptyShape;
415 aSelAttr->setValue(anEmptyResult, anEmptyShape);
419 bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
421 return fillSketchPlaneBySelection(thePrs);
424 bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs)
426 bool aCanFillSketch = true;
427 // avoid any selection on sketch object
428 ObjectPtr anObject = thePrs->object();
429 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
431 FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
432 if (aFeature->getKind() == SketchPlugin_Sketch::ID())
433 aCanFillSketch = false;
435 // check plane or planar face of any non-sketch object
436 if (aCanFillSketch) {
437 std::shared_ptr<GeomAPI_Face> aGeomFace;
439 GeomShapePtr aGeomShape = thePrs->shape();
440 if ((!aGeomShape.get() || aGeomShape->isNull()) && aResult.get()) {
441 aGeomShape = aResult->shape();
444 if (aGeomShape.get() && aGeomShape->shapeType() == GeomAPI_Shape::FACE) {
445 std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
446 aCanFillSketch = aGeomFace.get() && aGeomFace->isPlanar();
449 aCanFillSketch = false;
451 return aCanFillSketch;
454 //********************************************************************
455 bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType,
456 const ActionParamPtr& theParam)
458 if (theActionType == ActionSelection)
459 onSelectionChanged();
461 return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
466 bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs)
468 bool isOwnerSet = false;
470 const GeomShapePtr& aShape = thePrs->shape();
471 std::shared_ptr<GeomAPI_Dir> aDir;
473 if (thePrs->object() && (feature() != thePrs->object())) {
474 FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object());
475 DataPtr aData = feature()->data();
476 AttributeSelectionPtr aSelAttr =
477 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
478 (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
480 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs->object());
482 GeomShapePtr aShapePtr(new GeomAPI_Shape());
483 if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer
484 aShapePtr = ModelAPI_Tools::shape(aRes);
486 else { // selection happens in OB browser
489 if (aShapePtr.get() != NULL) {
490 aSelAttr->setValue(aRes, aShapePtr);
496 else if (aShape.get() && !aShape->isNull()) {
497 const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
498 aDir = setSketchPlane(aTDShape);
499 isOwnerSet = aDir.get();
504 void PartSet_WidgetSketchLabel::activateCustom()
506 std::shared_ptr<GeomAPI_Pln> aPlane = plane();
508 myStackWidget->setCurrentIndex(1);
509 activateSelection(true);
513 myStackWidget->setCurrentIndex(0);
514 bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
516 // Clear previous selection mode It is necessary for correct activation of preview planes
517 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
518 XGUI_Displayer* aDisp = aWorkshop->displayer();
519 aDisp->activateObjects(QIntList(), aDisp->displayedObjects(), false);
521 if (!aBodyIsVisualized) {
522 // We have to select a plane before any operation
523 myPreviewPlanes->showPreviewPlanes(myWorkshop);
524 mySizeOfViewWidget->setVisible(true);
527 mySizeOfViewWidget->setVisible(false);
529 activateSelection(true);
530 activateFilters(true);
533 void PartSet_WidgetSketchLabel::deactivate()
535 ModuleBase_ModelWidget::deactivate();
536 bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
537 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
538 activateSelection(false);
540 activateFilters(false);
542 myWorkshop->viewer()->update();
545 void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
549 std::shared_ptr<GeomAPI_Pln> aPlane = plane();
551 myWorkshop->module()->activeSelectionModes(aModes);
554 aModes << TopAbs_FACE;
556 myWorkshop->activateSubShapesSelection(aModes);
558 myWorkshop->deactivateSubShapesSelection();
563 std::shared_ptr<GeomAPI_Dir>
564 PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
566 if (theShape.IsNull())
567 return std::shared_ptr<GeomAPI_Dir>();
569 // get selected shape
570 std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
571 aGShape->setImpl(new TopoDS_Shape(theShape));
573 // get plane parameters
574 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aGShape));
575 std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
577 return std::shared_ptr<GeomAPI_Dir>();
578 return setSketchPlane(aPlane);
581 std::shared_ptr<GeomAPI_Dir>
582 PartSet_WidgetSketchLabel::setSketchPlane(std::shared_ptr<GeomAPI_Pln> thePlane)
584 // set plane parameters to feature
585 std::shared_ptr<ModelAPI_Data> aData = feature()->data();
586 double anA, aB, aC, aD;
587 thePlane->coefficients(anA, aB, aC, aD);
589 // calculate attributes of the sketch
590 std::shared_ptr<GeomAPI_Dir> aNormDir(new GeomAPI_Dir(anA, aB, aC));
591 std::shared_ptr<GeomAPI_XYZ> aCoords = aNormDir->xyz();
592 std::shared_ptr<GeomAPI_XYZ> aZero(new GeomAPI_XYZ(0, 0, 0));
593 aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
594 std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
595 // X axis is preferable to be dirX on the sketch
596 const double tol = Precision::Confusion();
597 bool isX = fabs(fabs(anA) - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
598 std::shared_ptr<GeomAPI_Dir> aTempDir(
599 isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
600 std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
601 std::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
603 std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
604 aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
605 anOrigin->setValue(anOrigPnt);
606 std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
607 aData->attribute(SketchPlugin_Sketch::NORM_ID()));
608 aNormal->setValue(aNormDir);
609 std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
610 aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
611 aDirX->setValue(aXDir);
612 std::shared_ptr<GeomAPI_Dir> aDir = thePlane->direction();
616 void PartSet_WidgetSketchLabel::onSetPlaneView()
618 std::shared_ptr<GeomAPI_Pln> aPlane = plane();
620 std::shared_ptr<GeomAPI_Dir> aDirection = aPlane->direction();
621 gp_Dir aDir = aDirection->impl<gp_Dir>();
622 if (myViewInverted->isChecked())
624 myWorkshop->viewer()->setViewProjection(aDir.X(), aDir.Y(), aDir.Z(), 0.);
625 PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
627 aModule->onViewTransformed();
632 //******************************************************
633 QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCircularEdgesInPlane()
635 QList<std::shared_ptr<ModuleBase_ViewerPrs>> aResult;
636 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
637 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
638 QObjectPtrList aDispObjects = aDisplayer->displayedObjects();
640 std::shared_ptr<GeomAPI_Pln> aPlane = plane();
641 foreach(ObjectPtr aObj, aDispObjects) {
642 ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
644 GeomShapePtr aShape = aResObj->shape();
646 GeomAPI_ShapeExplorer aExplorer(aShape, GeomAPI_Shape::EDGE);
647 for(; aExplorer.more(); aExplorer.next()) {
648 GeomShapePtr aEdgeShape = aExplorer.current();
649 GeomAPI_Edge anEdge(aEdgeShape);
650 if ((anEdge.isCircle() || anEdge.isArc() || anEdge.isEllipse()) &&
651 anEdge.isInPlane(aPlane)) {
652 bool isContains = false;
653 // Check that edge is not used.
654 // It is possible that the same edge will be taken from different faces
655 foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aResult) {
656 GeomAPI_Edge aUsedEdge(aPrs->shape());
657 if (aUsedEdge.isEqual(aEdgeShape)) {
663 std::shared_ptr<ModuleBase_ViewerPrs>
664 aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
665 aResult.append(aPrs);