aContext->SetColor(anAIS, aColor, false);
}
+double GeomAPI_AISObject::width()
+{
+ double aWidth = 0.0;
+ Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ aWidth = anAIS->Width();
+ }
+ return aWidth;
+}
+
bool GeomAPI_AISObject::setWidth(const double& theWidth)
{
bool isChanged = false;
GEOMAPI_EXPORT
void getColor(int& theR, int& theG, int& theB);
+ /// \return Current width of the lines of shape
+ GEOMAPI_EXPORT
+ double width();
+
/// \brief Assigns the width of the lines of shape
GEOMAPI_EXPORT
bool setWidth(const double& theWidth);
if (aMirrorIter != aMirroredList.end())
break; // the lists are inconsistent
// There is no mirrored object yet, create it
- FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeatureIn, sketch());
+ FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeatureIn, sketch(), true);
aNewFeature->execute();
ModelAPI_EventCreator::get()->sendUpdated(aNewFeature, aRedisplayEvent);
if (!aFeature || !aResult)
return ObjectPtr();
- FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch());
+ FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true);
aNewFeature->execute();
static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
if (!aFeature || !aResult)
return ObjectPtr();
- FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch());
+ FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true);
aNewFeature->execute();
static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
}
FeaturePtr SketchPlugin_Sketch::addUniqueNamedCopiedFeature(FeaturePtr theFeature,
- SketchPlugin_Sketch* theSketch)
+ SketchPlugin_Sketch* theSketch,
+ const bool theIsCopy)
{
FeaturePtr aNewFeature = theSketch->addFeature(theFeature->getKind());
// addFeature generates a unique name for the feature, it caches the name
aNewFeature->data()->setName(aUniqueFeatureName);
// text expressions could block setValue of some attributes
SketchPlugin_Tools::clearExpressions(aNewFeature);
+ // Set copy attribute
+ aNewFeature->data()->boolean(SketchPlugin_SketchEntity::COPY_ID())->setValue(theIsCopy);
return aNewFeature;
}
/// The name of the created feature stays unique.
/// \param theFeature a source feature
/// \param theSketch a sketch intance
+ /// \param theIsCopy if true sets feature copy attribute to true.
/// \return a created feature
static FeaturePtr addUniqueNamedCopiedFeature(FeaturePtr theFeature,
- SketchPlugin_Sketch* theSketch);
+ SketchPlugin_Sketch* theSketch,
+ const bool theIsCopy = false);
/// Creates a plane of the sketch.
/// \param theSketch a sketch intance
void SketchPlugin_SketchEntity::initAttributes()
{
data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId());
+ data()->addAttribute(COPY_ID(), ModelAPI_AttributeBoolean::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), AUXILIARY_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COPY_ID());
}
return MY_EXTERNAL_ID;
}
+ /// Reference to the copy type of the feature
+ inline static const std::string& COPY_ID()
+ {
+ static const std::string MY_COPY_ID("Copy");
+ return MY_COPY_ID;
+ }
+
/// Request for initialization of data model of the feature: adding all attributes
virtual void initAttributes();
return false;
}
+ /// Returns true of the feature is a copy of other feature
+ virtual bool isCopy() const
+ {
+ AttributeBooleanPtr anAttr = data()->boolean(COPY_ID());
+ if(anAttr.get()) {
+ return anAttr->value();
+ }
+ return false;
+ }
+
/// Customize presentation of the feature
virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
thePrs->setWidth(17);
// thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
}
+ if(isCopy()) {
+ double aWidth = thePrs->width();
+ thePrs->setWidth(aWidth / 2.5);
+ }
return isCustomized;
}