FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}")
SET(TKVInspector ${TKVInspector})
+ FIND_LIBRARY(DFBrowserAPI DFBrowserAPI "${TINSPECTOR_LIB_DIR}")
+ SET(DFBrowserAPI ${DFBrowserAPI})
+
+ FIND_LIBRARY(TKDFTreeModel TKDFTreeModel "${TINSPECTOR_LIB_DIR}")
+ SET(TKDFTreeModel ${TKDFTreeModel})
+
ENDIF(TKTInspector)
ENDIF(EXISTS ${TINSPECTOR_ROOT_DIR})
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
#include <GeomAPI_Ax1.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Copy.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <FeaturesPlugin_Tools.h>
#include <GeomAPI_Face.h>
#include <GeomAPI_Lin.h>
#include <GeomAPI_Pln.h>
+#include <GeomAPI_Trsf.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <GeomAlgoAPI_PointBuilder.h>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
+#include <gp_GTrsf.hxx>
#include <gp_Trsf.hxx>
#define MY_TRSF implPtr<gp_Trsf>()
#include <ModelAPI_AttributeSelection.h>
#include "ModelAPI_Object.h"
+#include <GeomAPI_Shape.h>
+
bool GeomValidators_DifferentShapes::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
#include "GeomValidators_IntersectionSelection.h"
+#include <GeomAPI_Shape.h>
+
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
#include <Model_ResultConstruction.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
#include "Model_Events.h"
#include "Model_Data.h"
+#include <GeomAPI_Shape.h>
+
#include <TDF_AttributeIterator.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
if (myWasChangedButBlocked.empty() || *(myWasChangedButBlocked.rbegin()) != theAttr)
myWasChangedButBlocked.push_back(theAttr);
}
+ } else {
+ // trim: need to redisplay
+ if (myObject) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+ }
}
}
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
#include <Model_ResultBody.h>
#include <Model_BodyBuilder.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <Config_PropManager.h>
#include <ModelAPI_Events.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <GeomAPI_Trsf.h>
+
#include <TNaming_Tool.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
#include <Config_ValidatorMessage.h>
#include <Config_ModuleReader.h>
#include <Config_ValidatorReader.h>
+
+#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Tools.h>
#include "ModelAPI_AttributeSelection.h"
#include <ModelAPI_Result.h>
+class GeomAPI_Shape;
+
/**\class ModelAPI_AttributeSelectionList
* \ingroup DataModel
* \brief Attribute that contains list of references to the sub-shapes with
/// \param theTemporarily if it is true, do not store and name the added in the data framework
/// (used to remove immediately, without the following updates)
virtual void append(const ResultPtr& theContext,
- const GeomShapePtr& theSubShape,
+ const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily = false) = 0;
/// Adds the new reference to the end of the list by the naming name of the selected shape
#define ModelAPI_Result_H_
#include "ModelAPI_Object.h"
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
class ModelAPI_Feature;
#define ModelAPI_ResultPart_H_
#include "ModelAPI_Result.h"
-#include <GeomAPI_Trsf.h>
+class GeomAPI_Trsf;
#include <string>
#include "ModelAPI_Tools.h"
#include <ModelAPI_Session.h>
+#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_AttributeDocRef.h>
return theResult->shape();
}
-void shapesOfType(const FeaturePtr& theFeature,
- const GeomAPI_Shape::ShapeType& theType,
- std::set<ResultPtr>& theShapeResults)
-{
- theShapeResults.clear();
- std::list<ResultPtr> aResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
- for (; aRIter != aResults.cend(); aRIter++) {
- ResultPtr aResult = *aRIter;
- GeomShapePtr aShape = aResult->shape();
- if (aShape.get() && aShape->shapeType() == theType)
- theShapeResults.insert(aResult);
- }
-}
-
const char* toString(ModelAPI_ExecState theExecState)
{
#define TO_STRING(__NAME__) case __NAME__: return #__NAME__;
#include "ModelAPI.h"
-#include <ModelAPI_CompositeFeature.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Result.h>
-#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultCompSolid.h>
+class ModelAPI_CompositeFeature;
+class ModelAPI_Document;
+class ModelAPI_Feature;
+class ModelAPI_Result;
+class ModelAPI_ResultParameter;
+class ModelAPI_ResultCompSolid;
-#include <GeomAPI_Shape.h>
+class GeomAPI_Shape;
#include <vector>
#include <map>
#include <set>
+#include <list>
namespace ModelAPI_Tools {
/// Returns shape from the given Result object
-MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
-
-/// Creates a container of shape of the feature results satisfied the given shape type
-/// \param theFeature a source feature
-/// \param theType shape type
-/// \param an output container for result of shapes
-MODELAPI_EXPORT void shapesOfType(const FeaturePtr& theFeature,
- const GeomAPI_Shape::ShapeType& theType,
- std::set<ResultPtr>& theShapeResults);
+MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
+ const std::shared_ptr<ModelAPI_Result>& theResult);
/*! Returns the feature error generated according to feature error and exec state
* \param theFeature a feature
* \return error value or empty string
*/
-MODELAPI_EXPORT std::string getFeatureError(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& theFeature);
/*!
* Searches for variable with name \param theName in \param theDocument.
* If found, set it value in the \param outValue and returns true.
* theSearcher must be located later in the history than the found variable.
*/
-MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
- const std::string& theName, double& outValue, ResultParameterPtr& theParam);
+MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theDocument,
+ std::shared_ptr<ModelAPI_Feature> theSearcher,
+ const std::string& theName, double& outValue,
+ std::shared_ptr<ModelAPI_ResultParameter>& theParam);
/*!
* Searches for variable with name \param theName in the active document (Part), when
* and returns true. If \param theDocument is empty active document is used.
* theSearcher must be located later in the history than the found variable.
*/
-MODELAPI_EXPORT bool findVariable(FeaturePtr theSearcher, const std::string& theName,
- double& outValue, ResultParameterPtr& theParam,
- const DocumentPtr& theDocument = DocumentPtr());
+MODELAPI_EXPORT bool findVariable(std::shared_ptr<ModelAPI_Feature> theSearcher,
+ const std::string& theName,
+ double& outValue, std::shared_ptr<ModelAPI_ResultParameter>& theParam,
+ const std::shared_ptr<ModelAPI_Document>& theDocument = std::shared_ptr<ModelAPI_Document>());
/*!
* Searches for Part result that contains the reference to the given document.
* \param theSub document that is searched, the resulting feature references to it
* \returns null if not found
*/
-MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result> findPartResult(
+ const std::shared_ptr<ModelAPI_Document>& theMain,
+ const std::shared_ptr<ModelAPI_Document>& theSub);
/*!
* Searches for Part the feature that contains in result the reference to the given document.
* \param theSub document that is searched, the resulting feature references to it
* \returns null if not found
*/
-MODELAPI_EXPORT FeaturePtr findPartFeature(const DocumentPtr& theMain, const DocumentPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> findPartFeature(
+ const std::shared_ptr<ModelAPI_Document>& theMain,
+ const std::shared_ptr<ModelAPI_Document>& theSub);
/*!
* Returns the composite feature - parent of this feature.
* \param theFeature the sub-element of composite
* \returns null if it is not sub-element of composite
*/
-MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_CompositeFeature> compositeOwner(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature);
/*!
* Returns the compsolid result - parent of this result.
* \param theSub the sub-element of comp-solid
* \returns null if it is not sub-element of composite
*/
-MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultCompSolid> compSolidOwner(
+ const std::shared_ptr<ModelAPI_Result>& theSub);
/*!
-* Returns true if the result contains a not empty list of sub results. It processes result compsolid.
+* Returns true if the result contains a not empty list of sub results.
+* It processes result compsolid.
* \param theResult a result object
* \returns boolean value
*/
-MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);
+MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
/*!
* Adds the results of the given feature to theResults list: including disabled and sub-results
*/
-MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults);
+MODELAPI_EXPORT void allResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
/*!
Returns true if there are no parts in the document, which are not activated
*/
MODELAPI_EXPORT bool allDocumentsActivated(std::string& theNotActivatedNames);
-
/*! Removes features from the document
* \param theFeatures a list of features to be removed
* \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
* \return true if at least one feature is removed
*/
-MODELAPI_EXPORT bool removeFeaturesAndReferences(const std::set<FeaturePtr>& theFeatures,
+MODELAPI_EXPORT bool removeFeaturesAndReferences(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
const bool theFlushRedisplay = false,
const bool theUseComposite = false,
const bool theUseRecursion = true);
* \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
* \return true if at least one feature is removed
*/
-MODELAPI_EXPORT bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
- const bool theFlushRedisplay);
+MODELAPI_EXPORT bool removeFeatures(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+ const bool theFlushRedisplay);
/*! Build a map of references for the given set of features
* \param theFeatures a list of features
list are put into the result container. E.g. if theFeatures contains "Sketch_2", map will
contain references to this feature also.
*/
-MODELAPI_EXPORT void findAllReferences(const std::set<FeaturePtr>& theFeatures,
- std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
- const bool theUseComposite = true,
- const bool theUseRecursion = true);
+MODELAPI_EXPORT void findAllReferences(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
+ std::map<std::shared_ptr<ModelAPI_Feature>,
+ std::set<std::shared_ptr<ModelAPI_Feature> > >& theReferences,
+ const bool theUseComposite = true,
+ const bool theUseRecursion = true);
/*! In the map of references find all features referenced to the source feature
* \param theFeatures a list of features to find references
* \param theReferences a map of all references to the features
* \param theFeaturesRefsTo an out list of referenced features
*/
-MODELAPI_EXPORT void findRefsToFeatures(const std::set<FeaturePtr>& aFeatures,
- const std::map<FeaturePtr, std::set<FeaturePtr> >& aReferences,
- std::set<FeaturePtr>& aFeaturesRefsTo);
+MODELAPI_EXPORT void findRefsToFeatures(
+ const std::set<std::shared_ptr<ModelAPI_Feature> >& aFeatures,
+ const std::map<std::shared_ptr<ModelAPI_Feature>,
+ std::set<std::shared_ptr<ModelAPI_Feature> > >& aReferences,
+ std::set<std::shared_ptr<ModelAPI_Feature> >& aFeaturesRefsTo);
/*! Finds referenced of the feature to objects and collects concealed results.
* \param theFeatures a model feature
* \param theResults container for concealed results. It has no duplications
*/
-MODELAPI_EXPORT void getConcealedResults(const FeaturePtr& theFeature,
- std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
}
#endif
SET(PROJECT_HEADERS
ModelGeomAlgo.h
ModelGeomAlgo_Point2D.h
+ ModelGeomAlgo_Shape.h
)
SET(PROJECT_SOURCES
ModelGeomAlgo_Point2D.cpp
+ ModelGeomAlgo_Shape.cpp
)
SET(PROJECT_LIBRARIES
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Tools.h>
+#include <ModelGeomAlgo_Shape.h>
+
#include <GeomAPI_ShapeIterator.h>
#include <GeomAlgoAPI_ShapeTools.h>
GeomShapePtr aFeatureShape;
{
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(theBaseFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty())
return;
aFeatureShape = (*anEdgeShapes.begin())->shape();
continue;
if (aFeature.get()) {
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty())
continue;
ResultPtr aResult = *anEdgeShapes.begin();
if (thePointToAttributeOrObject.find(aProjectedPoint) != thePointToAttributeOrObject.end())
thePointToAttributeOrObject.at(aProjectedPoint).first.push_back(anAttribute);
else {
- //std::list< std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
- //anAttributes.push_back(anAttribute);
- //thePointToAttributeOrObject.insert(aProjectedPoint, anAttributes);
-
std::list<std::shared_ptr<GeomDataAPI_Point2D> > anAttributes;
std::list<std::shared_ptr<ModelAPI_Object> > anObjects;
anAttributes.push_back(anAttribute);
thePointToAttributeOrObject[aProjectedPoint] = std::make_pair(anAttributes, anObjects);
}
- //thePoints.push_back(aProjectedPoint);
- //theAttributeToPoint[anAttribute] = aProjectedPoint;
}
}
}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_Tools.cpp
+// Created: 19 Mar 2017
+// Author: Natalia ERMOLAEVA
+
+#include <GeomAPI_Shape.h>
+
+#include "ModelGeomAlgo_Shape.h"
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
+
+
+#ifdef WIN32
+#pragma warning(disable : 4996) // for sprintf
+#endif
+
+namespace ModelGeomAlgo_Shape
+{
+ void shapesOfType(const FeaturePtr& theFeature,
+ const GeomAPI_Shape::ShapeType& theType,
+ std::set<ResultPtr>& theShapeResults)
+ {
+ theShapeResults.clear();
+ std::list<ResultPtr> aResults = theFeature->results();
+ std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
+ for (; aRIter != aResults.cend(); aRIter++) {
+ ResultPtr aResult = *aRIter;
+ GeomShapePtr aShape = aResult->shape();
+ if (aShape.get() && aShape->shapeType() == theType)
+ theShapeResults.insert(aResult);
+ }
+ }
+} // namespace ModelGeomAlgo_Shape
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelGeomAlgo_Point2D.h
+// Created: 20 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef ModelGeomAlgo_Shape_H
+#define ModelGeomAlgo_Shape_H
+
+#include "ModelGeomAlgo.h"
+#include "GeomAPI_Shape.h"
+
+#include <set>
+
+class ModelAPI_Feature;
+class ModelAPI_Result;
+
+namespace ModelGeomAlgo_Shape {
+
+ /// Searches Shape results of the feature satisfied the given shape type
+ /// \param theFeature a feature to obtain AttributeRefAttr
+ /// \param theType shape type
+ /// \param theShapeResults a list of results
+ MODELGEOMALGO_EXPORT void shapesOfType(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const GeomAPI_Shape::ShapeType& theType,
+ std::set<std::shared_ptr<ModelAPI_Result> >& theShapeResults);
+}
+
+#endif
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <GeomAPI_PlanarEdges.h>
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <GeomAPI_PlanarEdges.h>
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
PartSet_WidgetFeaturePointSelector::PartSet_WidgetFeaturePointSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData), myBaseSelected(false)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData)
{
}
bool PartSet_WidgetFeaturePointSelector::isValidSelection(
const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
{
- return true;
+ return ModuleBase_WidgetShapeSelector::isValidSelection(theValue);
+ //return true;
}
//********************************************************************
Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle();
if (toActivate) {
std::vector<int> aColors;
- aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
+ aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255.,
Quantity_TOC_RGB);
myHighlightColor = aHStyle->Color();
mySelectionColor = aSStyle->Color();
-
- aHStyle->SetTransparency(0.5f);
}
else {
aColor = myHighlightColor;
{
ModuleBase_WidgetShapeSelector::activateCustom();
- myBaseSelected = false;
-
myWorkshop->module()->activateCustomPrs(myFeature,
ModuleBase_IModule::CustomizeHighlightedObjects, true);
}
if (theEvent->button() != Qt::LeftButton)
return;
- myBaseSelected = true;
+ // set parameters of preview into parameters of selection in the feature
+ std::shared_ptr<ModelAPI_AttributeReference> aRefSelectedAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ feature()->data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
+ std::shared_ptr<ModelAPI_AttributeReference> aRefPreviewAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+ aRefSelectedAttr->setValue(aRefPreviewAttr->value());
+
+ std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(SketchPlugin_Trim::SELECTED_POINT()));
+ std::shared_ptr<GeomDataAPI_Point2D> aPointPreviewAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+ aPointSelectedAttr->setValue(aPointPreviewAttr->x(), aPointPreviewAttr->y());
+
+ updateObject(feature());
+
emit focusOutWidget(this);
// we need to deselect base feature for better visibility of selected feature
XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false);
std::shared_ptr<ModelAPI_AttributeReference> aRef =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- feature()->data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
aRef->setValue(anObject);
std::shared_ptr<GeomDataAPI_Point2D> anAttributePoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- feature()->data()->attribute(SketchPlugin_Trim::ENTITY_POINT()));
+ feature()->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
anAttributePoint->setValue(aX, anY);
// redisplay AIS presentation in viewer
#ifndef HIGHLIGHT_STAYS_PROBLEM
XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true);
#endif
updateObject(feature());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
aFilled = true;
return aFilled;
return QList<ModuleBase_ViewerPrsPtr>();
}
-//********************************************************************
-void PartSet_WidgetFeaturePointSelector::updateSelectionName()
-{
- if (myBaseSelected)
- ModuleBase_WidgetShapeSelector::updateSelectionName();
-}
-
//********************************************************************
bool PartSet_WidgetFeaturePointSelector::setSelection(
QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
virtual ~PartSet_WidgetFeaturePointSelector();
- /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
- /// next, the attribute's validating. It trying on the give selection to current attribute by
- /// setting the value inside and calling validators. After this, the previous attribute value is
- /// restored.The valid/invalid value is cashed.
+ /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
+ /// validating, next, the attribute's validating. It trying on the give selection to current
+ /// attribute by setting the value inside and calling validators. After this, the previous
+ /// attribute value is restored.The valid/invalid value is cashed.
/// \param theValue a selected presentation in the view
/// \return a boolean value
virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
/// \param theEvent a mouse event
virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
- /// Returns values which should be highlighted when the whidget is active
- /// \param theValues a list of presentations
- //virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
-
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// The method is called by the current operation to process the operation preselection.
const bool theToValidate);
/// Fill preselection used in mouseReleased
- //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
ModuleBase_IViewWindow* theWnd,
QMouseEvent* theEvent);
/// a shape. If the attribute do not uses the shape, it is empty
virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
- /// Computes and updates name of selected object in the widget
- virtual void updateSelectionName();
-
protected:
/// The methiod called when widget is activated
virtual void activateCustom();
CompositeFeaturePtr mySketch;
Quantity_Color myHighlightColor;
Quantity_Color mySelectionColor;
- bool myBaseSelected;
};
#endif
\ No newline at end of file
#include <GeomAlgoAPI_ShapeTools.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
#include <ModelGeomAlgo_Point2D.h>
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
// edges on feature
std::set<ResultPtr> anEdgeResults;
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeResults);
if (!anEdgeResults.empty()) {
GeomShapePtr aFeatureShape = (*anEdgeResults.begin())->shape();
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_Trim::ID());
- fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::BASE_OBJECT()));
+ fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::SELECTED_OBJECT()));
- AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::ENTITY_POINT());
+ AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::SELECTED_POINT());
if (anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
fillAttribute(thePositionPoint, aPointAttr);
new SketchPlugin_FilletVertexValidator);
aFactory->registerValidator("SketchPlugin_SplitValidator",
new SketchPlugin_SplitValidator);
+ aFactory->registerValidator("SketchPlugin_TrimValidator",
+ new SketchPlugin_TrimValidator);
aFactory->registerValidator("SketchPlugin_MiddlePointAttr",
new SketchPlugin_MiddlePointAttrValidator);
aFactory->registerValidator("SketchPlugin_ArcTangentPoint",
#include <GeomAPI_XY.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelGeomAlgo_Shape.h>
+
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_ConstraintMiddle.h>
#include <SketchPlugin_Circle.h>
void SketchPlugin_Trim::initAttributes()
{
- data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
- data()->addAttribute(ENTITY_POINT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(SketchPlugin_Trim::SELECTED_OBJECT(),
+ ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(SELECTED_POINT(), GeomDataAPI_Point2D::typeId());
+
+ data()->addAttribute(PREVIEW_POINT(), GeomDataAPI_Point2D::typeId());
+ data()->addAttribute(PREVIEW_OBJECT(), ModelAPI_AttributeReference::typeId());
+
+ data()->attribute(PREVIEW_POINT())->setIsArgument(false);
+ data()->attribute(SELECTED_POINT())->setIsArgument(false);
+ data()->attribute(PREVIEW_OBJECT())->setIsArgument(false);
+
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_POINT());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PREVIEW_OBJECT());
}
-void SketchPlugin_Trim::findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+void SketchPlugin_Trim::findShapePoints(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId,
+ std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
std::shared_ptr<GeomAPI_Pnt>& aLastPoint)
{
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(theObjectAttributeId));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
+ data()->attribute(thePointAttributeId));
std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
anAttributePnt2d->y());
if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
if (!aShapes.empty()) {
std::shared_ptr<GeomAPI_Pnt2d> aPoint;
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
- return aPoint;
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
bool aFound = false;
const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
}
}
if (!aFound) {
- // returns an end of the shape to define direction of split if feature's attribute participates
+ // returns an end of the shape to define direction of split if feature's attribute
+ // participates
std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
aPoint = thePoint->to2D(aPlane);
}
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
if(!aBaseObjectAttr->isInitialized()) {
setError("Error: Base object is not initialized.");
return;
/// points of trim
std::shared_ptr<GeomAPI_Pnt> aStartShapePoint, aLastShapePoint;
- findShapePoints(aStartShapePoint, aLastShapePoint);
+ findShapePoints(SELECTED_OBJECT(), SELECTED_POINT(), aStartShapePoint, aLastShapePoint);
std::shared_ptr<GeomAPI_Pnt2d> aStartShapePoint2d = convertPoint(aStartShapePoint);
std::shared_ptr<GeomAPI_Pnt2d> aLastShapePoint2d = convertPoint(aLastShapePoint);
aFurtherCoincidences, aModifiedAttributes);
aFeaturesToDelete.insert(aBaseFeature);
- // as circle is removed, temporary fill this attribute
+ // as circle is removed, erase it from dependencies(arguments) of this feature
+ // otherwise Trim feature will be removed with the circle before
+ // this operation is finished
aBaseObjectAttr->setObject(ResultPtr());
+
+ AttributeReferencePtr aPreviewObjectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(SketchPlugin_Trim::PREVIEW_OBJECT()));
+ aPreviewObjectAttr->setObject(ResultPtr());
+
}
else if (aKind == SketchPlugin_Line::ID()) {
trimLine(aStartShapePoint2d, aLastShapePoint2d,
}
//
+ if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
+
const PointToRefsMap& aRefsMap = myObjectToPoints.at(aBaseObject);
std::set<AttributePoint2DPtr>::const_iterator anIt = aFurtherCoincidences.begin(),
aLast = aFurtherCoincidences.end();
AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
{
AISObjectPtr anAIS = thePrevious;
- // feature for trim
- AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
- ObjectPtr aBaseObject = aBaseObjectAttr->value();
- if (!aBaseObject.get())
+
+ std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
+ GeomShapePtr aPreviewShape = getSubShape(PREVIEW_OBJECT(), PREVIEW_POINT());
+ if (aPreviewShape.get())
+ aShapes.push_back(aPreviewShape);
+ GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
+ if (aSelectedShape.get())
+ aShapes.push_back(aSelectedShape);
+
+ if (aShapes.empty())
return AISObjectPtr();
- FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
+
+ GeomShapePtr aBaseShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ if (!aBaseShape.get())
+ return AISObjectPtr();
+
+ if (aBaseShape.get()) {
+ if (!anAIS)
+ anAIS = AISObjectPtr(new GeomAPI_AISObject);
+ anAIS->createShape(aBaseShape);
+
+ std::vector<int> aColor;
+ aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
+ double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
+ int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
+ anAIS->setColor(aColor[0], aColor[1], aColor[2]);
+ // width when there is not base object should be extened in several points
+ // in order to see this preview over highlight
+ anAIS->setWidth(aWidth+4);
+ anAIS->setLineStyle(aLineStyle);
+ }
+ else
+ anAIS = AISObjectPtr();
+
+ return anAIS;
+}
+
+GeomShapePtr SketchPlugin_Trim::getSubShape(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId)
+{
+ GeomShapePtr aBaseShape;
+
+ AttributeReferencePtr anObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
+ data()->attribute(theObjectAttributeId));
+ ObjectPtr aBaseObject = anObjectAttr->value();
+ if (!aBaseObject.get())
+ return aBaseShape;
// point on feature
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
+ data()->attribute(thePointAttributeId));
std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
anAttributePnt2d->y());
if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
-
- GeomShapePtr aBaseShape;
+ fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
if (!aShapes.empty()) {
aBaseShape = aShape;
}
}
-
- if (aBaseShape.get()) {
- if (!anAIS)
- anAIS = AISObjectPtr(new GeomAPI_AISObject);
- anAIS->createShape(aBaseShape);
-
- std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
- aBaseFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
-
- bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
- std::vector<int> aColor;
- aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color");
- double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
- int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
- if (isConstruction) {
- aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY();
- aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
- }
- anAIS->setColor(aColor[0], aColor[1], aColor[2]);
- // width is extened in several points in order to see this preview over highlight
- anAIS->setWidth(aWidth + 2);
- anAIS->setLineStyle(aLineStyle);
- }
- else
- anAIS = AISObjectPtr();
-
- return anAIS;
+ return aBaseShape;
}
void SketchPlugin_Trim::getFeaturePoints(const FeaturePtr& theFeature,
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- aData->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ aData->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature);
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
(aBaseFeature->attribute(aModifiedAttribute)));
}
else {
- // result is two lines: start line point - start shape point, last shape point - last line point
+ // result is two lines: start line point - start shape point,
+ // last shape point - last line point
// create second line
FeaturePtr anNewFeature = createLineFeature(aBaseFeature, aLastShapePoint, aLastFeaturePoint);
thePoints.insert(std::dynamic_pointer_cast<GeomDataAPI_Point2D>
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
{
// Check the base objects are initialized.
AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
+ data()->attribute(SketchPlugin_Trim::SELECTED_OBJECT()));
ObjectPtr aBaseObject = aBaseObjectAttr->value();
FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
}
//********************************************************************
-bool SketchPlugin_Trim::useGraphicIntersection() const
-{
- return true;
-}
-
-//********************************************************************
-void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject)
+void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject,
+ ObjectPtr& theSketch,
+ std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
+ std::map<ObjectPtr, PointToRefsMap>& theObjectToPoints)
{
PointToRefsMap aPointsInfo;
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
std::set<ResultPtr> anEdgeShapes;
// edges on feature
- ModelAPI_Tools::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(aFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (!anEdgeShapes.empty()) {
GeomShapePtr aFeatureShape = (*anEdgeShapes.begin())->shape();
ModelGeomAlgo_Point2D::getPointsOfReference(aFeature, SketchPlugin_ConstraintCoincidence::ID(),
aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
// layed on feature coincidences to divide it on several shapes
- SketchPlugin_Sketch* aSketch = sketch();
- std::shared_ptr<ModelAPI_Data> aData = aSketch->data();
+ //SketchPlugin_Sketch* aSketch = sketch();
+ std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
ModelGeomAlgo_Point2D::getPointsInsideShape(aFeatureShape, aRefAttributes, aC->pnt(),
aX->dir(), aY, aPointsInfo);
- // intersection points
- if (useGraphicIntersection()) {
- std::list<FeaturePtr> aFeatures;
- for (int i = 0; i < aSketch->numberOfSubs(); i++) {
- FeaturePtr aFeature = aSketch->subFeature(i);
- if (aFeature.get())
- aFeatures.push_back(aFeature);
- }
- ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
+ std::list<FeaturePtr> aFeatures;
+ CompositeFeaturePtr aSketchComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theSketch);
+ for (int i = 0; i < aSketchComposite->numberOfSubs(); i++) {
+ FeaturePtr aFeature = aSketchComposite->subFeature(i);
+ if (aFeature.get())
+ aFeatures.push_back(aFeature);
}
- GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
- }
- myObjectToPoints[theObject] = aPointsInfo;
- myCashedShapes[theObject] = aShapes;
-}
+ ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo);
-//********************************************************************
-void SketchPlugin_Trim::attributeChanged(const std::string& theID)
-{
- //data()->addAttribute(SketchPlugin_Trim::BASE_OBJECT(), ModelAPI_AttributeReference::typeId());
- if (theID == SketchPlugin_Trim::BASE_OBJECT()) {
- bool isValidAttribute = false;
- // feature for trim
- AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
- data()->attribute(SketchPlugin_Trim::BASE_OBJECT()));
- ObjectPtr aBaseObject = aBaseObjectAttr->value();
- if (aBaseObject.get()) {
- FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
- // point on feature
- AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(ENTITY_POINT()));
- std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
- std::shared_ptr<GeomAPI_Pnt> anAttributePnt = sketch()->to3D(anAttributePnt2d->x(),
- anAttributePnt2d->y());
-
- if (myCashedShapes.find(aBaseObject) == myCashedShapes.end())
- fillObjectShapes(aBaseObject);
-
- const std::set<GeomShapePtr>& aShapes = myCashedShapes[aBaseObject];
- isValidAttribute = !aShapes.empty();
-
- if (!isValidAttribute) {
- bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- aBaseObjectAttr->setValue(ObjectPtr());
- data()->blockSendAttributeUpdated(aWasBlocked);
- }
- }
+ GeomAlgoAPI_ShapeTools::splitShape(aFeatureShape, aPointsInfo, aShapes);
}
+ theObjectToPoints[theObject] = aPointsInfo;
+ theCashedShapes[theObject] = aShapes;
}
}
/// The value parameter for the constraint
- inline static const std::string& BASE_OBJECT()
+ inline static const std::string& SELECTED_OBJECT()
{
- static const std::string MY_CONSTRAINT_BASE_OBJECT("BaseObject");
- return MY_CONSTRAINT_BASE_OBJECT;
+ static const std::string MY_SELECTED_OBJECT("SelectedObject");
+ return MY_SELECTED_OBJECT;
}
/// Start 2D point of the split segment
- inline static const std::string& ENTITY_POINT()
+ inline static const std::string& SELECTED_POINT()
{
- static const std::string MY_ENTITY_POINT("ConstraintEntityPoint");
- return MY_ENTITY_POINT;
+ static const std::string MY_SELECTED_POINT("SelectedPoint");
+ return MY_SELECTED_POINT;
+ }
+
+ /// The value parameter for the preview object
+ inline static const std::string& PREVIEW_OBJECT()
+ {
+ static const std::string MY_PREVIEW_OBJECT("PreviewObject");
+ return MY_PREVIEW_OBJECT;
+ }
+
+ /// Start 2D point of the split segment
+ inline static const std::string& PREVIEW_POINT()
+ {
+ static const std::string MY_PREVIEW_POINT("PreviewPoint");
+ return MY_PREVIEW_POINT;
}
/// \brief Creates a new part document if needed
/// This is necessary to perform execute only by apply the feature
SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
- /// Called on change of any argument-attribute of this object
- /// \param theID identifier of changed attribute
- SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
/// \brief Use plugin manager for features creation
SketchPlugin_Trim();
/// Moves the feature : Empty
SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
+ typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
+ std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+ std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
+
+ static void fillObjectShapes(const ObjectPtr& theObject,
+ ObjectPtr& theSketch,
+ std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
+ std::map<ObjectPtr, PointToRefsMap>& theObjectToPoints);
+
private:
+ GeomShapePtr getSubShape(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId);
+
/// Returns geom point attribute of the feature bounds. It processes line or arc.
/// For circle feature, the result attributes are null
/// \param theFeature a source feature
const std::shared_ptr<ModelAPI_Feature>& theFeature);
private:
- bool useGraphicIntersection() const;
-
- void fillObjectShapes(const ObjectPtr& theObject);
-
- void findShapePoints(std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
+ void findShapePoints(const std::string& theObjectAttributeId,
+ const std::string& thePointAttributeId,
+ std::shared_ptr<GeomAPI_Pnt>& aStartPoint,
std::shared_ptr<GeomAPI_Pnt>& aLastPoint);
std::shared_ptr<GeomAPI_Pnt2d> convertPoint(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
private:
std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
- typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
- std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
- std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
-
std::map<ObjectPtr, PointToRefsMap> myObjectToPoints;
};
#include "SketchPlugin_Line.h"
#include "SketchPlugin_Point.h"
#include "SketchPlugin_Sketch.h"
+#include "SketchPlugin_Trim.h"
#include "SketchPlugin_Tools.h"
#include "SketcherPrs_Tools.h"
#include <ModelAPI_ResultConstruction.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <ModelGeomAlgo_Shape.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Lin.h>
aKind == SketchPlugin_Circle::ID()) {
std::set<ResultPtr> anEdgeShapes;
- ModelAPI_Tools::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
+ ModelGeomAlgo_Shape::shapesOfType(anAttrFeature, GeomAPI_Shape::EDGE, anEdgeShapes);
if (anEdgeShapes.empty() || anEdgeShapes.size() > 1 /*there case has not existed yet*/)
return aValid;
return aValid;
}
+bool SketchPlugin_TrimValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ bool aValid = false;
+
+ if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
+ theError = "The attribute with the %1 type is not processed";
+ theError.arg(theAttribute->attributeType());
+ return aValid;
+ }
+ AttributeReferencePtr aBaseObjectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+
+ std::shared_ptr<SketchPlugin_Feature> aTrimFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+
+ ObjectPtr aBaseObject = aBaseObjectAttr->value();
+ if (!aBaseObject) {
+ AttributePtr aPreviewAttr = aTrimFeature->attribute(SketchPlugin_Trim::PREVIEW_OBJECT());
+ aBaseObjectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aPreviewAttr);
+ aBaseObject = aBaseObjectAttr->value();
+
+ //return aValid;
+ }
+
+ FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObject);
+ if (!aBaseFeature)
+ return aValid;
+
+ std::string aKind = aBaseFeature->getKind();
+ if (aKind != SketchPlugin_Line::ID() &&
+ aKind != SketchPlugin_Arc::ID() &&
+ aKind != SketchPlugin_Circle::ID())
+ return aValid;
+
+ // point on feature
+ AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aTrimFeature->data()->attribute(SketchPlugin_Trim::PREVIEW_POINT()));
+
+ SketchPlugin_Sketch* aSketch = aTrimFeature->sketch();
+
+ std::shared_ptr<GeomAPI_Pnt2d> anAttributePnt2d = aPoint->pnt();
+ std::shared_ptr<GeomAPI_Pnt> anAttributePnt = aSketch->to3D(anAttributePnt2d->x(),
+ anAttributePnt2d->y());
+
+ std::map<ObjectPtr, std::set<GeomShapePtr> > aCashedShapes;
+ std::map<ObjectPtr, std::map<std::shared_ptr<GeomAPI_Pnt>,
+ std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
+ std::list<std::shared_ptr<ModelAPI_Object> > > > > anObjectToPoints;
+ SketchPlugin_Trim::fillObjectShapes(aBaseObject, aSketch->data()->owner(),
+ aCashedShapes, anObjectToPoints);
+ const std::set<GeomShapePtr>& aShapes = aCashedShapes[aBaseObject];
+
+ return aShapes.size() > 1;
+}
+
bool SketchPlugin_ProjectionValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
Events_InfoMessage& theError) const;
};
+/**\class SketchPlugin_TrimValidator
+ * \ingroup Validators
+ * \brief Validator for the entity of the following type:
+ * - Linear segment with point(s) coinident to this line or intersected it
+ * - Arc with point(s) coincident to the arc or intersected it
+ * - Circle with at least 2 split-points on this circle or intersected it
+ *
+ * Checks that there are coincident point on selected feature.
+ */
+class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
+{
+ public:
+ //! returns true if attribute is valid
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ //! \param theError error message
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
+};
+
/**\class SketchPlugin_IntersectionValidator
* \ingroup Validators
* \brief Validator for the attribute to be intersected with the sketch plane.
<toolbox id="ArcType">
<box id="CenterStartEnd" title="Center and two points" icon="icons/Sketch/arc_base_32x32.png">
<sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"
- enable_value="enable_by_preferences" />
+ enable_value="enable_by_preferences" reference_attribute="ArcCenterRef" />
<!--reference_attribute="ArcCenterRef" />-->
<sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"
enable_value="enable_by_preferences"/>
tooltip="Trim selected segment arc or circle on intersection points nearest to the graphic selection"
icon="icons/Sketch/trim.png">
<sketch_feature_point_selector
- id="BaseObject"
+ id="SelectedObject"
label="Split feature"
tooltip="Select feature for split"
shape_types="edge"
use_external="false"
use_graphic_intersection="true">
- <!--<validator id="SketchPlugin_SplitValidator" parameters="use_graphic_intersection"/> -->
+ <validator id="SketchPlugin_TrimValidator"/>
</sketch_feature_point_selector>
<validator id="PartSet_SplitSelection"/>
</feature>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <AIS_InteractiveContext.hxx>
#endif
aParameters.Append(MyVCallBack);
+ MyTCommunicator->registerPlugin("SMBrowser"); // custom plugin to view ModelAPI
+
MyTCommunicator->init(aParameters);
+ MyTCommunicator->Activate("SMBrowser"); // to have button in TInspector
MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model
MyTCommunicator->Activate("TKDFBrowser");
}