#include "ModelAPI_Session.h"
#include "ModelAPI_AttributeString.h"
+#include "ModelAPI_AttributeRefAttr.h"
+
+#include "GeomDataAPI_Point2D.h"
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_PageBase.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
+#include "ModuleBase_ToolBox.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Line.h>
return aProcessed;
if (myIsInternalEditOperation) {
- PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
- if (aPoint2DWdg && aPoint2DWdg->canBeActivatedByMove()) {
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
- FeaturePtr aLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature() : FeaturePtr();
- restartOperation();
- aProcessed = true;
-
- if (aLastFeature) {
- ModuleBase_IPropertyPanel* aPanel = myWorkshop->currentOperation()->propertyPanel();
- PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(aPanel->activeWidget());
- if (aPoint2DWdg && aPoint2DWdg->canBeActivatedByMove()) {
- QList<ModuleBase_ViewerPrs> aSelection;
- aSelection.append(ModuleBase_ViewerPrs(aLastFeature, TopoDS_Shape(), NULL));
- if (aPoint2DWdg->setSelection(aSelection, true))
- aPanel->activateNextWidget(aPoint2DWdg);
+ FeaturePtr aLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature()
+ : FeaturePtr();
+ if (aLastFeature) {
+ ModuleBase_ModelWidget* anActiveWidget = module()->activeWidget();
+ ModuleBase_IPropertyPanel* aPanel = myWorkshop->currentOperation()->propertyPanel();
+ bool aWidgetIsFilled = false;
+
+ //bool aCanBeActivatedByMove = false;
+ FeaturePtr aCurrentFeature = anActiveWidget->feature();
+ bool isLineFeature = false, isArcFeature = false;
+ if (aCurrentFeature->getKind() == SketchPlugin_Line::ID())
+ isLineFeature = anActiveWidget->attributeID() == SketchPlugin_Line::START_ID();
+ else if (isTangentArc(aFOperation))
+ isArcFeature = anActiveWidget->attributeID() == SketchPlugin_Arc::TANGENT_POINT_ID();
+
+ bool aCanBeActivatedByMove = isLineFeature || isArcFeature;
+ if (aCanBeActivatedByMove) {
+ restartOperation();
+
+ anActiveWidget = module()->activeWidget();
+ aCurrentFeature = anActiveWidget->feature();
+ aProcessed = true;
+ if (isLineFeature) {
+ PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
+ if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line
+ QList<ModuleBase_ViewerPrs> aSelection;
+ aSelection.append(ModuleBase_ViewerPrs(aLastFeature, TopoDS_Shape(), NULL));
+ aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true);
+ }
+ }
+ else if (isArcFeature) { // arc, start point should be equal last point of the last feature arc
+ if (aCurrentFeature->getKind() == SketchPlugin_Arc::ID()) {
+ // get the last point of the previuos arc feature(geom point 2d)
+ std::shared_ptr<ModelAPI_Data> aData = aLastFeature->data();
+ std::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::END_ID()));
+ // get point attribute on the current feature
+ AttributeRefAttrPtr aTangentPointAttr = aCurrentFeature->data()->refattr(
+ SketchPlugin_Arc::TANGENT_POINT_ID());
+ aTangentPointAttr->setAttr(aPointAttr);
+ aWidgetIsFilled = true;
+ }
}
}
+ if (aWidgetIsFilled)
+ aPanel->activateNextWidget(anActiveWidget);
}
}
return aProcessed;
return isDone;
}
-/*bool isTangentArc(ModuleBase_Operation* theOperation)
-{
- bool aTangentArc = false;
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (theOperation);
- if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
- FeaturePtr aFeature = aFOperation->feature();
- if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
- AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
- std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
- aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
- }
- }
-
- return aTangentArc;
-}*/
-
void PartSet_SketcherReetntrantMgr::onVertexSelected()
{
if (!isActiveMgr())
ModuleBase_ModelWidget* aPreviousAttributeWidget = 0;
QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) {
- if (aWidgets[i]->attributeID() == thePreviousAttributeID)
+ if (aWidgets[i]->attributeID() == thePreviousAttributeID) {
+ /// workaround for the same attributes used in different stacked widgets(attribute types)
+ if (ModuleBase_ToolBox::isOffToolBoxParent(aWidgets[i]))
+ continue;
aPreviousAttributeWidget = aWidgets[i];
+ }
}
// If the current widget is a selector, do nothing, it processes the mouse press
if (aPreviousAttributeWidget) {
}
}
-bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
- const FeaturePtr& theNewFeature)
-{
- bool aChanged = false;
- std::string aTypeAttributeId;
- if (theSourceFeature->getKind() == SketchPlugin_Circle::ID()) {
- aTypeAttributeId = SketchPlugin_Circle::CIRCLE_TYPE();
- }
- if (theSourceFeature->getKind() == SketchPlugin_Arc::ID()) {
- aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
- }
- if (!aTypeAttributeId.empty()) {
- AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
- AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
- aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
- ModuleBase_ModelWidget::updateObject(theNewFeature);
- aChanged = true;
- }
- return aChanged;
-}
-
void PartSet_SketcherReetntrantMgr::createInternalFeature()
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
}
}
+bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
+ const FeaturePtr& theNewFeature)
+{
+ bool aChanged = false;
+ std::string aTypeAttributeId;
+ if (theSourceFeature->getKind() == SketchPlugin_Circle::ID()) {
+ aTypeAttributeId = SketchPlugin_Circle::CIRCLE_TYPE();
+ }
+ if (theSourceFeature->getKind() == SketchPlugin_Arc::ID()) {
+ aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
+ }
+ if (!aTypeAttributeId.empty()) {
+ AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
+ AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
+ aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
+ ModuleBase_ModelWidget::updateObject(theNewFeature);
+ aChanged = true;
+ }
+ return aChanged;
+}
+
+bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation)
+{
+ bool aTangentArc = false;
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (theOperation);
+ if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
+ FeaturePtr aFeature = aFOperation->feature();
+ if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
+ std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
+ aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
+ }
+ }
+ return aTangentArc;
+}
+
XGUI_Workshop* PartSet_SketcherReetntrantMgr::workshop() const
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
const double PI =3.141592653589793238463;
namespace {
- /*static const std::string& ARC_TYPE()
- {
- static const std::string TYPE("ArcType");
- return TYPE;
- }*/
static const std::string& ARC_TYPE_CENTER_START_END()
{
static const std::string TYPE("CenterStartEnd");
static const std::string TYPE("ThreePoints");
return TYPE;
}
- /*static const std::string& ARC_TYPE_TANGENT()
- {
- static const std::string TYPE("Tangent");
- return TYPE;
- }*/
static const std::string& PASSED_POINT_ID()
{
static const std::string PASSED_PNT("ArcPassedPoint");
return PASSED_PNT;
}
- static const std::string& TANGENT_POINT_ID()
- {
- static const std::string TANGENT_PNT("ArcTangentPoint");
- return TANGENT_PNT;
- }
static const std::string& RADIUS_ID()
{
static const std::string RADIUS("ArcRadius");
bool theArcReversed,
std::shared_ptr<GeomDataAPI_Point2D> thePassedPoint)
{
+ if (theCenter->distance(theStartPoint) < tolerance ||
+ theCenter->distance(theEndPoint) < tolerance)
+ return;
+
std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(
theStartPoint->xy()->decreased(theCenter->xy())));
std::shared_ptr<GeomAPI_Dir2d> aEndDir(new GeomAPI_Dir2d(
if (aRadiusAttr && anAngleAttr) {
std::shared_ptr<GeomAPI_Circ2d> aCircle(
new GeomAPI_Circ2d(aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt()));
- calculateArcAngleRadius(aCircle, aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt(),
- anAngleAttr, aRadiusAttr);
+ if (aCircle->implPtr<void*>())
+ calculateArcAngleRadius(aCircle, aStartAttr->pnt(), anEndAttr->pnt(), aPassedPoint->pnt(),
+ anAngleAttr, aRadiusAttr);
}
data()->blockSendAttributeUpdated(false);
}