#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
-#include <ModuleBase_WidgetFeature.h>
-#include <ModuleBase_WidgetPoint2dDistance.h>
+#include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_ViewerPrs.h>
-#include <XGUI_ViewerPrs.h>
#include <XGUI_Constants.h>
#include <V3d_View.hxx>
return aModes;
}
-void PartSet_OperationFeatureCreate::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
+ myPreSelection = theSelected;
}
void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature)
{
- //if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
- // return;
myInitFeature = theFeature;
}
}
void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
if (canBeCommitted())
{
return;
}
- double aX = 0, anY = 0;
-
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+ double aX = aPoint.X(), anY = aPoint.Y();
+
if (theSelected.empty()) {
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
}
else {
- XGUI_ViewerPrs aPrs = theSelected.front();
+ ModuleBase_ViewerPrs aPrs = theSelected.front();
const TopoDS_Shape& aShape = aPrs.shape();
if (!aShape.IsNull()) // the point is selected
{
}
}
}
- bool isApplyed = false;
- if (isPointWidget())
- isApplyed = setWidgetPoint(aX, anY);
- else {
- if (!theSelected.empty()) {
- XGUI_ViewerPrs aPrs = theSelected.front();
- FeaturePtr aFeature = aPrs.feature();
- if (aFeature)
- isApplyed = setWidgetFeature(aFeature);
- }
+ FeaturePtr aFeature;
+ if (!theSelected.empty()) {
+ ModuleBase_ViewerPrs aPrs = theSelected.front();
+ aFeature = aPrs.feature();
}
+ else
+ aFeature = feature(); // for the widget distance only
+
+ bool isApplyed = setWidgetValue(aFeature, aX, anY);
if (isApplyed) {
flushUpdated();
emit activateNextWidget(myActiveWidget);
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- setWidgetPoint(aX, anY);
+ setWidgetValue(feature(), aX, anY);
flushUpdated();
}
}
void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
{
myActiveWidget = theWidget;
-
+ if ((myPreSelection.size() > 0) && myActiveWidget) {
+ const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+ ModuleBase_WidgetValueFeature aValue;
+ aValue.setFeature(aPrs.feature());
+ if (myActiveWidget->setValue(&aValue)) {
+ myPreSelection.remove(aPrs);
+ emit activateNextWidget(myActiveWidget);
+ }
+ }
if (myInitFeature && myActiveWidget) {
ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
return aNewFeature;
}
-bool PartSet_OperationFeatureCreate::isPointWidget() const
+bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY)
{
- return dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget) ||
- dynamic_cast<ModuleBase_WidgetPoint2dDistance*>(myActiveWidget);
-}
-
-bool PartSet_OperationFeatureCreate::setWidgetPoint(double theX, double theY)
-{
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint(new GeomAPI_Pnt2d(theX, theY));
- ModuleBase_WidgetPoint2D* aWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
- if (aWidget) {
- aWidget->setPoint(aPoint);
- return true;
- } else {
- ModuleBase_WidgetPoint2dDistance* aWgt = dynamic_cast<ModuleBase_WidgetPoint2dDistance*>(myActiveWidget);
- if (aWgt) {
- aWgt->setPoint(feature(), aPoint);
- return true;
- }
- }
- return false;
-}
-
-bool PartSet_OperationFeatureCreate::setWidgetFeature(const FeaturePtr& theFeature)
-{
- ModuleBase_WidgetFeature* aWidget = dynamic_cast<ModuleBase_WidgetFeature*>(myActiveWidget);
- if (!aWidget)
- return false;
-
- return aWidget->setFeature(theFeature);
+ ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+ aValue->setFeature(theFeature);
+ aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
+ bool isApplyed = myActiveWidget->setValue(aValue);
+
+ delete aValue;
+ myIsModified = (myIsModified || isApplyed);
+ return isApplyed;
}