//return true;
}
-//********************************************************************
-void PartSet_WidgetFeaturePointSelector::updateSelectionModesAndFilters(bool toActivate)
-{
-#ifdef HIGHLIGHT_STAYS_PROBLEM
- Handle(AIS_InteractiveContext) aContext =
- XGUI_Tools::workshop(myWorkshop)->viewer()->AISContext();
- Quantity_Color aColor;
- Handle(Prs3d_Drawer) aHStyle = aContext->HighlightStyle();
- Handle(Prs3d_Drawer) aSStyle = aContext->SelectionStyle();
- if (toActivate) {
- std::vector<int> aColors;
- aColors = Config_PropManager::color("Visualization", "sketch_entity_color");
- aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255.,
- Quantity_TOC_RGB);
- myHighlightColor = aHStyle->Color();
- mySelectionColor = aSStyle->Color();
- }
- else {
- aColor = myHighlightColor;
- }
- aHStyle->SetColor(aColor);
- aContext->SetHighlightStyle(aHStyle);
-
- aSStyle->SetColor(aColor);
- aContext->SetSelectionStyle(aSStyle);
-
-#endif
-
- ModuleBase_WidgetShapeSelector::updateSelectionModesAndFilters(toActivate);
-}
-
//********************************************************************
void PartSet_WidgetFeaturePointSelector::activateCustom()
{
ModuleBase_ViewerPrsPtr aPrs = !aHighlighted.empty() ? aHighlighted.first()
: ModuleBase_ViewerPrsPtr();
- fillFeature(aPrs, theWindow, theEvent);
+ myPreviewPoint = PartSet_Tools::getPnt2d(theEvent, theWindow, mySketch);
+ if (myHasPreview) {
+ if (aPrs.get() && aPrs->object().get())
+ myPreviewObject = aPrs->object();
+ else
+ myPreviewObject = ObjectPtr();
+ fillFeature();
+ updateObject(feature());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ }
}
//********************************************************************
return;
// Do not use non-sketcher objects
- if (!sketch()->isSub(myPreviewObject))
+ if (!sketch()->isSub(aPreviewObject))
return;
// set parameters of preview into parameters of selection in the feature
}
//********************************************************************
-bool PartSet_WidgetFeaturePointSelector::fillFeature(
- const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
- ModuleBase_IViewWindow* theWindow,
- QMouseEvent* theEvent)
+bool PartSet_WidgetFeaturePointSelector::fillFeature()
{
- bool aFilled = false;
- if (theSelectedPrs.get() && theSelectedPrs->object().get())
- myPreviewObject = theSelectedPrs->object();
- myPreviewPoint = PartSet_Tools::getPnt2d(theEvent, theWindow, mySketch);
-
if (myHasPreview) {
std::shared_ptr<ModelAPI_AttributeReference> aRef =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(
feature()->data()->attribute(myPreviewObjectAttribute));
aRef->setValue(myPreviewObject);
-
- std::shared_ptr<GeomDataAPI_Point2D> anAttributePoint =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- feature()->data()->attribute(myPreviewPointAttribute));
- anAttributePoint->setValue(myPreviewPoint);
+ if (myPreviewPoint.get()) {
+ std::shared_ptr<GeomDataAPI_Point2D> anAttributePoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(myPreviewPointAttribute));
+ anAttributePoint->setValue(myPreviewPoint);
+ }
+ }
+ else {
+ // Do not use non-sketcher objects
+ if (!sketch()->isSub(myPreviewObject))
+ return false;
+
+ // set parameters of preview into parameters of selection in the feature
+ if (myPreviewPoint.get()) {
+ std::shared_ptr<GeomDataAPI_Point2D> aPointSelectedAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ feature()->data()->attribute(mySelectedPointAttribute));
+ aPointSelectedAttr->setValue(myPreviewPoint);
+ }
+ AttributeReferencePtr aRefSelectedAttr = feature()->reference(mySelectedObjectAttribute);
+ if (aRefSelectedAttr)
+ aRefSelectedAttr->setValue(myPreviewObject);
+ else {
+ AttributeRefAttrPtr aRefAttrSelectedAttr = feature()->refattr(mySelectedObjectAttribute);
+ if (aRefAttrSelectedAttr)
+ aRefAttrSelectedAttr->setObject(myPreviewObject);
+ }
}
// redisplay AIS presentation in viewer
#ifndef HIGHLIGHT_STAYS_PROBLEM
// an attempt to clear highlighted item in the viewer: but of OCCT
XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true);
#endif
- updateObject(feature());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-
- aFilled = true;
-
- return aFilled;
+ return true;
}
//********************************************************************
}
//********************************************************************
-bool PartSet_WidgetFeaturePointSelector::setSelection(
- QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
- const bool theToValidate)
+bool PartSet_WidgetFeaturePointSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
- // false is returned to do not emit focus out widget by selected sub-shape
- return false;
+ if (!thePrs.get() || !thePrs->object().get())
+ return false;
+
+ ModuleBase_ISelection* aSelection = myWorkshop->selection();
+ myPreviewObject = aSelection->getResult(thePrs);
+ GeomShapePtr aShape = aSelection->getShape(thePrs);
+ myExternalObjectMgr->getGeomSelection(thePrs, myPreviewObject, aShape, myWorkshop,
+ sketch(), true);
+ return fillFeature();
}
+//********************************************************************
void PartSet_WidgetFeaturePointSelector::setPreSelection(
- const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
+ const ModuleBase_ViewerPrsPtr& thePreSelected,
ModuleBase_IViewWindow* theWnd,
QMouseEvent* theEvent)
{
#include <ModelAPI_CompositeFeature.h>
#include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_ViewerPrs.h>
#include "PartSet.h"
#include "PartSet_MouseProcessor.h"
/// \return a boolean value
virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
- /// Activate or deactivate selection and selection filters
- /// \return true if the selection filter of the widget is activated in viewer context
- virtual void updateSelectionModesAndFilters(bool toActivate);
-
/// Set sketcher
/// \param theSketch a sketcher object
void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
/// \param theEvent a mouse event
virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
- /// Set the given wrapped value to the current widget
- /// This value should be processed in the widget according to the needs
- /// The method is called by the current operation to process the operation preselection.
- /// It is redefined to fill attributes responsible for the sub selection
- /// \param theValues the wrapped selection values
- /// \param theToValidate a flag on validation of the values
- virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
- const bool theToValidate);
+
+ /// Fills the attribute with the value of the selected owner
+ /// \param thePrs a selected owner
+ virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
/// Fill preselection used in mouseReleased
- virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
+ virtual void setPreSelection(const ModuleBase_ViewerPrsPtr& thePreSelected,
ModuleBase_IViewWindow* theWnd,
QMouseEvent* theEvent);
protected:
void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
protected:
- bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
- ModuleBase_IViewWindow* theWnd,
- QMouseEvent* theEvent);
+ bool fillFeature();
/// Pointer to a sketch
CompositeFeaturePtr mySketch;