#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_ToolBox.h"
+
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent) : QDockWidget(theParent), myIsEditing(false)
{
{
ModuleBase_ModelWidget* aFirstWidget = 0;
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
ModuleBase_ModelWidget* aWgt;
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+ bool isOffToolBox = false;
for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) {
aWgt = (*aWIt);
- if (aWgt->canSetValue())
- aFirstWidget = aWgt;
+ if (!aValidators->isCase(aWgt->feature(), aWgt->attributeID()))
+ continue; // this attribute is not participated in the current case
+
+ if (!aWgt->canSetValue())
+ continue;
+
+ /// workaround for the same attributes used in different stacked widgets(attribute types)
+ if (ModuleBase_ToolBox::isOffToolBoxParent(aWgt))
+ continue;
+
+ aFirstWidget = aWgt;
}
return aFirstWidget;
}
// Author: Alexandre SOLOVYOV
#include <ModuleBase_ToolBox.h>
+#include <ModuleBase_ModelWidget.h>
+
#include <QButtonGroup>
#include <QStackedWidget>
#include <QHBoxLayout>
myStack->setCurrentIndex( theIndex );
}
+bool ModuleBase_ToolBox::isOffToolBoxParent(ModuleBase_ModelWidget* theWidget)
+{
+ bool isOffToolBox = false;
+
+ QList<QWidget*> aControls = theWidget->getControls();
+ if (aControls.size() > 0) {
+ QWidget* aFirstControl = aControls.first();
+
+ QWidget* aWidget = aFirstControl;
+ QWidget* aParent = (QWidget*)aFirstControl->parent();
+ while (aParent) {
+ QStackedWidget* aStackedWidget = dynamic_cast<QStackedWidget*>(aParent);
+ if (aStackedWidget) {
+ int anIndex = aStackedWidget->currentIndex();
+ isOffToolBox = aStackedWidget->currentWidget() != aWidget;
+ break;
+ }
+ aWidget = aParent;
+ aParent = (QWidget*)aWidget->parent();
+ }
+ }
+ return isOffToolBox;
+}
class QFrame;
class QHBoxLayout;
class QStackedWidget;
+class ModuleBase_ModelWidget;
/**
* \class ModuleBase_ToolBox
/// \param theIdx an index
void setCurrentIndex( const int theIdx);
+ /// Found in the controls of the model widget parent in Stacked Widget
+ /// returns whether this controls are in the current widget of the stacked widgets
+ /// \param theWidget a model widget
+ /// \return boolean result
+ static bool isOffToolBoxParent(ModuleBase_ModelWidget* theWidget);
+
signals:
/// A signal which is emited on current item changed
void currentChanged( int );
aVisible = theDisplayer->isVisible(theObject);
// compsolid is not visualized in the viewer, but should have presentation when all sub solids are
// visible. It is useful for highlight presentation where compsolid shape is selectable
- if (!aVisible && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
+ if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
#include "PartSet_WidgetPoint2d.h"
#include "ModelAPI_Session.h"
+#include "ModelAPI_AttributeString.h"
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_OperationFeature.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_Circle.h>
#include <XGUI_Workshop.h>
#include <XGUI_ModuleConnector.h>
if (!isActiveMgr())
return aWidget;
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
- if (aOperation) {
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+ if (anOperation) {
+ ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector()))
aWidget = myInternalActiveWidget;
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())
return;
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
- if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+ std::string anOperationId = anOperation->id().toStdString();
+ if (anOperationId == SketchPlugin_Line::ID()/* || isTangentArc(anOperation)*/) {
/// If last line finished on vertex the lines creation sequence has to be break
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
if (aFOperation) {
myNoMoreWidgetsAttribute = "";
myIsFlagsBlocked = true;
+ FeaturePtr aPrevFeature = aFOperation->feature();
aFOperation->commit();
module()->launchOperation(aFOperation->id());
+ // allow the same attribute values in restarted operation
+ ModuleBase_OperationFeature* aCurrentOperation = dynamic_cast<ModuleBase_OperationFeature*>(
+ myWorkshop->currentOperation());
+ copyReetntrantAttributes(aPrevFeature, aCurrentOperation->feature());
+
myIsFlagsBlocked = false;
resetFlags();
// we should avoid processing of the signal about no more widgets attributes and
}
}
+bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
+ const FeaturePtr& theNewFeature)
+{
+ bool aChanged;
+ 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*>
CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
+
+ bool isFeatureChanged = copyReetntrantAttributes(anOperationFeature, myInternalFeature);
XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
(aFOperation->propertyPanel());
!aWidget->getDefaultValue().empty() &&
!aWidget->isComputedDefault();
aWidget->setFeature(myInternalFeature, isStoreValue);
+ if (!isStoreValue && isFeatureChanged)
+ aWidget->restoreValue();
}
+
ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
(aWidgets);
if (aFirstWidget)
/// Breaks sequense of automatically resterted operations
void resetFlags();
+ /// Copy some feature specific attributes from the source to a new feature
+ /// This is type for Circle and Arc features
+ /// \param theSourceFeature a source feature
+ /// \param theNewFeature a new feature
+ /// \return true is something is copied
+ static bool copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
+ const FeaturePtr& theNewFeature);
+
/// Returns the workshop
XGUI_Workshop* workshop() const;
const double PI =3.141592653589793238463;
namespace {
- static const std::string& ARC_TYPE()
+ /*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& ARC_TYPE_TANGENT()
{
static const std::string TYPE("Tangent");
return TYPE;
- }
+ }*/
static const std::string& PASSED_POINT_ID()
{
data()->addAttribute(TANGENT_POINT_ID(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), RADIUS_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ANGLE_ID());
}
void SketchPlugin_Arc::execute()
return MY_SKETCH_ARC_ID;
}
+ inline static const std::string& ARC_TYPE()
+ {
+ static const std::string TYPE("ArcType");
+ return TYPE;
+ }
+
+ inline static const std::string& ARC_TYPE_TANGENT()
+ {
+ static const std::string TYPE("Tangent");
+ return TYPE;
+ }
+
/// Central 2D point of the circle which contains the arc
inline static const std::string& CENTER_ID()
{
return MY_CIRCLE_ID;
}
+ inline static const std::string& CIRCLE_TYPE()
+ {
+ static const std::string TYPE("CircleType");
+ return TYPE;
+ }
+
/// 2D point - center of the circle
inline static const std::string& CENTER_ID()
{
<point2ddistance id="CircleRadius" accept_expressions="0" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set radius">
<validator id="GeomValidators_Positive"/>
</point2ddistance>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
</box>
<box id="ThreePoints" title="Three points" icon=":icons/circle_3pt_32x32.png">
<sketch-2dpoint_selector id="FirstPoint" accept_expressions="0" title="First point" tooltip="First point"/>
<sketch-2dpoint_selector id="SecondPoint" accept_expressions="0" title="Second point" tooltip="Second point"/>
<sketch-2dpoint_selector id="ThirdPoint" accept_expressions="0" title="Third point" tooltip="Third point"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
</box>
</toolbox>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
</feature>
<!-- SketchArc -->
<sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"/>
<sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"/>
<sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
<validator id="GeomValidators_Different" parameters="ArcCenter,ArcStartPoint,ArcEndPoint"/>
</box>
<box id="ThreePoints" title="Three points on arc" icon=":icons/arc_3pt_32x32.png">
<sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"/>
<sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
<sketch-2dpoint_selector id="ArcPassedPoint" accept_expressions="0" title="Passed point" tooltip="Passed point"/>
- <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon=":icons/radius.png" tooltip="Set radius" obligatory="1">
+ <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon=":icons/radius.png" tooltip="Set radius" obligatory="0">
<validator id="GeomValidators_Positive"/>
</doublevalue>
- <doublevalue id="ArcAngle" label="Angle:" icon=":icons/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="1"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <doublevalue id="ArcAngle" label="Angle:" icon=":icons/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"/>
<validator id="GeomValidators_Different" parameters="ArcStartPoint,ArcEndPoint,ArcPassedPoint"/>
</box>
<box id="Tangent" title="Tangent with edge" icon=":icons/arc_tang_32x32.png">
<validator id="SketchPlugin_ArcTangentPoint" parameters="" />
</sketch_shape_selector>
<sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
- <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon=":icons/radius.png" tooltip="Set radius" obligatory="1">
+ <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon=":icons/radius.png" tooltip="Set radius" obligatory="0">
<validator id="GeomValidators_Positive"/>
</doublevalue>
- <doublevalue id="ArcAngle" label="Angle:" icon=":icons/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="1"/>
- <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+ <doublevalue id="ArcAngle" label="Angle:" icon=":icons/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"/>
</box>
</toolbox>
+ <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
</feature>
</group>