#include <PartSet_Tools.h>
#include <ModelAPI_ResultBody.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_WidgetValueFeature.h>
+
#include <SketchPlugin_Feature.h>
#include <V3d_View.hxx>
#include <AIS_Shape.hxx>
return std::list<FeaturePtr>();
}
-std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
-{
- std::list<int> aModes;
- //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
- //if (aFeature) {
- // if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
- // aModes.clear();
- // aModes.push_back(AIS_DSM_Text);
- // aModes.push_back(AIS_DSM_Line);
- // return aModes;
- // }
- //}
- aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
- aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
- aModes.push_back(AIS_DSM_Text);
- aModes.push_back(AIS_DSM_Line);
- return aModes;
-}
FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
{
ModuleBase_Operation::createFeature(theFlushMessage);
{
}
-void PartSet_OperationSketchBase::keyReleased(const int theKey)
-{
- switch (theKey) {
- case Qt::Key_Escape: {
- bool toAbort = true;
- if (isModified()) {
- int anAnswer = QMessageBox::question(
- qApp->activeWindow(),
- tr("Cancel operation"),
- tr("Do you want to cancel %1 operation?").arg(id()),
- QMessageBox::Yes,
- QMessageBox::No);
- toAbort = (anAnswer == QMessageBox::Yes);
- }
- if (toAbort)
- abort();
- }
- break;
- default:
- break;
- }
-}
-
void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
{
FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
if (aFeature) {
QStringList aNested = this->nestedFeatures();
if (!aNested.isEmpty()) {
- if (aNested.contains(QString(aFeature->getKind().c_str())))
- emit restartRequired(theType, theFeature);
- else
+ if (!aNested.contains(QString(aFeature->getKind().c_str())))
return;
}
}
emit restartRequired(theType, theFeature);
}
+
+
+
+void PartSet_OperationSketchBase::activateByPreselection()
+{
+ if (!myPropertyPanel)
+ return;
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if ((myPreSelection.size() > 0) && aActiveWgt) {
+ const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+ ModuleBase_WidgetValueFeature aValue;
+ aValue.setObject(aPrs.object());
+ if (aActiveWgt->setValue(&aValue)) {
+ myPreSelection.remove(aPrs);
+ if(isValid()) {
+ //myActiveWidget = NULL;
+ commit();
+ } else {
+ myPropertyPanel->activateNextWidget();
+ //emit activateNextWidget(myActiveWidget);
+ }
+ }
+ // If preselection is enough to make a valid feature - apply it immediately
+ }
+}