return new ModuleBase_OperationFeature(theFeatureId.c_str(), this);
}
-bool ModuleBase_IModule::customizeObject(ObjectPtr theObject, const bool theUpdateViewer)
+bool ModuleBase_IModule::customizeObject(ObjectPtr theObject,
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer)
{
return false;
}
{\r
Q_OBJECT\r
public:\r
+ /// enumeration to know which objects should be customized\r
+ enum ModuleBase_CustomizeFlag {\r
+ CustomizeDependedAndResults = 0x00000000,\r
+ CustomizeHighlightedObjects = 0x00000001,\r
+ CustomizeAllObjects = CustomizeDependedAndResults | CustomizeHighlightedObjects\r
+ };\r
\r
/// Constructor\r
/// \param theParent instance of workshop interface\r
* If the object is result with the color attribute value set, it is used,\r
* otherwise the customize is applyed to the object's feature if it is a custom prs\r
* \param theObject an object instance\r
+ * \param theFlag a flag of level of customization, which means that only part of sub-elements\r
+ * should be updated(e.g. only highlighted elements)\r
* \param theUpdateViewer the parameter whether the viewer should be update immediately\r
* \returns true if the object is modified\r
*/\r
- virtual bool customizeObject(ObjectPtr theObject, const bool theUpdateViewer);\r
+ virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,\r
+ const bool theUpdateViewer);\r
\r
/// This method is called on object browser creation for customization of module specific features\r
/// \param theObjectBrowser a pinter on Object Browser widget\r
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) {};
+
/// Restore value from attribute data to the widget's control. Emits signals before and after store
/// \return True in success
bool restoreValue();
#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_Definitions.h>
+#include <ModuleBase_IModule.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
return isDone;
}
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::getHighlighted(QList<ModuleBase_ViewerPrs>& theValues)
+{
+ std::set<int> anAttributeIds;
+ getSelectedAttributeIndices(anAttributeIds);
+ if (!anAttributeIds.empty())
+ convertIndicesToViewerSelection(anAttributeIds, theValues);
+}
+
//********************************************************************
bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
QList<ModuleBase_ViewerPrs> ModuleBase_WidgetMultiSelector::getAttributeSelection() const
{
QList<ModuleBase_ViewerPrs> aSelected;
- // Restore selection in the viewer by the attribute selection list
- if(myFeature) {
- AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
- if (aSelectionListAttr.get()) {
- for (int i = 0; i < aSelectionListAttr->size(); i++) {
- AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- ResultPtr anObject = anAttr->context();
- if (anObject.get()) {
- TopoDS_Shape aShape;
- std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
- if (aShapePtr.get()) {
- aShape = aShapePtr->impl<TopoDS_Shape>();
- }
- aSelected.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
- }
- }
- }
- else {
- AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
- if (aRefListAttr.get()) {
- for (int i = 0; i < aRefListAttr->size(); i++) {
- ObjectPtr anObject = aRefListAttr->object(i);
- if (anObject.get()) {
- aSelected.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
- }
- }
- }
- }
- }
+ convertIndicesToViewerSelection(std::set<int>(), aSelected);
return aSelected;
}
void ModuleBase_WidgetMultiSelector::onDeleteItem()
{
// find attribute indices to delete
- QList<QListWidgetItem*> aItems = myListControl->selectedItems();
std::set<int> anAttributeIds;
- foreach(QListWidgetItem* anItem, aItems) {
- int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
- if (anAttributeIds.find(anIndex) == anAttributeIds.end())
- anAttributeIds.insert(anIndex);
- }
+ getSelectedAttributeIndices(anAttributeIds);
+
// refill attribute by the items which indices are not in the list of ids
bool aDone = false;
AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
if (aDone) {
restoreValue();
myWorkshop->setSelected(getAttributeSelection());
+
+ myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeAllObjects, true);
}
}
QList<QListWidgetItem*> aItems = myListControl->selectedItems();
myCopyAction->setEnabled(!aItems.isEmpty());
myDeleteAction->setEnabled(!aItems.isEmpty());
-
- //myWorkshop->setSelected(>setSelected(getAttributeSelection());
- QList<ModuleBase_ViewerPrs> aSelectedItems;
- emit itemsSelected(aSelectedItems);
+ myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
+ true);
+}
+
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::getSelectedAttributeIndices(std::set<int>& theAttributeIds)
+{
+ QList<QListWidgetItem*> aItems = myListControl->selectedItems();
+ foreach(QListWidgetItem* anItem, aItems) {
+ int anIndex = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
+ if (theAttributeIds.find(anIndex) == theAttributeIds.end())
+ theAttributeIds.insert(anIndex);
+ }
+}
+
+void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
+ QList<ModuleBase_ViewerPrs>& theValues) const
+{
+ if(myFeature.get() == NULL)
+ return;
+ AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+ if (aSelectionListAttr.get()) {
+ for (int i = 0; i < aSelectionListAttr->size(); i++) {
+ // filter by attribute indices only if the container is not empty otherwise return all items
+ if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
+ continue;
+ AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
+ ResultPtr anObject = anAttr->context();
+ if (anObject.get()) {
+ TopoDS_Shape aShape;
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
+ if (aShapePtr.get()) {
+ aShape = aShapePtr->impl<TopoDS_Shape>();
+ }
+ theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
+ }
+ }
+ }
+ else {
+ AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID());
+ if (aRefListAttr.get()) {
+ for (int i = 0; i < aRefListAttr->size(); i++) {
+ // filter by attribute indices only if the container is not empty otherwise return all items
+ if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end())
+ continue;
+ ObjectPtr anObject = aRefListAttr->object(i);
+ if (anObject.get()) {
+ theValues.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+ }
+ }
+ }
+ }
}
virtual bool setSelection(QList<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);
+
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
/// Slot is called on selection type changed
void onSelectionTypeChanged();
-signals:
- /// Signals about items selected in the list view
- void itemsSelected(const QList<ModuleBase_ViewerPrs>& theItems);
-
protected slots:
/// Slot for copy command in a list pop-up menu
void onCopyItem();
/// For example, the "Edges" is converted to "edge"
std::string validatorType(const QString& theType) const;
+protected:
+ /// Returns attribute indices selected in the widget selection list
+ /// \param theIndices a list of indices
+ void getSelectedAttributeIndices(std::set<int>& theIndices);
+
+ /// Gets the feature attribute and fill a list of viewer presentation for the attribute
+ /// indices. If the the container of indices is empty, it returns all objects.
+ /// \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;
protected:
/// List control
QListWidget* myListControl;
return Handle(PartSet_OperationPrs)::DownCast(anAISIO);
}
-bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject, const bool theUpdateViewer)
+bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject,
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer)
{
#ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
return false;
#include "PartSet_OperationPrs.h"
+#include <ModuleBase_IModule.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_Feature.h>
/// \param theObject an object to redisplay
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
/// \returns true if the presentation is redisplayed
- bool redisplay(const ObjectPtr& theObject, const bool theUpdateViewer);
+ bool redisplay(const ObjectPtr& theObject,
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag, const bool theUpdateViewer);
/// Nullify the operation presentation. For example, it can be useful when the viewer/context
/// is closed. If this is not performed and the presentation is assigned in another context,
SLOT(onViewTransformed(int)));
connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)),
SLOT(onViewCreated(ModuleBase_IViewWindow*)));
-
myMenuMgr = new PartSet_MenuMgr(this);
myCustomPrs = new PartSet_CustomPrs(theWshop);
aDisplayer->updateViewer();
}
-bool PartSet_Module::customizeObject(ObjectPtr theObject, const bool theUpdateViewer)
+bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer)
{
bool isRedisplayed = false;
if (myCustomPrs->isActive())
- isRedisplayed = myCustomPrs->redisplay(theObject, theUpdateViewer);
+ isRedisplayed = myCustomPrs->redisplay(theObject, theFlag, theUpdateViewer);
return isRedisplayed;
}
* If the object is result with the color attribute value set, it is used,
* otherwise the customize is applyed to the object's feature if it is a custom prs
* \param theObject an object instance
+ * \param theFlag a flag of level of customization, which means that only part of sub-elements
+ * should be updated(e.g. only highlighted elements)
* \param theUpdateViewer the parameter whether the viewer should be update immediatelly
* \returns true if the object is modified
*/
- virtual bool customizeObject(ObjectPtr theObject, const bool theUpdateViewer);
+ virtual bool customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
/// This method is called on object browser creation for customisation of module specific features
/// \param theObjectBrowser a pinter on Object Browser widget
return !myFeatureShapes.empty() || !myFeatureResults.empty();
}
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ModelWidget.h>
void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
// create presentations on the base of the shapes
Handle(Prs3d_Drawer) aDrawer = Attributes();
+
QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
aLast = myFeatureShapes.end();
for (; anIt != aLast; anIt++) {
ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
}
+ QList<ModuleBase_ViewerPrs> aValues;
+ ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
+ if (aPanel) {
+ ModuleBase_ModelWidget* aWidget = aPanel->activeWidget();
+ if (aWidget) {
+ aWidget->getHighlighted(aValues);
+ }
+ }
+
+ Standard_Real aPreviousWidth = Width();
+ setWidth(aDrawer, aPreviousWidth+3);
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ Quantity_NameOfColor anHColor = aContext->HilightColor();
+
+ aColor = Quantity_Color(anHColor);
+ aColor = Quantity_Color((1. + aColor.Red())/2., (1. + aColor.Green())/2.,
+ (1. + aColor.Blue())/2., Quantity_TOC_RGB);
+ SetColor(aColor);
+
+ QList<ModuleBase_ViewerPrs>::const_iterator anIIt = aValues.begin(),
+ aILast = aValues.end();
+ for (; anIIt != aILast; anIIt++) {
+ ModuleBase_ViewerPrs aPrs = *anIIt;
+ ObjectPtr anObject = aPrs.object();
+ TopoDS_Shape aShape = aPrs.shape();
+ if (aShape.IsNull()) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ if (aResult.get()) {
+ GeomShapePtr aGeomShape = aResult->shape();
+ if (aGeomShape.get())
+ aShape = aGeomShape->impl<TopoDS_Shape>();
+ }
+ }
+ if (!aShape.IsNull()) {
+ ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
+ StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
+ }
+ }
+ setWidth(aDrawer, aPreviousWidth);
}
void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
if (aFOperation) {
FeaturePtr aCurrentFeature = aFOperation->feature();
if (aCurrentFeature.get())
- aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature, false);
+ aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+ ModuleBase_IModule::CustomizeAllObjects, false);
}
}
return aCustomized;