PartSet_WidgetSketchLabel.h
PartSet_Validators.h
PartSet_WidgetPoint2d.h
- PartSet_WidgetConstraintShapeSelector.h
PartSet_WidgetEditor.h
PartSet_WidgetPoint2dDistance.h
PartSet_WidgetShapeSelector.h
PartSet_Tools.cpp
PartSet_WidgetSketchLabel.cpp
PartSet_Validators.cpp
- PartSet_WidgetConstraintShapeSelector.cpp
PartSet_WidgetEditor.cpp
PartSet_WidgetPoint2d.cpp
PartSet_WidgetPoint2dDistance.cpp
#include <PartSet_WidgetPoint2d.h>
#include <PartSet_WidgetPoint2dDistance.h>
#include <PartSet_WidgetShapeSelector.h>
-#include <PartSet_WidgetConstraintShapeSelector.h>
#include <PartSet_WidgetEditor.h>
#include "PartSet_SketcherMgr.h"
#include "PartSet_MenuMgr.h"
new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
aWgt = aShapeSelectorWgt;
- } if (theType == "sketch_constraint_shape_selector") {
- PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
- new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
- aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
- aWgt = aConstraintShapeSelectorWgt;
} if (theType == WDG_DOUBLEVALUE_EDITOR) {
aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PartSet_WidgetShapeSelector.cpp
-// Created: 27 Nov 2014
-// Author: Vitaly Smetannikov
-
-#include "PartSet_WidgetConstraintShapeSelector.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Validator.h>
-
-#include <PartSet_Tools.h>
-#include <SketchPlugin_Feature.h>
-
-bool PartSet_WidgetConstraintShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
-{
- // initially the method is wrote to create an external object. Since the parent widget creates it,
- // the redefinition is not necessary anymore.
- // TODO: remove the widget and use the parent one insted of it
- return PartSet_WidgetShapeSelector::setObject(theSelectedObject, theShape);
- /*ObjectPtr aSelectedObject = theSelectedObject;
-
- FeaturePtr aFeature = ModelAPI_Feature::feature(aSelectedObject);
- if (aFeature) {
- std::shared_ptr<SketchPlugin_Feature> aSPFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if ((!aSPFeature) && (!theShape->isNull())) {
- createExternal(theSelectedObject, theShape);
-
- if (myExternalObject) {
- aSelectedObject = myExternalObject;
- } else
- return false;
- }
- }
- return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, theShape);*/
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PartSet_WidgetShapeSelector.h
-// Created: 27 Nov 2014
-// Author: Vitaly Smetannikov
-
-
-#ifndef PartSet_WidgetConstraintShapeSelector_H
-#define PartSet_WidgetConstraintShapeSelector_H
-
-#include "PartSet.h"
-
-#include <PartSet_WidgetShapeSelector.h>
-
-#include <ModelAPI_CompositeFeature.h>
-
-
-/**
-* \ingroup Modules
-* Customosation of PartSet_WidgetShapeSelector in order to provide
-* working with constraints.
-*/
-class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public PartSet_WidgetShapeSelector
-{
-Q_OBJECT
- public:
- /// Constructor
- /// \param theParent the parent object
- /// \param theWorkshop instance of workshop interface
- /// \param theData the widget configuation. The attribute of the model widget is obtained from
- /// \param theParentId is Id of a parent of the current attribute
- PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData, const std::string& theParentId)
- : PartSet_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
-
- virtual ~PartSet_WidgetConstraintShapeSelector() {}
-
- /// Set sketcher
- /// \param theSketch a sketcher object
- //void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
-
- /// Retrurns installed sketcher
- //CompositeFeaturePtr sketch() const { return mySketch; }
-
-protected:
- /// Store the values to the model attribute of the widget. It casts this attribute to
- /// the specific type and set the given values
- /// \param theSelectedObject an object
- /// \param theShape a selected shape, which is used in the selection attribute
- virtual bool setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
-
-//private:
- /// Pointer to a sketch
- //CompositeFeaturePtr mySketch;
-};
-
-#endif
\ No newline at end of file
#include <ModelAPI_Validator.h>
#include <ModuleBase_Definitions.h>
+#include <Config_WidgetAPI.h>
#include <PartSet_Tools.h>
#include <SketchPlugin_Feature.h>
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const std::string& theParentId)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId), myUseExternal(true)
{
+ QString aIsExternal(theData->getProperty("use_external").c_str());
+ if (!aIsExternal.isEmpty()) {
+ QString aStr = aIsExternal.toUpper();
+ myUseExternal = (aStr == "TRUE") || (aStr == "YES");
+ }
}
bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aSelectedObject);
if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
return false;
+ // Do check using of external feature
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
- if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull()) {
+
+ // Do check that we can use external feature
+ if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myUseExternal))
+ return false;
+
+ if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myUseExternal) {
aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
theSelectedObject, mySketch);
if (!aSelectedObject.get()) {
/// An external object
ObjectPtr myExternalObject;
+
+ bool myUseExternal;
};
#endif
\ No newline at end of file
<!-- SketchConstraintParallel -->
<feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select a line" shape_types="edge">
<validator id="GeomValidators_Edge" parameters="line"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
- <sketch_constraint_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line"
+ <sketch_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line"
shape_types="edge">
<validator id="GeomValidators_Edge" parameters="line"/>
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<validator id="PartSet_ParallelSelection"/>
</feature>
<feature id="SketchConstraintPerpendicular" title="Perpendicular"
tooltip="Create constraint defining two perpendicular lines"
icon=":icons/perpendicular.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select an line"
shape_types="edge">
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
<validator id="GeomValidators_Edge" parameters="line"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
- <sketch_constraint_shape_selector id="ConstraintEntityB"
+ <sketch_shape_selector id="ConstraintEntityB"
label="Second line" tooltip="Select an line"
shape_types="edge">
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="GeomValidators_Edge" parameters="line"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<validator id="PartSet_PerpendicularSelection"/>
</feature>
<!-- SketchConstraintHorizontal -->
<feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line" icon=":icons/horisontal.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
- label="Line" tooltip="Select a line" shape_types="edge">
+ <sketch_shape_selector id="ConstraintEntityA"
+ label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
<validator id="GeomValidators_Edge" parameters="line"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<validator id="PartSet_HVDirSelection"/>
</feature>
<!-- SketchConstraintVertical -->
<feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line" icon=":icons/vertical.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
- label="Line" tooltip="Select a line" shape_types="edge">
+ <sketch_shape_selector id="ConstraintEntityA"
+ label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
<validator id="GeomValidators_Edge" parameters="line"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<validator id="PartSet_HVDirSelection"/>
</feature>
<feature id="SketchConstraintEqual" title="Equal"
tooltip="Create constraint defining equal lengths of two lines or line and arc or equal radii of two arcs or two circles or arc and circle"
icon=":icons/equal.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line, circle or arc" shape_types="edge">
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
- <sketch_constraint_shape_selector id="ConstraintEntityB"
+ <sketch_shape_selector id="ConstraintEntityB"
label="Second object" tooltip="Select line, circle or arc" shape_types="edge">
<validator id="SketchPlugin_EqualAttr" parameters="ConstraintEntityA"/>
<validator id="PartSet_DifferentObjects"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
</feature>
<!-- SketchConstraintTangent -->
<feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects" icon=":icons/tangent.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line or arc" shape_types="edge">
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
- <sketch_constraint_shape_selector id="ConstraintEntityB"
+ <sketch_shape_selector id="ConstraintEntityB"
label="Second object" tooltip="Select line or arc" shape_types="edge">
<validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
<validator id="PartSet_DifferentObjects"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<validator id="PartSet_TangentSelection"/>
</feature>
<group id="Edit">
<!-- SketchConstraintFillet -->
<feature id="SketchConstraintFillet" title="Fillet" tooltip="Create constraint defining fillet between two objects" icon=":icons/fillet.png">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="First object" tooltip="Select line or arc" shape_types="edge">
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
- <sketch_constraint_shape_selector id="ConstraintEntityB"
+ <sketch_shape_selector id="ConstraintEntityB"
label="Second object" tooltip="Select line or arc" shape_types="edge">
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
<validator id="GeomValidators_Positive"/>
id="SketchConstraintMirror"
title="Mirror" icon=":icons/mirror.png"
tooltip="Create constraint, mirroring group of objects">
- <sketch_constraint_shape_selector id="ConstraintEntityA"
+ <sketch_shape_selector id="ConstraintEntityA"
label="Mirror line" tooltip="Select mirror line" shape_types="edge">
<validator id="GeomValidators_Edge" parameters="line"/>
- </sketch_constraint_shape_selector>
+ </sketch_shape_selector>
<multi_selector id="ConstraintMirrorList"
label="List of objects"
tooltip="Select list of mirroring objects"