aCurrentWidget = myWorkshop->module()->activeWidget();
ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
(aCurrentWidget);
- ModuleBase_ViewerPrs aPrs;
+ ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
myWorkshop->selection()->fillPresentation(aPrs, theOwner);
aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
#include <GeomAPI_Pnt.h>
//********************************************************************
-void ModuleBase_ISelection::appendSelected(const QList<ModuleBase_ViewerPrs> theValues,
- QList<ModuleBase_ViewerPrs>& theValuesTo)
+void ModuleBase_ISelection::appendSelected(const QList<ModuleBase_ViewerPrsPtr> theValues,
+ QList<ModuleBase_ViewerPrsPtr>& theValuesTo)
{
// collect the objects from the viewer
QObjectPtrList anExistedObjects;
- QList<ModuleBase_ViewerPrs>::const_iterator aPrsIt = theValuesTo.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator aPrsIt = theValuesTo.begin(),
aPrsLast = theValuesTo.end();
for (; aPrsIt != aPrsLast; aPrsIt++) {
- if ((*aPrsIt).owner() && (*aPrsIt).object())
- anExistedObjects.push_back((*aPrsIt).object());
+ if ((*aPrsIt)->owner() && (*aPrsIt)->object())
+ anExistedObjects.push_back((*aPrsIt)->object());
}
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(),
aLast = theValues.end();
for (; anIt != aLast; anIt++) {
- ObjectPtr anObject = (*anIt).object();
+ ObjectPtr anObject = (*anIt)->object();
if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) {
- theValuesTo.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
+ theValuesTo.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)));
}
}
}
//********************************************************************
-ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs)
+ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrsPtr& thePrs)
{
ResultPtr aResult;
- if (thePrs.object().get())
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
- else if (!thePrs.owner().IsNull()) {
- ObjectPtr anObject = getSelectableObject(thePrs.owner());
+ if (thePrs->object().get())
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs->object());
+ else if (!thePrs->owner().IsNull()) {
+ ObjectPtr anObject = getSelectableObject(thePrs->owner());
aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
}
}
//********************************************************************
-GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs)
+GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrsPtr& thePrs)
{
GeomShapePtr aShape;
- const GeomShapePtr& aPrsShape = thePrs.shape();
+ const GeomShapePtr& aPrsShape = thePrs->shape();
// if only result is selected, an empty shape is set to the model
if (!aPrsShape.get() || aPrsShape->isNull()) {
}
}
//********************************************************************
-QList<ModuleBase_ViewerPrs> ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects)
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects)
{
- QList<ModuleBase_ViewerPrs> aSelectedPrs;
+ QList<ModuleBase_ViewerPrsPtr> aSelectedPrs;
QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (anObject.get() != NULL) {
- aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
+ aSelectedPrs.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)));
}
}
return aSelectedPrs;
//********************************************************************
void ModuleBase_ISelection::filterSelectionOnEqualPoints
- (QList<ModuleBase_ViewerPrs>& theSelected)
+ (QList<ModuleBase_ViewerPrsPtr>& theSelected)
{
- QList<ModuleBase_ViewerPrs> aCandidatesToRemove;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(),
+ QList<ModuleBase_ViewerPrsPtr> aCandidatesToRemove;
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theSelected.begin(),
aLast = theSelected.end();
- QList<ModuleBase_ViewerPrs>::const_iterator aSubIt;
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator aSubIt;
for (; anIt != aLast; anIt++) {
aSubIt = anIt;
aSubIt++;
}
}
}
- QList<ModuleBase_ViewerPrs>::const_iterator aRemIt = aCandidatesToRemove.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator aRemIt = aCandidatesToRemove.begin(),
aRemLast = aCandidatesToRemove.end();
for (; aRemIt != aRemLast; aRemIt++) {
theSelected.removeAll(*aRemIt);
}
}
-bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrs thePrs1,
- const ModuleBase_ViewerPrs thePrs2)
+bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrsPtr thePrs1,
+ const ModuleBase_ViewerPrsPtr thePrs2)
{
bool isEqual = false;
- Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1.owner());
- Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2.owner());
+ Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1->owner());
+ Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2->owner());
if (!anOwner1.IsNull() && anOwner1->HasShape() &&
!anOwner2.IsNull() && anOwner2->HasShape()) {
/// Returns a list of viewer selected presentations
/// \return list of presentations
- virtual QList<ModuleBase_ViewerPrs> getSelected(const SelectionPlace& thePlace = Browser) const = 0;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getSelected(const SelectionPlace& thePlace = Browser) const = 0;
/// The values are appended to the first parameter list if the first list does not contain an item
/// with the same object
/// \param theValues a list of new values
/// \param theValuesTo a list, that will be changed
- static void appendSelected(const QList<ModuleBase_ViewerPrs> theValues,
- QList<ModuleBase_ViewerPrs>& theValuesTo);
+ static void appendSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>> theValues,
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValuesTo);
/// Returns a list of viewer highlited presentations
/// \return list of presentations
- virtual QList<ModuleBase_ViewerPrs> getHighlighted() const = 0;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const = 0;
/// Fills the viewer presentation parameters by the parameters from the owner
/// \param thePrs a container for selection
/// \param theOwner a selection owner
- virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs,
+ virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
/**
//! If the shape is equal to the shape of selected object, it returns an empty shape
//! \param thePrs a selected object
//! \return a shape
- MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs);
+ MODULEBASE_EXPORT ResultPtr getResult(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
//! Return the shape from the viewer presentation.
//! If the shape is equal to the shape of selected object, it returns an empty shape
//! \param thePrs a selected object
//! \return a shape
- MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs);
+ MODULEBASE_EXPORT GeomShapePtr getShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
//! Return the IO from the viewer presentation.
//! \param thePrs a selected object
//! \return an interactive object
- virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs) = 0;
+ virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
//! Wraps the object list into the viewer prs list
//! \param theObjects a list of objects
//! \return a list of prs, where only object is not empty
- static MODULEBASE_EXPORT QList<ModuleBase_ViewerPrs> getViewerPrs(
+ static MODULEBASE_EXPORT QList<std::shared_ptr<ModuleBase_ViewerPrs>> getViewerPrs(
const QObjectPtrList& theObjects);
/// Removes selection items where owners have equal vertices. The first
/// owner with the qual vertex stays in the list.
static MODULEBASE_EXPORT void filterSelectionOnEqualPoints
- (QList<ModuleBase_ViewerPrs>& theSelected);
+ (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected);
private:
/// Returns true if the presentations have an owner with a vertex and these vertices are equal.
/// \param thePrs1 the first viewer selected presentation
/// \param thePrs2 the second viewer selected presentation
- static bool isEqualVertices(const ModuleBase_ViewerPrs thePrs1,
- const ModuleBase_ViewerPrs thePrs2);
+ static bool isEqualVertices(const std::shared_ptr<ModuleBase_ViewerPrs> thePrs1,
+ const std::shared_ptr<ModuleBase_ViewerPrs> thePrs2);
};
#endif
//! Select features clearing previous selection.
//! If the list is empty then selection will be cleared
//! \param theValues a list of presentations
- virtual void setSelected(const QList<ModuleBase_ViewerPrs>& theValues) = 0;
+ virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) = 0;
/// Update of commands status
virtual void updateCommandStatus() = 0;
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped selection values
/// \param theToValidate the boolean value whether the value should be checked by filters
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate)
{
return false;
/// Returns values which should be highlighted when the whidget is active
/// \param theValues a list of presentations
- virtual void getHighlighted(QList<ModuleBase_ViewerPrs>& theValues) {};
+ virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) {};
/// Restore value from attribute data to the widget's control. Emits signals before and after store
/// \return True in success
void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelection,
ModuleBase_IViewer* theViewer)
{
- QList<ModuleBase_ViewerPrs> aPreSelected;
+ QList<ModuleBase_ViewerPrsPtr> aPreSelected;
// Check that the selected result are not results of operation feature
FeaturePtr aFeature = feature();
if (aFeature) {
- QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
+ QList<ModuleBase_ViewerPrsPtr> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
std::list<ResultPtr> aResults = aFeature->results();
QObjectPtrList aResList;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
aResList.append(*aIt);
- foreach (ModuleBase_ViewerPrs aPrs, aSelected) {
- if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature))
+ foreach (ModuleBase_ViewerPrsPtr aPrs, aSelected) {
+ if ((!aResList.contains(aPrs->object())) && (aPrs->object() != aFeature))
aPreSelected.append(aPrs);
}
} else
setPreselection(aPreSelected);
}
-void ModuleBase_OperationFeature::setPreselection(const QList<ModuleBase_ViewerPrs>& theValues)
+void ModuleBase_OperationFeature::setPreselection(const QList<ModuleBase_ViewerPrsPtr>& theValues)
{
clearPreselection();
myPreSelection = theValues;
/// Fill internal map by preselection
/// \param theValues a list of preselection
- void setPreselection(const QList<ModuleBase_ViewerPrs>& theValues);
+ void setPreselection(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// \brief Set property pane to the operation
/// \param theProp a property panel instance
bool myIsEditing;
/// List of pre-selected object
- QList<ModuleBase_ViewerPrs> myPreSelection;
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> myPreSelection;
/// If the operation works with feature which is sub-feature of another one
/// then this variable has to be initialised by parent feature
#include <ModuleBase_ResultPrs.h>
-ModuleBase_ViewerPrs::ModuleBase_ViewerPrs()
-{
-
-}
-
ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult,
const GeomShapePtr& theShape,
Handle_SelectMgr_EntityOwner theOwner)
Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(myOwner);
Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs.owner());
if (!anOwner1.IsNull() && !anOwner2.IsNull())
- isEqualOwner = anOwner1->Shape() == anOwner2->Shape();
+ isEqualOwner = (anOwner1->Shape().IsNull() && anOwner2->Shape().IsNull()) ||
+ anOwner1->Shape().IsEqual(anOwner2->Shape());
}
if (isEqualResult && isEqualShape &&
Handle(ModuleBase_BRepOwner) aCSolidOwner2 = Handle(ModuleBase_BRepOwner)::DownCast(thePrs.owner());
isEqualIO = !aCSolidOwner1.IsNull() && !aCSolidOwner2.IsNull();
if (!aCSolidOwner1.IsNull() && !aCSolidOwner1.IsNull())
- isEqualOwner = aCSolidOwner1->Shape() == aCSolidOwner1->Shape();
+ isEqualOwner = (aCSolidOwner1->Shape().IsNull() && aCSolidOwner2->Shape().IsNull()) ||
+ aCSolidOwner1->Shape().IsEqual(aCSolidOwner2->Shape());
}
return isEqualResult && isEqualShape && isEqualOwner && isEqualIO;
class ModuleBase_ViewerPrs
{
public:
- /// Constructor
- MODULEBASE_EXPORT ModuleBase_ViewerPrs();
-
/// Constructor
/// \param theResult an object
/// \param theShape a viewer shape
/// \param theOwner a selection owner
- MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const GeomShapePtr& theShape,
- Handle_SelectMgr_EntityOwner theOwner);
+ MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult = ObjectPtr(),
+ const GeomShapePtr& theShape = GeomShapePtr(),
+ Handle_SelectMgr_EntityOwner theOwner = NULL);
/// Destructor
MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs();
Handle(AIS_InteractiveObject) myInteractive; /// interactive object
};
+typedef std::shared_ptr<ModuleBase_ViewerPrs> ModuleBase_ViewerPrsPtr;
+
#endif
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
- QList<ModuleBase_ViewerPrs> aSkippedValues;
+ QList<ModuleBase_ViewerPrsPtr> aSkippedValues;
/// remove unused objects from the model attribute.
/// It should be performed before new attributes append.
removeUnusedAttributeObjects(theValues);
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
bool isDone = false;
for (; anIt != aLast; anIt++) {
- ModuleBase_ViewerPrs aValue = *anIt;
+ ModuleBase_ViewerPrsPtr aValue = *anIt;
bool aProcessed = false;
if (!theToValidate || isValidInFilters(aValue)) {
aProcessed = setSelectionCustom(aValue);
}
//********************************************************************
-void ModuleBase_WidgetMultiSelector::getHighlighted(QList<ModuleBase_ViewerPrs>& theValues)
+void ModuleBase_WidgetMultiSelector::getHighlighted(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
std::set<int> anAttributeIds;
getSelectedAttributeIndices(anAttributeIds);
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool aValid = ModuleBase_WidgetSelector::isValidSelectionCustom(thePrs);
if (aValid) {
void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
{
activateSelectionAndFilters(true);
- QList<ModuleBase_ViewerPrs> anEmptyList;
+ QList<ModuleBase_ViewerPrsPtr> anEmptyList;
// This method will call Selection changed event which will call onSelectionChanged
// To clear mySelection, myListControl and storeValue()
// So, we don't need to call it
}
}
-QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getAttributeSelection() const
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetMultiSelector::getAttributeSelection() const
{
- QList<ModuleBase_ViewerPrs> aSelected;
+ QList<ModuleBase_ViewerPrsPtr> aSelected;
convertIndicesToViewerSelection(std::set<int>(), aSelected);
return aSelected;
}
}
void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
- QList<ModuleBase_ViewerPrs>& theValues) const
+ QList<ModuleBase_ViewerPrsPtr>& theValues) const
{
if(myFeature.get() == NULL)
return;
AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
ResultPtr anObject = anAttr->context();
if (anObject.get())
- theValues.append(ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL));
+ theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL)));
}
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
continue;
ObjectPtr anObject = aRefListAttr->object(i);
if (anObject.get()) {
- theValues.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
+ theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)));
}
}
}
AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
if (anAttribute.get()) {
GeomShapePtr aGeomShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop);
- theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL));
+ theValues.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, aGeomShape, NULL)));
}
}
}
}
void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects
- (QList<ModuleBase_ViewerPrs>& theValues)
+ (QList<ModuleBase_ViewerPrsPtr>& theValues)
{
std::map<ObjectPtr, std::set<GeomShapePtr> > aGeomSelection = convertSelection(theValues);
DataPtr aData = myFeature->data();
}
else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
std::set<AttributePtr> anAttributes;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
ObjectPtr anObject;
GeomShapePtr aShape;
for (; anIt != aLast; anIt++) {
- ModuleBase_ViewerPrs aPrs = *anIt;
+ ModuleBase_ViewerPrsPtr aPrs = *anIt;
getGeomSelection(aPrs, anObject, aShape);
AttributePtr anAttr = myWorkshop->module()->findAttribute(anObject, aShape);
if (anAttr.get() && anAttributes.find(anAttr) == anAttributes.end())
}
std::map<ObjectPtr, std::set<GeomShapePtr> > ModuleBase_WidgetMultiSelector::convertSelection
- (QList<ModuleBase_ViewerPrs>& theValues)
+ (QList<ModuleBase_ViewerPrsPtr>& theValues)
{
// convert prs list to objects map
std::map<ObjectPtr, std::set<GeomShapePtr> > aGeomSelection;
std::set<GeomShapePtr> aShapes;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
ObjectPtr anObject;
GeomShapePtr aShape;
GeomShapePtr anEmptyShape(new GeomAPI_Shape());
for (; anIt != aLast; anIt++) {
- ModuleBase_ViewerPrs aPrs = *anIt;
+ ModuleBase_ViewerPrsPtr aPrs = *anIt;
getGeomSelection(aPrs, anObject, aShape);
aShapes.clear();
if (aGeomSelection.find(anObject) != aGeomSelection.end()) // found
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped selection values
/// \param theToValidate a validation of the values flag
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Returns values which should be highlighted when the whidget is active
/// \param theValues a list of presentations
- virtual void getHighlighted(QList<ModuleBase_ViewerPrs>& theValues);
+ virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Returns true if the event is processed. The default implementation is empty, returns false.
virtual bool processDelete();
/// Return the attribute values wrapped in a list of viewer presentations
/// \return a list of viewer presentations, which contains an attribute result and
/// a shape. If the attribute do not uses the shape, it is empty
- virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
/// Fills the list control by the attribute values
void updateSelectionList();
/// \param theAttributeIds indices in attribute list to be returned
/// \param theValues the result presentations, filled with object and shape of an attribute item
void convertIndicesToViewerSelection(std::set<int> theAttributeIds,
- QList<ModuleBase_ViewerPrs>& theValues) const;
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) const;
/// Iterates throgh the model attribute list and remove elements which do not present in the list
/// \param theValues the wrapped selection values
- virtual void removeUnusedAttributeObjects(QList<ModuleBase_ViewerPrs>& theValues);
+ virtual void removeUnusedAttributeObjects(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Converts viewer presentation selection list to objects and shapes map
/// \param theValues the wrapped selection values
/// \return selection list
std::map<ObjectPtr, std::set<GeomShapePtr> > convertSelection
- (QList<ModuleBase_ViewerPrs>& theValues);
+ (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Returns true if the object and shape present in the container
/// \param theObject a model object, a set of shapes is searched by it
}
//********************************************************************
-void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape)
{
//********************************************************************
void ModuleBase_WidgetSelector::onSelectionChanged()
{
- QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
bool isDone = setSelection(aSelected, true/*false*/);
updateOnSelectionChanged(isDone);
}
}
//********************************************************************
-QList<ModuleBase_ViewerPrs> ModuleBase_WidgetSelector::getAttributeSelection() const
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetSelector::getAttributeSelection() const
{
- return QList<ModuleBase_ViewerPrs>();
+ return QList<ModuleBase_ViewerPrsPtr>();
}
//********************************************************************
}
//********************************************************************
-bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
}
//********************************************************************
-bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
ObjectPtr anObject;
GeomShapePtr aShape;
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Fills the attribute with the value of the selected owner
/// \param thePrs a selected owner
- virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// The methiod called when widget is deactivated
virtual void deactivate();
/// \return a list of viewer presentations, which contains an attribute result and
/// a shape. If the attribute do not uses the shape, it is empty
// NDS: has body is temporary
- virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
/// Retunrs a list of possible shape types
/// \return a list of shapes
/// \param thePrs a selection
/// \param theObject an output object
/// \param theShape a shape of the selection
- virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+ virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape);
* \ingroup GUI
Provides for an attribute backup of values. It is possible to store/ restore the attribute values.
*/
-class MODULEBASE_EXPORT ModuleBase_WidgetSelectorStore
+class ModuleBase_WidgetSelectorStore
{
public:
/// Constructor
- ModuleBase_WidgetSelectorStore();
+ MODULEBASE_EXPORT ModuleBase_WidgetSelectorStore();
/// Destructor
- virtual ~ModuleBase_WidgetSelectorStore() {}
+ MODULEBASE_EXPORT virtual ~ModuleBase_WidgetSelectorStore() {}
/// Creates a backup of the current values of the attribute
/// \param theAttribute a model attribute which parameters are to be stored
/// \param theWorkshop a current workshop
- void storeAttributeValue(const AttributePtr& theAttribute,
- ModuleBase_IWorkshop* theWorkshop);
+ MODULEBASE_EXPORT void storeAttributeValue(const AttributePtr& theAttribute,
+ ModuleBase_IWorkshop* theWorkshop);
/// Creates a backup of the current values of the attribute
/// \param theAttribute a model attribute which parameters are to be restored
/// \param theWorkshop a current workshop
- void restoreAttributeValue(const AttributePtr& theAttribute,
- ModuleBase_IWorkshop* theWorkshop);
+ MODULEBASE_EXPORT void restoreAttributeValue(const AttributePtr& theAttribute,
+ ModuleBase_IWorkshop* theWorkshop);
private:
/// backup parameters of the model attribute. The class processes three types of attribute:
}
//********************************************************************
-bool ModuleBase_WidgetShapeSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+bool ModuleBase_WidgetShapeSelector::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
if (theValues.empty()) {
// In order to make reselection possible, set empty object and shape should be done
- setSelectionCustom(ModuleBase_ViewerPrs());
+ setSelectionCustom(std::shared_ptr<ModuleBase_ViewerPrs>(new ModuleBase_ViewerPrs(
+ ObjectPtr(), GeomShapePtr(), NULL)));
return false;
}
// it removes the processed value from the parameters list
- ModuleBase_ViewerPrs aValue = theValues.takeFirst();
+ ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst();
bool isDone = false;
if (!theToValidate || isValidInFilters(aValue)) {
}
//********************************************************************
-QList<ModuleBase_ViewerPrs> ModuleBase_WidgetShapeSelector::getAttributeSelection() const
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetShapeSelector::getAttributeSelection() const
{
- QList<ModuleBase_ViewerPrs> aSelected;
+ QList<ModuleBase_ViewerPrsPtr> aSelected;
if(myFeature) {
DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute);
std::shared_ptr<GeomAPI_Shape> aShapePtr = getShape();
- ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL);
+ ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs(anObject, aShapePtr, NULL));
aSelected.append(aPrs);
}
return aSelected;
/// It is redefined to check the value validity and if it is, fill the attribute with by value
/// \param theValues the wrapped selection values
/// \param theToValidate a flag on validation of the values
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Returns list of widget controls
/// Return the attribute values wrapped in a list of viewer presentations
/// \return a list of viewer presentations, which contains an attribute result and
/// a shape. If the attribute do not uses the shape, it is empty
- virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
//----------- Class members -------------
protected:
}
//********************************************************************
-bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs)
+bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool aValid = true;
- Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner();
+ Handle(SelectMgr_EntityOwner) anOwner = thePrs->owner();
// if an owner is null, the selection happens in the Object browser.
// creates a selection owner on the base of object shape and the object AIS object
- if (anOwner.IsNull() && thePrs.owner().IsNull() && thePrs.object().get()) {
+ if (anOwner.IsNull() && thePrs->owner().IsNull() && thePrs->object().get()) {
ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
if (aResult.get() && aResult->shape().get()) {
// some results have no shape, e.g. the parameter one. So, they should not be validated
}
// removes created owner
- if (!anOwner.IsNull() && anOwner != thePrs.owner()) {
+ if (!anOwner.IsNull() && anOwner != thePrs->owner()) {
anOwner.Nullify();
myPresentedObject = ObjectPtr();
}
}
//********************************************************************
-bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue)
+bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
{
bool aValid = false;
if (getValidState(theValue, aValid)) {
}
//********************************************************************
-bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_ViewerPrs& theValue,
+bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_ViewerPrsPtr& theValue,
const AttributePtr& theAttribute)
{
bool aValid = false;
}
//********************************************************************
-bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
return true;
}
}
//********************************************************************
-void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid)
+void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrsPtr& theValue, const bool theValid)
{
bool aValidPrs = myInvalidPrs.contains(theValue);
bool anInvalidPrs = myInvalidPrs.contains(theValue);
}
//********************************************************************
-bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid)
+bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrsPtr& theValue, bool& theValid)
{
bool aValidPrs = myValidPrs.contains(theValue);
bool anInvalidPrs = myInvalidPrs.contains(theValue);
}
//********************************************************************
-QList<ModuleBase_ViewerPrs> ModuleBase_WidgetValidated::getFilteredSelected()
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetValidated::getFilteredSelected()
{
- QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(
+ QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
ModuleBase_ISelection::Viewer);
- QList<ModuleBase_ViewerPrs> anOBSelected = myWorkshop->selection()->getSelected(
+ QList<ModuleBase_ViewerPrsPtr> anOBSelected = myWorkshop->selection()->getSelected(
ModuleBase_ISelection::Browser);
// filter the OB presentations
filterPresentations(anOBSelected);
}
//********************************************************************
-void ModuleBase_WidgetValidated::filterPresentations(QList<ModuleBase_ViewerPrs>& theValues)
+void ModuleBase_WidgetValidated::filterPresentations(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
- QList<ModuleBase_ViewerPrs> aValidatedValues;
+ QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
bool isDone = false;
for (; anIt != aLast; anIt++) {
if (isValidInFilters(*anIt))
}
//********************************************************************
-void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrs>& theValues)
+void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
std::set<ResultCompSolidPtr> aCompSolids;
- QList<ModuleBase_ViewerPrs> aValidatedValues;
+ QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
// Collect compsolids.
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
for (; anIt != aLast; anIt++) {
- const ModuleBase_ViewerPrs& aViewerPrs = *anIt;
- ObjectPtr anObject = aViewerPrs.object();
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
if(aResultCompSolid.get()) {
aCompSolids.insert(aResultCompSolid);
// Filter sub-solids of compsolids.
anIt = theValues.begin();
for (; anIt != aLast; anIt++) {
- const ModuleBase_ViewerPrs& aViewerPrs = *anIt;
- ObjectPtr anObject = aViewerPrs.object();
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult);
if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) {
/// restored.The valid/invalid value is cashed.
/// \param theValue a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
+ virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
//! Returns data object by AIS
ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
/// Checks whether all active viewer filters validate the presentation
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
+ bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Checks all attribute validators returns valid. It tries on the given 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
- bool isValidSelectionForAttribute(const ModuleBase_ViewerPrs& theValue,
+ bool isValidSelectionForAttribute(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,
const AttributePtr& theAttribute);
/// Retunrs attribute, which should be validated. In default implementation,
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Fills the attribute with the value of the selected owner
/// \param thePrs a selected owner
- virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
+ virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
/// Returns a list of selected presentations in the viewer and object browser
/// The presentations from the object browser are filtered by the AIS context filters
/// \return a list of presentations
- QList<ModuleBase_ViewerPrs> getFilteredSelected();
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> getFilteredSelected();
/// It obtains selection filters from the workshop and activates them in the active viewer
/// \param toActivate a flag about activation or deactivation the filters
/// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored
/// \param theValue a viewer presentation
/// \param theValid a valid state
- bool getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid);
+ bool getValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, bool& theValid);
/// Store the validity state of the presentation in an internal map
/// \param theValue a viewer presentation
/// \param theValid a valid state
- void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid);
+ void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);
private:
/// Applies AIS context filters to the parameter list. The not approved presentations are
/// removed from the parameters.
/// \param theValues a list of presentations.
- void filterPresentations(QList<ModuleBase_ViewerPrs>& theValues);
+ void filterPresentations(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Remove subshapes of compsolids if whole compsolid is present.
/// \param theValues a list of presentations.
- void filterCompSolids(QList<ModuleBase_ViewerPrs>& theValues);
+ void filterCompSolids(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
protected:
/// Reference to workshop
private:
ObjectPtr myPresentedObject; /// back up of the filtered object
- QList<ModuleBase_ViewerPrs> myValidPrs; /// cash of valid selection presentations
- QList<ModuleBase_ViewerPrs> myInvalidPrs; /// cash of invalid selection presentations
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs; /// cash of valid selection presentations
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> myInvalidPrs; /// cash of invalid selection presentations
/// store to backup parameters of the model
ModuleBase_WidgetSelectorStore* myAttributeStore;
{
Standard_Boolean aValid = Standard_True;
- ModuleBase_ViewerPrs aPrs;
+ ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
myWorkshop->selection()->fillPresentation(aPrs, theOwner);
ResultPtr aResult = myWorkshop->selection()->getResult(aPrs);
// to filter infinite construction results
bool hasAttribute = false;
bool hasFeature = false;
- QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
ResultPtr aResult;
FeaturePtr aFeature;
- foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
if (aResult.get() != NULL) {
- const GeomShapePtr& aShape = aPrs.shape();
+ const GeomShapePtr& aShape = aPrs->shape();
if (aShape.get() && aShape->isEqual(aResult->shape()))
hasFeature = true;
else
hasAttribute = true;
} else {
- aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs.object());
+ aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
hasFeature = (aFeature.get() != NULL);
}
}
if (aPrsList.size() == 1) {
- const GeomShapePtr& aShape = aPrsList.first().shape();
+ const GeomShapePtr& aShape = aPrsList.first()->shape();
if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) {
// Find 2d coordinates
FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch();
std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d);
// Find coincident in these coordinates
- ObjectPtr aObj = aPrsList.first().object();
+ ObjectPtr aObj = aPrsList.first()->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
FeaturePtr aCoincident = PartSet_Tools::findFirstCoincidence(aFeature, aSelPnt);
// If we have coincidence then add Detach menu
if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) {
ModuleBase_ISelection* aSelection = workshop()->selection();
// click on a point in sketch leads here with the point is highlighted, not yet selected
- QList<ModuleBase_ViewerPrs> aPreselection = aSelection->getHighlighted();
+ QList<ModuleBase_ViewerPrsPtr> aPreselection = aSelection->getHighlighted();
if (aPreselection.size() == 1) {
- ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0];
- ObjectPtr anObject = aSelectedPrs.object();
+ ModuleBase_ViewerPrsPtr aSelectedPrs = aPreselection[0];
+ ObjectPtr anObject = aSelectedPrs->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
FeaturePtr anOpFeature = aFOperation->feature();
- GeomShapePtr aShape = aSelectedPrs.shape();
+ GeomShapePtr aShape = aSelectedPrs->shape();
// click on the digit of dimension constrain comes here with an empty shape, so we need the check
if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) {
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
if (isSketcherOp) {
// Editing of constraints can be done on selection
ModuleBase_ISelection* aSelect = myWorkshop->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+ QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected();
if (aSelected.size() == 1) {
- ModuleBase_ViewerPrs aPrs = aSelected.first();
- ObjectPtr aObject = aPrs.object();
+ ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
+ ObjectPtr aObject = aPrs->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (aFeature) {
std::string aId = aFeature->getKind();
{
theObjectShapes.clear();
- QList<ModuleBase_ViewerPrs> aValues;
+ QList<ModuleBase_ViewerPrsPtr> aValues;
ModuleBase_IPropertyPanel* aPanel = theWorkshop->propertyPanel();
if (aPanel) {
ModuleBase_ModelWidget* aWidget = aPanel->activeWidget();
}
QList<GeomShapePtr> aShapes;
- QList<ModuleBase_ViewerPrs>::const_iterator anIIt = aValues.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIIt = aValues.begin(),
aILast = aValues.end();
for (; anIIt != aILast; anIIt++) {
- ModuleBase_ViewerPrs aPrs = *anIIt;
- ObjectPtr anObject = aPrs.object();
+ ModuleBase_ViewerPrsPtr aPrs = *anIIt;
+ ObjectPtr anObject = aPrs->object();
- GeomShapePtr aGeomShape = aPrs.shape();
+ GeomShapePtr aGeomShape = aPrs->shape();
if (!aGeomShape.get() || aGeomShape->isNull()) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
//#define DEBUG_CURSOR
/// Returns list of unique objects by sum of objects from List1 and List2
-/*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
- const QList<ModuleBase_ViewerPrs>& theList2)
+/*QList<ModuleBase_ViewerPrsPtr> getSumList(const QList<ModuleBase_ViewerPrsPtr>& theList1,
+ const QList<ModuleBase_ViewerPrsPtr>& theList2)
{
- QList<ModuleBase_ViewerPrs> aRes;
- foreach (ModuleBase_ViewerPrs aPrs, theList1) {
+ QList<ModuleBase_ViewerPrsPtr> aRes;
+ foreach (ModuleBase_ViewerPrsPtr aPrs, theList1) {
if (!aRes.contains(aPrs))
aRes.append(aPrs);
}
- foreach (ModuleBase_ViewerPrs aPrs, theList2) {
+ foreach (ModuleBase_ViewerPrsPtr aPrs, theList2) {
if (!aRes.contains(aPrs))
aRes.append(aPrs);
}
// \param theSketch a sketch to project a vertex shape of a presentation to the plane
// and find the corresponded attribute
// \param theFeatureList an output list of features
-void fillFeatureList(const QList<ModuleBase_ViewerPrs>& theList,
+void fillFeatureList(const QList<ModuleBase_ViewerPrsPtr>& theList,
const FeaturePtr theSketch,
QList<FeaturePtr>& theFeatureList)
{
- QList<ModuleBase_ViewerPrs> aRes;
+ QList<ModuleBase_ViewerPrsPtr> aRes;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theList.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theList.begin(),
aLast = theList.end();
for (; anIt != aLast; anIt++)
{
- ModuleBase_ViewerPrs aPrs = *anIt;
- FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object());
+ ModuleBase_ViewerPrsPtr aPrs = *anIt;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object());
if (aFeature.get() && !theFeatureList.contains(aFeature))
theFeatureList.append(aFeature);
}
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_ISelection* aSelect = aWorkshop->selection();
- QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
+ QList<ModuleBase_ViewerPrsPtr> aHighlighted = aSelect->getHighlighted();
QList<FeaturePtr> aFeatureList;
if (theHighlightedOnly) {
else {
fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList);
- QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls);
+ QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls);
fillFeatureList(aSelected, myCurrentSketch, aFeatureList);
}
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, GeomShapePtr(), NULL));
+ QList<ModuleBase_ViewerPrsPtr> aSelection;
+ aSelection.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL)));
aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true);
}
}
return ResultPtr();
}
-bool PartSet_Tools::isContainPresentation(const QList<ModuleBase_ViewerPrs>& theSelected,
- const ModuleBase_ViewerPrs& thePrs)
+bool PartSet_Tools::isContainPresentation(const QList<ModuleBase_ViewerPrsPtr>& theSelected,
+ const ModuleBase_ViewerPrsPtr& thePrs)
{
- foreach (ModuleBase_ViewerPrs aPrs, theSelected) {
- if (aPrs.object() == thePrs.object())
+ foreach (ModuleBase_ViewerPrsPtr aPrs, theSelected) {
+ if (aPrs->object() == thePrs->object())
return true;
}
return false;
}
-bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch,
+bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrsPtr& thePrs, FeaturePtr theSketch,
Handle_V3d_View theView, double& theX, double& theY)
{
bool aHasVertex = false;
- const GeomShapePtr& aShape = thePrs.shape();
+ const GeomShapePtr& aShape = thePrs->shape();
if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX)
{
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
/// \param theSelected a list of presentations
/// \param thePrs a presentation to be found
/// \return - result of check, true if the list contains the prs
- static bool isContainPresentation(const QList<ModuleBase_ViewerPrs>& theSelected,
- const ModuleBase_ViewerPrs& thePrs);
+ static bool isContainPresentation(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected,
+ const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Returns Result object if the given skietch contains external edge equal to the given
/// \param theSketch - the sketch feature
/// \param theView a 3D view
/// \param theX the output horizontal coordinate of the point
/// \param theY the output vertical coordinate of the point
- static bool hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch,
+ static bool hasVertexShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs, FeaturePtr theSketch,
Handle_V3d_View theView, double& theX, double& theY);
int shapesNbPoints(const ModuleBase_ISelection* theSelection)
{
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
ModuleBase_ISelection::filterSelectionOnEqualPoints(aList);
int aCount = 0;
- foreach (ModuleBase_ViewerPrs aPrs, aList) {
- const GeomShapePtr& aShape = aPrs.shape();
+ foreach (ModuleBase_ViewerPrsPtr aPrs, aList) {
+ const GeomShapePtr& aShape = aPrs->shape();
if (aShape.get() && !aShape->isNull()) {
if (aShape->shapeType() == GeomAPI_Shape::VERTEX)
aCount++;
int shapesNbLines(const ModuleBase_ISelection* theSelection)
{
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
int aCount = 0;
- foreach(ModuleBase_ViewerPrs aPrs, aList) {
- const GeomShapePtr& aShape = aPrs.shape();
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aList) {
+ const GeomShapePtr& aShape = aPrs->shape();
if (aShape.get() && !aShape->isNull()) {
if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
return isEmptySelectionValid(theOperation);
} else {
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
- ModuleBase_ViewerPrs aPrs;
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
int aCount = 0;
- foreach (ModuleBase_ViewerPrs aPrs, aList) {
- const GeomShapePtr& aShape = aPrs.shape();
+ foreach (ModuleBase_ViewerPrsPtr aPrs, aList) {
+ const GeomShapePtr& aShape = aPrs->shape();
if (aShape.get() && !aShape->isNull()) {
if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
return isEmptySelectionValid(theOperation);
} else {
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
return (aList.count() == 1);
}
}
if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
return isEmptySelectionValid(theOperation);
} else {
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
if ((aList.size() == 0) || (aList.size() > 2))
return false;
- ModuleBase_ViewerPrs aPrs = aList.first();
- const GeomShapePtr& aShape = aPrs.shape();
+ ModuleBase_ViewerPrsPtr aPrs = aList.first();
+ const GeomShapePtr& aShape = aPrs->shape();
if (!aShape.get() || aShape->isNull() || aShape->shapeType() != GeomAPI_Shape::EDGE)
return false;
GeomAPI_Edge aEdge1(aShape);
if (aList.size() == 2) {
// Check second selection
aPrs = aList.last();
- const GeomShapePtr& aShape2 = aPrs.shape();
+ const GeomShapePtr& aShape2 = aPrs->shape();
if (!aShape2.get() || aShape2->isNull() || aShape2->shapeType() != GeomAPI_Shape::EDGE)
return false;
GeomAPI_Edge aEdge2(aShape2);
if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
return isEmptySelectionValid(theOperation);
} else {
- QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
- ModuleBase_ViewerPrs aPrs;
+ QList<ModuleBase_ViewerPrsPtr> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
int aCount = 0;
int aType = 0;
- foreach (ModuleBase_ViewerPrs aPrs, aList) {
- GeomShapePtr aShape = aPrs.shape();
+ foreach (ModuleBase_ViewerPrsPtr aPrs, aList) {
+ GeomShapePtr aShape = aPrs->shape();
if (aShape.get() && aShape->isEdge()) {
aCount++;
GeomAPI_Edge aEdge(aShape);
}
//********************************************************************
-bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool aValid = ModuleBase_WidgetMultiSelector::isValidSelectionCustom(thePrs);
if (aValid) {
myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true);
}
-void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape)
{
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// \param thePrs a selection
/// \param theObject an output object
/// \param theShape a shape of the selection
- virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+ virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape);
{
}
-bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
bool isDone = false;
if (theValues.empty())
return isDone;
- ModuleBase_ViewerPrs aValue = theValues.takeFirst();
- GeomShapePtr aShape = aValue.shape();
+ ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst();
+ GeomShapePtr aShape = aValue->shape();
if (aShape.get() && !aShape->isNull()) {
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
double aX, aY;
}
else if (canBeActivatedByMove()) {
if (feature()->getKind() == SketchPlugin_Line::ID()) {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aValue.object());
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aValue->object());
// Initialize new line with first point equal to end of previous
if (aFeature.get()) {
std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped widget values
/// \param theToValidate a validation flag
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Select the internal content if it can be selected. It is empty in the default realization
}
//********************************************************************
-bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs);
if (aValid) {
return aValid;
}
-void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape)
{
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Return an object and geom shape by the viewer presentation
/// \param thePrs a selection
/// \param theObject an output object
/// \param theShape a shape of the selection
- virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
+ virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
ObjectPtr& theObject,
GeomShapePtr& theShape);
}
//********************************************************************
-bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrs& theValue)
+bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
{
bool aValid = false;
if (myIsCustomAttribute) {
}
//********************************************************************
-bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrs& theValue)
+bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue)
{
return PartSet_WidgetSketchLabel::canFillSketch(theValue);
}
return aHasSubObjects;
}
-bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
bool aDone = false;
if (!startSketchOperation(theValues)) {
myIsCustomAttribute = true;
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
bool aProcessed = false;
for (; anIt != aLast; anIt++) {
- ModuleBase_ViewerPrs aValue = *anIt;
+ ModuleBase_ViewerPrsPtr aValue = *anIt;
if (!theToValidate || isValidInFilters(aValue))
aProcessed = setSelectionCustom(aValue) || aProcessed;
}
//********************************************************************
void PartSet_WidgetSketchCreator::onSelectionChanged()
{
- QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
bool isDone = setSelection(aSelected, true/*false*/);
}
{
}
-bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues)
+bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrsPtr>& theValues)
{
bool aSketchStarted = false;
if (theValues.size() != 1)
return aSketchStarted;
- ModuleBase_ViewerPrs aValue = theValues.front();
+ ModuleBase_ViewerPrsPtr aValue = theValues.front();
if (!PartSet_WidgetSketchLabel::canFillSketch(aValue))
return aSketchStarted;
// start edit operation for the sketch
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myModule->createOperation("Sketch"));
- QList<ModuleBase_ViewerPrs> aValues;
+ QList<ModuleBase_ViewerPrsPtr> aValues;
aValues.push_back(aValue);
aFOperation->setPreselection(aValues);
/// This value should be processed in the widget according to the needs
/// \param theValues the wrapped selection values
/// \param theToValidate a validation of the values flag
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Editing mode depends on mode of current operation. This value is defined by it.
/// restored.The valid/invalid value is cashed.
/// \param theValue a selected presentation in the view
/// \return a boolean value
- virtual bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
+ virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
protected:
/// If there is no operation in current session, start operation for modify parameters
/// Checks whether the selection presentation contains preview planes
/// \param theValue a selection information
/// \return a boolean value
- virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& theValue);
+ virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
/// Saves the internal parameters to the given feature
/// \return True in success
/// Append new Sketch, set the selected plane for the sketch and start Edit operation.
/// \param theValues a selection list
/// \return true if the sketch is started
- bool startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues);
+ bool startSketchOperation(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Sets the sub-object to list of base.
static void setSketchObjectToList(const CompositeFeaturePtr& theFeature,
{
}
-bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+bool PartSet_WidgetSketchLabel::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
// do not use the given selection if the plane of the sketch has been already set.
if (plane().get())
return true;
- ModuleBase_ViewerPrs aPrs = theValues.first();
+ ModuleBase_ViewerPrsPtr aPrs = theValues.first();
bool aDone = setSelectionInternal(theValues, theToValidate);
if (aDone)
updateByPlaneSelected(aPrs);
void PartSet_WidgetSketchLabel::onSelectionChanged()
{
- QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
if (aSelected.empty())
return;
- ModuleBase_ViewerPrs aPrs = aSelected.first();
+ ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
bool aDone = setSelectionInternal(aSelected, false);
if (aDone) {
updateByPlaneSelected(aPrs);
}
}
-bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList<ModuleBase_ViewerPrs>& theValues,
+bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
bool aDone = false;
- ModuleBase_ViewerPrs aValue;
if (theValues.empty()) {
// In order to make reselection possible, set empty object and shape should be done
- setSelectionCustom(ModuleBase_ViewerPrs());
+ setSelectionCustom(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(ObjectPtr(), GeomShapePtr(), NULL)));
aDone = false;
}
else {
// it removes the processed value from the parameters list
- aValue = theValues.first();//.takeFirst();
+ ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst();
if (!theToValidate || isValidInFilters(aValue))
aDone = setSelectionCustom(aValue);
}
return aDone;
}
-void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs)
+void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs)
{
// 1. hide main planes if they have been displayed
myPreviewPlanes->erasePreviewPlanes(myWorkshop);
// 2. if the planes were displayed, change the view projection
- const GeomShapePtr& aShape = thePrs.shape();
+ const GeomShapePtr& aShape = thePrs->shape();
std::shared_ptr<GeomAPI_Shape> aGShape;
std::shared_ptr<GeomAPI_Shape> aBaseShape;
}
}
-bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
return fillSketchPlaneBySelection(feature(), thePrs);
}
-bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs)
+bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs)
{
bool aCanFillSketch = true;
// avoid any selection on sketch object
- ObjectPtr anObject = thePrs.object();
+ ObjectPtr anObject = thePrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
if (aCanFillSketch) {
std::shared_ptr<GeomAPI_Face> aGeomFace;
- GeomShapePtr aGeomShape = thePrs.shape();
+ GeomShapePtr aGeomShape = thePrs->shape();
if ((!aGeomShape.get() || aGeomShape->isNull()) && aResult.get()) {
aGeomShape = aResult->shape();
}
}
bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const FeaturePtr& theFeature,
- const ModuleBase_ViewerPrs& thePrs)
+ const ModuleBase_ViewerPrsPtr& thePrs)
{
bool isOwnerSet = false;
- const GeomShapePtr& aShape = thePrs.shape();
+ const GeomShapePtr& aShape = thePrs->shape();
std::shared_ptr<GeomAPI_Dir> aDir;
- if (thePrs.object() && (theFeature != thePrs.object())) {
+ if (thePrs->object() && (theFeature != thePrs->object())) {
DataPtr aData = theFeature->data();
AttributeSelectionPtr aSelAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
if (aSelAttr) {
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs->object());
if (aRes) {
GeomShapePtr aShapePtr(new GeomAPI_Shape());
if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer
/// It is redefined to do nothing if the plane of the sketch has been already set.
/// \param theValues the wrapped selection values
/// \param theToValidate a validation flag
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Returns list of widget controls
virtual void setHighlighted(bool) { /*do nothing*/ };
virtual void enableFocusProcessing();
- static bool canFillSketch(const ModuleBase_ViewerPrs& thePrs);
+ static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
static bool fillSketchPlaneBySelection(const FeaturePtr& theFeature,
- const ModuleBase_ViewerPrs& thePrs);
+ const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
signals:
/// Signal on plane selection
/// Fills the attribute with the value of the selected owner
/// \param thePrs a selected owner
- virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Saves the internal parameters to the given feature
/// \return True in success
/// It is redefined to do nothing if the plane of the sketch has been already set.
/// \param theValues the wrapped selection values
/// \param theToValidate a validation flag
- bool setSelectionInternal(const QList<ModuleBase_ViewerPrs>& theValues,
+ bool setSelectionInternal(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
const bool theToValidate);
/// Erase preview planes, disconnect widget, change the view projection
/// \param thePrs a selected presentation
- void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs);
+ void updateByPlaneSelected(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
protected:
/// Activate or deactivate selection
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- QList<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
if (aPrsList.size() > 0) {
bool isVisible = false;
bool isShading = false;
bool canBeShaded = false;
ObjectPtr aObject;
- foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
- aObject = aPrs.object();
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
+ aObject = aPrs->object();
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aRes && aRes->isDisplayed()) {
isVisible = true;
theMenu->addSeparator();
}
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QList<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
int aSelected = aPrsList.size();
QActionsList aActions;
theMenu->addSeparator();
}
if (aSelected == 1) {
- ObjectPtr aObject = aPrsList.first().object();
+ ObjectPtr aObject = aPrsList.first()->object();
if (aObject.get() != NULL) {
std::string aName = aObject->groupName();
if (myViewerMenu.contains(aName))
aContext->ActivatedModes(anAIS, aModes);
return aModes.Extent() > 0;
}
-void XGUI_Displayer::setSelected(const QList<ModuleBase_ViewerPrs>& theValues, bool theUpdateViewer)
+void XGUI_Displayer::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues, bool theUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
if (aContext->HasOpenedContext()) {
aContext->UnhilightSelected(false);
aContext->ClearSelected(false);
- foreach (ModuleBase_ViewerPrs aPrs, theValues) {
- const GeomShapePtr& aGeomShape = aPrs.shape();
+ foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
+ const GeomShapePtr& aGeomShape = aPrs->shape();
if (aGeomShape.get() && !aGeomShape->isNull()) {
const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
aContext->AddOrRemoveSelected(aShape, false);
} else {
- ObjectPtr anObject = aPrs.object();
+ ObjectPtr anObject = aPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get() && isVisible(aResult)) {
AISObjectPtr anObj = myResult2AISObjectMap[aResult];
} else {
aContext->UnhilightCurrents(false);
aContext->ClearCurrents(false);
- foreach (ModuleBase_ViewerPrs aPrs, theValues) {
- ObjectPtr anObject = aPrs.object();
+ foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
+ ObjectPtr anObject = aPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get() && isVisible(aResult)) {
AISObjectPtr anObj = myResult2AISObjectMap[aResult];
/// empty, select it, otherwise select the result.
/// \param theValues a list of presentation to be selected
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
- void setSelected(const QList<ModuleBase_ViewerPrs>& theValues, bool theUpdateViewer = true);
+ void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues, bool theUpdateViewer = true);
/// Unselect all objects
void clearSelected();
return anObject;
}
-void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrs>& theValues)
+void XGUI_ModuleConnector::setSelected(const QList<ModuleBase_ViewerPrsPtr>& theValues)
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
if (theValues.isEmpty()) {
//! Select features clearing previous selection.
//! If the list is empty then selection will be cleared
- virtual void setSelected(const QList<ModuleBase_ViewerPrs>& theValues);
+ virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Update of commands status
virtual void updateCommandStatus();
{
}
-QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(const SelectionPlace& thePlace) const
+QList<ModuleBase_ViewerPrsPtr> XGUI_Selection::getSelected(const SelectionPlace& thePlace) const
{
- QList<ModuleBase_ViewerPrs> aPresentations;
+ QList<ModuleBase_ViewerPrsPtr> aPresentations;
switch (thePlace) {
case Browser:
return aPresentations;
}
-Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrs& thePrs)
+Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrsPtr& thePrs)
{
- Handle(AIS_InteractiveObject) anIO = thePrs.interactive();
+ Handle(AIS_InteractiveObject) anIO = thePrs->interactive();
if (anIO.IsNull()) {
- Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner();
+ Handle(SelectMgr_EntityOwner) anOwner = thePrs->owner();
if (!anOwner.IsNull())
anIO = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
- if (anIO.IsNull() && thePrs.object()) {
+ if (anIO.IsNull() && thePrs->object()) {
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- AISObjectPtr anAISObject = aDisplayer->getAISObject(thePrs.object());
+ AISObjectPtr anAISObject = aDisplayer->getAISObject(thePrs->object());
if (anAISObject.get())
anIO = anAISObject->impl<Handle(AIS_InteractiveObject)>();
}
return anIO;
}
-void XGUI_Selection::getSelectedInViewer(QList<ModuleBase_ViewerPrs>& thePresentations) const
+void XGUI_Selection::getSelectedInViewer(QList<ModuleBase_ViewerPrsPtr>& thePresentations) const
{
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull() && aContext->HasOpenedContext()) {
QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
- ModuleBase_ViewerPrs aPrs;
+ ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
if (aSelectedIds.contains((long)anOwner.Access()))
}
}
-void XGUI_Selection::getSelectedInBrowser(QList<ModuleBase_ViewerPrs>& thePresentations) const
+void XGUI_Selection::getSelectedInBrowser(QList<ModuleBase_ViewerPrsPtr>& thePresentations) const
{
// collect the objects of the parameter presentation to avoid a repeted objects in the result
QObjectPtrList aPresentationObjects;
- QList<ModuleBase_ViewerPrs>::const_iterator aPrsIt = thePresentations.begin(),
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator aPrsIt = thePresentations.begin(),
aPrsLast = thePresentations.end();
for (; aPrsIt != aPrsLast; aPrsIt++) {
- aPresentationObjects.push_back((*aPrsIt).object());
+ aPresentationObjects.push_back((*aPrsIt)->object());
}
QObjectPtrList anObjects = selectedObjects();
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (anObject.get() != NULL && !aPresentationObjects.contains(anObject)) {
- thePresentations.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
+ thePresentations.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)));
}
}
}
-void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
+void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs,
const Handle(SelectMgr_EntityOwner)& theOwner) const
{
- thePrs.setOwner(theOwner);
+ thePrs->setOwner(theOwner);
Handle(AIS_InteractiveObject) anIO =
Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
- thePrs.setInteractive(anIO);
+ thePrs->setInteractive(anIO);
// we should not check the appearance of this feature because there can be some selected shapes
// for one feature
if (!aShape.IsNull()) {
std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aGeomShape->setImpl(new TopoDS_Shape(aShape));
- thePrs.setShape(aGeomShape);
+ thePrs->setShape(aGeomShape);
}
} else {
#ifdef DEBUG_DELIVERY
if (!aEdge.IsNull()) {
std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aGeomShape->setImpl(new TopoDS_Shape(aEdge));
- thePrs.setShape(aGeomShape);
+ thePrs->setShape(aGeomShape);
}
} else {
Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO);
if (!aVertex.IsNull()) {
std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aGeomShape->setImpl(new TopoDS_Shape(aVertex));
- thePrs.setShape(aGeomShape);
+ thePrs->setShape(aGeomShape);
}
}
}
ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult);
if (aCompSolid.get()) {
GeomShapePtr aShape = aCompSolid->shape();
- if (aShape.get() && aShape->isEqual(thePrs.shape())) {
- thePrs.setObject(aCompSolid);
+ if (aShape.get() && aShape->isEqual(thePrs->shape())) {
+ thePrs->setObject(aCompSolid);
return;
}
}
}
}
- thePrs.setObject(aFeature);
+ thePrs->setObject(aFeature);
}
-QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted() const
+QList<ModuleBase_ViewerPrsPtr> XGUI_Selection::getHighlighted() const
{
- QList<ModuleBase_ViewerPrs> aPresentations;
+ QList<ModuleBase_ViewerPrsPtr> aPresentations;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (aContext.IsNull())
return aPresentations;
QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
- ModuleBase_ViewerPrs aPrs;
+ ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
if (aSelectedIds.contains((long)anIO.Access()))
continue;
aSelectedIds.append((long)anIO.Access());
- aPrs.setInteractive(anIO);
+ aPrs->setInteractive(anIO);
ObjectPtr aResult = aDisplayer->getObject(anIO);
// we should not check the appearance of this feature because there can be some selected shapes
// for one feature
- aPrs.setObject(aResult);
+ aPrs->setObject(aResult);
if (aContext->HasOpenedContext()) {
TopoDS_Shape aShape = aContext->DetectedShape();
if (!aShape.IsNull()) {
std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aGeomShape->setImpl(new TopoDS_Shape(aShape));
- aPrs.setShape(aGeomShape);
+ aPrs->setShape(aGeomShape);
}
}
aPresentations.push_back(aPrs);
/// Returns a list of viewer selected presentations
/// \return list of presentations
- virtual QList<ModuleBase_ViewerPrs> getSelected(const SelectionPlace& thePlace = Browser) const;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getSelected(const SelectionPlace& thePlace = Browser) const;
/// Fills the viewer presentation parameters by the parameters from the owner
/// \param thePrs a container for selection
/// \param theOwner a selection owner
- virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs,
+ virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
const Handle_SelectMgr_EntityOwner& theOwner) const;
/// Returns a list of viewer highlited presentations
/// \return list of presentations
- virtual QList<ModuleBase_ViewerPrs> getHighlighted() const;
+ virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const;
/**
* Returns list of currently selected objects in object browser
//! Return the IO from the viewer presentation.
//! \param thePrs a selected object
//! \return an interactive object
- virtual Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs);
+ virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
protected:
/// Fills the list of presentations by objects selected in the viewer.
/// \param thePresentations an output list of presentation
- void getSelectedInViewer(QList<ModuleBase_ViewerPrs>& thePresentations) const;
+ void getSelectedInViewer(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
/// Fills the list of presentations by objects selected in the object browser.
/// ViewerPrs contains only object parameter not empty.
/// If the given list of presentations already has a viewer presentation with the same object
/// as selected in the browser, a new item is not appended to the list of presentations.
/// \param thePresentations an output list of presentation
- void getSelectedInBrowser(QList<ModuleBase_ViewerPrs>& thePresentations) const;
+ void getSelectedInBrowser(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& thePresentations) const;
/// Generates a vertex or edge by the give IO if it is an AIS created on trihedron
/// \param theIO a selected object
//**************************************************************
void XGUI_SelectionMgr::onObjectBrowserSelection()
{
- QList<ModuleBase_ViewerPrs> aSelectedPrs =
+ QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser);
- QList<ModuleBase_ViewerPrs> aTmpList = aSelectedPrs;
+ QList<ModuleBase_ViewerPrsPtr> aTmpList = aSelectedPrs;
ObjectPtr aObject;
FeaturePtr aFeature;
- foreach(ModuleBase_ViewerPrs aPrs, aTmpList) {
- aObject = aPrs.object();
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aTmpList) {
+ aObject = aPrs->object();
if (aObject.get()) {
aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
if (aFeature.get()) {
const std::list<std::shared_ptr<ModelAPI_Result>> aResList = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
- aSelectedPrs.append(ModuleBase_ViewerPrs((*aIt), GeomShapePtr(), NULL));
+ aSelectedPrs.append(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs((*aIt), GeomShapePtr(), NULL)));
}
}
}
FeaturePtr aFeature;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull()) {
- QList<ModuleBase_ViewerPrs> aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer);
- foreach(ModuleBase_ViewerPrs aPrs, aPresentations) {
+ QList<ModuleBase_ViewerPrsPtr> aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer);
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aPresentations) {
if (aPrs.object().get()) {
aFeatures.append(aPrs.object());
if (aPrs.shape().get()) {
//**************************************************************
void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace)
{
- QList<ModuleBase_ViewerPrs> aSelectedPrs =
+ QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
myWorkshop->selector()->selection()->getSelected(thePlace);
if (thePlace == ModuleBase_ISelection::Browser) {
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
myWorkshop->objectBrowser()->blockSignals(aBlocked);
- QList<ModuleBase_ViewerPrs> aSelectedPrs =
+ QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser);
XGUI_Displayer* aDisplayer = myWorkshop->displayer();