TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
Set(aShape);
+ // Activate individual repaintng if this is a part of compsolid
+ ResultBodyPtr aResOwner = ModelAPI_Tools::bodyOwner(myResult);
+ SetAutoHilight(aResOwner.get() == NULL);
+
+ init();
+}
+
+//********************************************************************
+ModuleBase_ResultPrs::ModuleBase_ResultPrs(FieldStepPtr theStep)
+ : ViewerData_AISShape(TopoDS_Shape()), myStep(theStep), myAdditionalSelectionPriority(0),
+ myTransparency(1), myIsSubstituted(false)
+{
+ GeomShapePtr aShapePtr = theStep->field()->shape();
+ TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
+ Set(aShape);
+
+ init();
+}
+
+
+//********************************************************************
+void ModuleBase_ResultPrs::init()
+{
// Set own free boundaries aspect in order to have free
// and unfree boundaries with different colors
Handle(Prs3d_Drawer) aDrawer = Attributes();
else
aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
- // Activate individual repaintng if this is a part of compsolid
- ResultBodyPtr aResOwner = ModelAPI_Tools::bodyOwner(myResult);
- SetAutoHilight(aResOwner.get() == NULL);
-
- myHiddenSubShapesDrawer = new AIS_ColoredDrawer (myDrawer);
+ myHiddenSubShapesDrawer = new AIS_ColoredDrawer(myDrawer);
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
aShadingAspect->SetMaterial(Graphic3d_NOM_BRASS); //default value of context material
myHiddenSubShapesDrawer->SetShadingAspect(aShadingAspect);
setEdgesDefaultColor();
}
+
//********************************************************************
void ModuleBase_ResultPrs::setAdditionalSelectionPriority(const int thePriority)
{
void ModuleBase_ResultPrs::setEdgesDefaultColor()
{
- AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
-
- if (!aHasColor) {
- Handle(Prs3d_Drawer) aDrawer = Attributes();
- Handle(Prs3d_LineAspect) anAspect; // = aDrawer->LineAspect();
- //anAspect->SetColor(Quantity_NOC_YELLOW);
- //aDrawer->SetLineAspect(anAspect);
-
- // - unfree boundaries color
- anAspect = aDrawer->UnFreeBoundaryAspect();
- anAspect->SetColor(Quantity_NOC_YELLOW);
- aDrawer->SetUnFreeBoundaryAspect(anAspect);
- aDrawer->SetUnFreeBoundaryDraw(true);
-
- // - free boundaries color
- anAspect = aDrawer->FreeBoundaryAspect();
- anAspect->SetColor(Quantity_NOC_GREEN);
- aDrawer->SetFreeBoundaryAspect(anAspect);
- aDrawer->SetFreeBoundaryDraw(true);
-
- // - standalone edges color
- anAspect = aDrawer->WireAspect();
- anAspect->SetColor(Quantity_NOC_RED);
- aDrawer->SetWireAspect(anAspect);
+ if (myResult.get()) {
+ AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
+
+ if (!aHasColor) {
+ Handle(Prs3d_Drawer) aDrawer = Attributes();
+ Handle(Prs3d_LineAspect) anAspect; // = aDrawer->LineAspect();
+ //anAspect->SetColor(Quantity_NOC_YELLOW);
+ //aDrawer->SetLineAspect(anAspect);
+
+ // - unfree boundaries color
+ anAspect = aDrawer->UnFreeBoundaryAspect();
+ anAspect->SetColor(Quantity_NOC_YELLOW);
+ aDrawer->SetUnFreeBoundaryAspect(anAspect);
+ aDrawer->SetUnFreeBoundaryDraw(true);
+
+ // - free boundaries color
+ anAspect = aDrawer->FreeBoundaryAspect();
+ anAspect->SetColor(Quantity_NOC_GREEN);
+ aDrawer->SetFreeBoundaryAspect(anAspect);
+ aDrawer->SetFreeBoundaryDraw(true);
+
+ // - standalone edges color
+ anAspect = aDrawer->WireAspect();
+ anAspect->SetColor(Quantity_NOC_RED);
+ aDrawer->SetWireAspect(anAspect);
+ }
}
}
return true;
}
+//********************************************************************
+GeomShapePtr ModuleBase_ResultPrs::getOriginalShape() const
+{
+ if (myStep.get())
+ return myStep->field()->shape();
+ return myResult->shape();
+}
+
//********************************************************************
void ModuleBase_ResultPrs::Compute(
const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
- std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = getOriginalShape();
bool aReadyToDisplay = aShapePtr.get();
if (aReadyToDisplay) {
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
aReadyToDisplay = false;
}
}
- // change deviation coefficient to provide more precise circle
- //ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
try {
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
}
}
// visualize hidden sub-shapes transparent
- if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
- {
- StdPrs_ShadedShape::Add (thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
- aReadyToDisplay = true;
- }
+ if (myResult.get()) {
+ if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
+ {
+ StdPrs_ShadedShape::Add(thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
+ aReadyToDisplay = true;
+ }
- if (!aReadyToDisplay) {
- Events_InfoMessage("ModuleBase_ResultPrs",
- "An empty AIS presentation: ModuleBase_ResultPrs").send();
- static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
- ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
+ if (!aReadyToDisplay) {
+ Events_InfoMessage("ModuleBase_ResultPrs",
+ "An empty AIS presentation: ModuleBase_ResultPrs").send();
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
+ ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
+ }
}
}
#include "ModuleBase.h"
#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultField.h>
#include <BRep_Builder.hxx>
#include <NCollection_List.hxx>
/// \param theResult a result object
Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
+ /// Constructor
+ /// \param theResult a result object
+ Standard_EXPORT ModuleBase_ResultPrs(FieldStepPtr theStep);
+
//! Method which draws selected owners ( for fast presentation draw )
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
const SelectMgr_SequenceOfOwner& theOwners);
void setEdgesDefaultColor();
+ void init();
+
+ GeomShapePtr getOriginalShape() const;
+
private:
/// Reference to result object
ResultPtr myResult;
+ /// Reference to step object (initialised is only or step or result)
+ FieldStepPtr myStep;
+
/// Original shape of the result object
TopoDS_Shape myOriginalShape;
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultField.h>
#include <ModuleBase_BRepOwner.h>
#include <ModuleBase_IModule.h>
//#define DEBUG_FEATURE_REDISPLAY
//#define DEBUG_SELECTION_FILTERS
-//#define DEBUG_COMPOSILID_DISPLAY
-
//#define DEBUG_OCCT_SHAPE_SELECTION
#define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
{
bool aDisplayed = false;
if (isVisible(theObject)) {
-#ifdef DEBUG_COMPOSILID_DISPLAY
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
- if (aCompsolidResult.get()) {
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- ResultPtr aSubResult = aCompsolidResult->subResult(i);
- if (aSubResult.get())
- redisplay(aSubResult, false);
- }
- if (theUpdateViewer)
- updateViewer();
- }
- else
-#endif
aDisplayed = redisplay(theObject, theUpdateViewer);
} else {
AISObjectPtr anAIS;
aScreen->setViewScale(getViewScale());
}
anAIS = aPrs->getAISObject(anAIS);
- //if (anAIS.get()) {
- // correct deviation coefficient for
- /*Handle(AIS_InteractiveObject) anAISPrs = anAIS->impl<Handle(AIS_InteractiveObject)>();
- if (!anAISPrs.IsNull()) {
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
- if (!aShapePrs.IsNull()) {
- TopoDS_Shape aShape = aShapePrs->Shape();
- if (!aShape.IsNull())
- //ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, anAISPrs->Attributes());
- }
- }*/
- //}
} else {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get() != NULL) {
-#ifdef DEBUG_COMPOSILID_DISPLAY
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
- if (aCompsolidResult.get()) {
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- ResultPtr aSubResult = aCompsolidResult->subResult(i);
- if (aSubResult.get())
- display(aSubResult, false);
- }
- if (theUpdateViewer)
- updateViewer();
- }
- else {
-#endif
- std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- if (aShapePtr.get() != NULL) {
- anAIS = AISObjectPtr(new GeomAPI_AISObject());
- Handle(AIS_InteractiveObject) anAISPrs =
- myWorkshop->module()->createPresentation(aResult);
- if (anAISPrs.IsNull())
- anAISPrs = new ModuleBase_ResultPrs(aResult);
- else {
- Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
- if (!aShapePrs.IsNull())
- ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*) aShapePrs.get());
+ anAIS = createPresentation(aResult);
+ isShading = true;
+ }
+ else {
+ FieldStepPtr aStep =
+ std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
+ if (aStep) {
+ GeomShapePtr aShapePtr = aStep->field()->shape();
+ if (aShapePtr.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAISPrs = new ModuleBase_ResultPrs(aStep);
+ anAIS = AISObjectPtr(new GeomAPI_AISObject());
+ anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+ isShading = true;
}
- anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
- //anAIS->createShape(aShapePtr);
- isShading = true;
}
-#ifdef DEBUG_COMPOSILID_DISPLAY
- } // close else
-#endif
}
}
if (anAIS)
return aDisplayed;
}
+
+//**************************************************************
+AISObjectPtr XGUI_Displayer::createPresentation(const ResultPtr& theResult) const
+{
+ AISObjectPtr anAIS;
+ if (theResult.get() != NULL) {
+ std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+ if (aShapePtr.get() != NULL) {
+ anAIS = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(AIS_InteractiveObject) anAISPrs =
+ myWorkshop->module()->createPresentation(theResult);
+ if (anAISPrs.IsNull())
+ anAISPrs = new ModuleBase_ResultPrs(theResult);
+ else {
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
+ if (!aShapePrs.IsNull())
+ ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
+ }
+ anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+ }
+ }
+ return anAIS;
+}
+
+
//**************************************************************
bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
{
const NCollection_DataMap<TopoDS_Shape,
NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
-protected:
+private:
XGUI_SelectionActivate* selectionActivate() const;
-protected:
+ AISObjectPtr createPresentation(const ResultPtr& theResult) const;
+
+private:
XGUI_Workshop* myWorkshop; ///< Reference to workshop
#ifdef TINSPECTOR
Handle(VInspectorAPI_CallBack) myVCallBack;
void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
{
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+
XGUI_DataModel* aModel = dataModel();
ObjectPtr aObj = aModel->object(theIndex);
if (aObj.get()) {
- ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
- if (aResObj.get()) {
- std::set<ObjectPtr> anObjects;
- anObjects.insert(aResObj);
-
- bool hasHiddenState = aModel->hasHiddenState(theIndex);
- if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
- return;
- if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
- if (aResObj->isDisplayed())
- aResObj->setDisplayed(false);
- aResObj->setDisplayed(true);
+ ResultFieldPtr aField = std::dynamic_pointer_cast<ModelAPI_ResultField>(aObj);
+ if (aField.get()) {
+ bool toDisplay = !aField->isDisplayed();
+ aField->setDisplayed(toDisplay);
+ if (toDisplay) {
+ for (int i = 0; i < aField->stepsSize(); i++) {
+ aField->step(i)->setDisplayed(false);
+ // TODO: Sending events has to be removed when step will be defined as Object
+ aECreator->sendUpdated(aField->step(i), EVENT_DISP);
+ }
}
- else
- aResObj->setDisplayed(!aResObj->isDisplayed());
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- update(theIndex);
}
else {
FieldStepPtr aStep =
std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
if (aStep.get()) {
// Only one step from a field can be visible at once
- int aId = aStep->id();
- ModelAPI_ResultField* aField = aStep->field();
- aField->setDisplayed(false);
- for (int i = 0; i < aField->stepsSize(); i++) {
- aField->step(i)->setDisplayed(i == aId);
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- aECreator->sendUpdated(aField->step(i), EVENT_DISP);
+ bool toDisplay = !aStep->isDisplayed();
+ if (toDisplay) {
+ int aId = aStep->id();
+ ModelAPI_ResultField* aField = aStep->field();
+ aField->setDisplayed(false);
+ for (int i = 0; i < aField->stepsSize(); i++) {
+ aField->step(i)->setDisplayed(i == aId);
+ // TODO: Sending events has to be removed when step will be defined as Object
+ aECreator->sendUpdated(aField->step(i), EVENT_DISP);
+ }
+ }
+ else {
+ aStep->setDisplayed(false);
+ aECreator->sendUpdated(aStep, EVENT_DISP);
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
+ else {
+ ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResObj.get()) {
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(aResObj);
+
+ bool hasHiddenState = aModel->hasHiddenState(theIndex);
+ if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+ return;
+ if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
+ if (aResObj->isDisplayed())
+ aResObj->setDisplayed(false);
+ aResObj->setDisplayed(true);
+ }
+ else
+ aResObj->setDisplayed(!aResObj->isDisplayed());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ }
+ }
}
// Update list of selected objects because this event happens after
// selection event in object browser
if (aObjBrowser) {
aObjBrowser->onSelectionChanged();
}
+ update(theIndex);
}
}
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
#include <ModuleBase_Events.h>
#include <ModuleBase_IModule.h>
ObjectPtr aObj = (*aIt);
// Hide the object if it is invalid or concealed one
- bool aHide = !aObj->data() || !aObj->data()->isValid() ||
- aObj->isDisabled() || (!aObj->isDisplayed());
+ //bool aHide = !aObj->data() || !aObj->data()->isValid() ||
+ // aObj->isDisabled() || (!aObj->isDisplayed());
+ // TODO: Remove the Hide code as soon as a fields step will become as object
+ bool aHide = false;
+ if (aObj->groupName() == ModelAPI_ResultField::ModelAPI_FieldStep::group())
+ aHide = !aObj->isDisplayed();
+ else
+ aHide = !aObj->data() || !aObj->data()->isValid() ||
+ aObj->isDisabled() || (!aObj->isDisplayed());
+
if (!aHide) { // check that this is not hidden result
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
aHide = aRes && aRes->isConcealed();