1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetSketchCreator.cpp
4 // Created: 08 June 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "PartSet_WidgetSketchCreator.h"
8 #include "PartSet_Module.h"
10 #include <XGUI_ModuleConnector.h>
11 #include <XGUI_Workshop.h>
12 #include <XGUI_Displayer.h>
13 #include <XGUI_SelectionMgr.h>
15 #include <GeomAPI_Face.h>
17 #include <ModuleBase_Tools.h>
18 #include <ModuleBase_Operation.h>
19 #include <ModuleBase_IPropertyPanel.h>
20 #include <Config_WidgetAPI.h>
24 #include <QFormLayout>
26 PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
27 PartSet_Module* theModule,
28 const Config_WidgetAPI* theData,
29 const std::string& theParentId)
30 : ModuleBase_ModelWidget(theParent, theData, theParentId), myModule(theModule)
32 QFormLayout* aLayout = new QFormLayout(this);
33 ModuleBase_Tools::adjustMargins(aLayout);
35 QString aLabelText = QString::fromStdString(theData->widgetLabel());
36 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
37 myLabel = new QLabel(aLabelText, this);
38 if (!aLabelIcon.isEmpty())
39 myLabel->setPixmap(QPixmap(aLabelIcon));
42 QString aToolTip = QString::fromStdString(theData->widgetTooltip());
43 myTextLine = new QLineEdit(this);
44 myTextLine->setReadOnly(true);
45 myTextLine->setToolTip(aToolTip);
46 myTextLine->installEventFilter(this);
48 aLayout->addRow(myLabel, myTextLine);
51 PartSet_WidgetSketchCreator::~PartSet_WidgetSketchCreator()
55 QList<QWidget*> PartSet_WidgetSketchCreator::getControls() const
57 QList<QWidget*> aControls;
58 aControls.append(myTextLine);
62 bool PartSet_WidgetSketchCreator::restoreValue()
67 bool PartSet_WidgetSketchCreator::storeValueCustom() const
72 void PartSet_WidgetSketchCreator::activateCustom()
74 connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
77 //XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
78 //XGUI_Workshop* aWorkshop = aConnector->workshop();
79 //XGUI_Displayer* aDisp = aWorkshop->displayer();
82 //aModes << TopAbs_FACE;
83 //aDisp->activateObjects(aModes);
85 //connect(aWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
86 //activateFilters(myModule->workshop(), true);
89 void PartSet_WidgetSketchCreator::onStarted()
91 disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
93 CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
94 FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
96 ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
97 anOperation->setFeature(aSketch);
98 myModule->sendOperation(anOperation);
101 void PartSet_WidgetSketchCreator::storeAttributeValue()
105 void PartSet_WidgetSketchCreator::restoreAttributeValue(const bool theValid)
109 bool PartSet_WidgetSketchCreator::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
111 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face());
112 aFace->setImpl(new TopoDS_Shape(thePrs.shape()));
113 if (aFace->isPlanar())
115 //CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
116 //FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
118 //ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
119 //anOperation->setFeature(aSketch);
120 //myModule->sendOperation(anOperation);
124 bool PartSet_WidgetSketchCreator::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)