Removed redundant .lxx files from API package.
AIS_InteractiveContext_1.cxx,AIS_InteractiveContext_2.cxx,AIS_InteractiveContext_3.cxx
have been merged into AIS_InteractiveContext.cxx.
V3d_View_2.cxx,V3d_View_3.cxx,V3d_View_4.cxx have been merged into V3d_View.cxx
V3d_View_4.cxx has been merged into V3d_View.cxx.
//! filters, which are in position when a local context is open.
class AIS_AttributeFilter : public SelectMgr_Filter
{
-
public:
-
-
//! Constructs an empty attribute filter object.
//! This filter object determines whether selectable
//! interactive objects have a non-null owner.
//! Indicates that the Interactive Object has the color
//! setting specified by the argument aCol at construction time.
- Standard_Boolean HasColor() const;
-
+ Standard_Boolean HasColor() const { return hasC; }
//! Indicates that the Interactive Object has the width
//! setting specified by the argument aWidth at
//! construction time.
- Standard_Boolean HasWidth() const;
-
- //! Sets the color aCol.
- //! This must be chosen from the list of colors in Quantity_NameOfColor.
- void SetColor (const Quantity_NameOfColor aCol);
-
- //! Sets the line width aWidth.
- void SetWidth (const Standard_Real aWidth);
-
+ Standard_Boolean HasWidth() const { return hasW; }
+
+ //! Sets the color.
+ void SetColor (const Quantity_NameOfColor theCol)
+ {
+ myCol = theCol;
+ hasC = Standard_True;
+ }
+
+ //! Sets the line width.
+ void SetWidth (const Standard_Real theWidth)
+ {
+ myWid = theWidth;
+ hasW = Standard_True;
+ }
//! Removes the setting for color from the filter.
- void UnsetColor();
-
+ void UnsetColor() { hasC = Standard_False; }
//! Removes the setting for width from the filter.
- void UnsetWidth();
-
+ void UnsetWidth() { hasW = Standard_False; }
+
//! Indicates that the selected Interactive Object passes
//! the filter. The owner, anObj, can be either direct or
//! user. A direct owner is the corresponding
//! the mouse, the object is kept; if not, it is rejected.
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
-
-
-
DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter,SelectMgr_Filter)
-protected:
-
-
-
-
private:
-
Quantity_NameOfColor myCol;
Standard_Real myWid;
Standard_Boolean hasC;
Standard_Boolean hasW;
-
};
-
-#include <AIS_AttributeFilter.lxx>
-
-
-
-
-
#endif // _AIS_AttributeFilter_HeaderFile
+++ /dev/null
-// Created on: 1997-03-04
-// Created by: Robert COUBLANC
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline void AIS_AttributeFilter::SetColor(const Quantity_NameOfColor aCol)
-{myCol = aCol;hasC = Standard_True;}
-
-inline void AIS_AttributeFilter::SetWidth(const Standard_Real aWid)
-{myWid=aWid;hasW = Standard_True;}
-
-inline void AIS_AttributeFilter::UnsetColor()
-{hasC = Standard_False;}
-
-inline void AIS_AttributeFilter::UnsetWidth()
-{hasW = Standard_False;}
-
-inline Standard_Boolean AIS_AttributeFilter::HasColor() const
-{return hasC;}
-
-inline Standard_Boolean AIS_AttributeFilter::HasWidth() const
-{return hasW;}
#include <TColStd_ListOfInteger.hxx>
class SelectMgr_EntityOwner;
-
class AIS_ExclusionFilter;
DEFINE_STANDARD_HANDLE(AIS_ExclusionFilter, SelectMgr_Filter)
Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
Standard_EXPORT void Clear();
-
- Standard_Boolean IsExclusionFlagOn() const;
-
- void SetExclusionFlag (const Standard_Boolean Status);
-
+
+ Standard_Boolean IsExclusionFlagOn() const { return myIsExclusionFlagOn; }
+
+ void SetExclusionFlag (const Standard_Boolean theStatus) { myIsExclusionFlagOn = theStatus; }
+
Standard_EXPORT Standard_Boolean IsStored (const AIS_KindOfInteractive aType) const;
Standard_EXPORT void ListOfStoredTypes (TColStd_ListOfInteger& TheList) const;
Standard_EXPORT void ListOfSignature (const AIS_KindOfInteractive aType, TColStd_ListOfInteger& TheStoredList) const;
-
-
-
DEFINE_STANDARD_RTTIEXT(AIS_ExclusionFilter,SelectMgr_Filter)
-protected:
-
-
-
-
private:
-
Standard_EXPORT Standard_Boolean IsSignatureIn (const AIS_KindOfInteractive aType, const Standard_Integer aSignature) const;
Standard_Boolean myIsExclusionFlagOn;
TColStd_DataMapOfIntegerListOfInteger myStoredTypes;
-
};
-
-#include <AIS_ExclusionFilter.lxx>
-
-
-
-
-
#endif // _AIS_ExclusionFilter_HeaderFile
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline Standard_Boolean AIS_ExclusionFilter::IsExclusionFlagOn() const
-{
- return myIsExclusionFlagOn;
-}
-
-
-inline void AIS_ExclusionFilter::SetExclusionFlag(const Standard_Boolean Status)
-{
- myIsExclusionFlagOn = Status;
-}
-
-
#include <AIS_ConnectedInteractive.hxx>
#include <AIS_GlobalStatus.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_MapIteratorOfMapOfInteractive.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_Trihedron.hxx>
-#include <Geom_Axis2Placement.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
-#include <HLRBRep.hxx>
-#include <OSD_Environment.hxx>
#include <Precision.hxx>
#include <Prs3d_BasicAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_ShadingAspect.hxx>
-#include <PrsMgr_PresentableObject.hxx>
-#include <Quantity_Color.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_OrFilter.hxx>
#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_Atomic.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Type.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
-#include <UnitsAPI.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
+#include <AIS_Shape.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS_Shape.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient)
namespace
{
AIS_ListOfInteractive aList;
ObjectsInside (aList);
- for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next())
+ for (AIS_ListOfInteractive::Iterator aListIterator (aList); aListIterator.More(); aListIterator.Next())
{
Remove (aListIterator.Value(), Standard_False);
}
setObjectStatus (aChild, theStatus, theDispMode, theSelectionMode);
}
}
+
+//=======================================================================
+//function : highlightWithColor
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Handle(V3d_Viewer)& theViewer)
+{
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ if (anObj.IsNull())
+ {
+ return;
+ }
+
+ const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
+
+ myMainPM->BeginImmediateDraw();
+ theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
+ myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
+}
+
+//=======================================================================
+//function : highlightSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
+{
+ AIS_NListOfEntityOwner anOwners;
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ if (anObj.IsNull())
+ {
+ return;
+ }
+
+ if (!theOwner->IsAutoHilight())
+ {
+ SelectMgr_SequenceOfOwner aSeq;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ if (aSelIter.Value()->IsSameSelectable (anObj))
+ {
+ anOwners.Append (aSelIter.Value());
+ }
+ }
+ }
+ else
+ {
+ anOwners.Append (theOwner);
+ }
+ highlightOwners (anOwners, Handle(Prs3d_Drawer)());
+}
+
+//=======================================================================
+//function : highlightGlobal
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Standard_Integer theDispMode)
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
+ const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
+
+ if (aGlobOwner.IsNull())
+ {
+ myMainPM->Color (theObj, theStyle, aHiMode);
+ return;
+ }
+
+ AIS_NListOfEntityOwner anOwners;
+ if (!aGlobOwner->IsAutoHilight())
+ {
+ SelectMgr_SequenceOfOwner aSeq;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ if (aSelIter.Value()->IsSameSelectable (theObj))
+ {
+ anOwners.Append (aSelIter.Value());
+ }
+ }
+ }
+ else
+ {
+ anOwners.Append (aGlobOwner);
+ }
+ highlightOwners (anOwners, theStyle);
+}
+
+//=======================================================================
+//function : unhighlightSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
+{
+ unhighlightOwners (mySelection->Objects(), theIsToHilightSubIntensity);
+}
+
+//=======================================================================
+//function : unhighlightOwners
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
+ const Standard_Boolean theIsToHilightSubIntensity)
+{
+ NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive);
+ if (!aStatusPtr)
+ {
+ continue;
+ }
+
+ if (anOwner->IsAutoHilight())
+ {
+ anOwner->Unhilight (myMainPM);
+ if (theIsToHilightSubIntensity)
+ {
+ if ((*aStatusPtr)->IsSubIntensityOn())
+ {
+ const Standard_Integer aHiMode = getHilightMode (anInteractive, (*aStatusPtr)->HilightStyle(), (*aStatusPtr)->DisplayMode());
+ highlightWithSubintensity (anOwner, aHiMode);
+ }
+ }
+ }
+ else
+ {
+ anObjToClear.Add (anInteractive);
+ }
+ if (anOwner == anInteractive->GlobalSelOwner())
+ {
+ (*aStatusPtr)->SetHilightStatus (Standard_False);
+ }
+ (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
+ }
+ for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
+ myMainPM->Unhighlight (anObj);
+ anObj->ClearSelected();
+ }
+}
+
+//=======================================================================
+//function : unhighlightGlobal
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj)
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
+ if (aGlobOwner.IsNull())
+ {
+ myMainPM->Unhighlight (theObj);
+ return;
+ }
+
+ AIS_NListOfEntityOwner anOwners;
+ anOwners.Append (aGlobOwner);
+ unhighlightOwners (anOwners);
+}
+
+//=======================================================================
+//function : turnOnSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Integer theDispMode,
+ const Standard_Boolean theIsDisplayedOnly) const
+{
+ // the only differ with selection highlight is color, so sync transparency values
+ const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
+ aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ if (theObject.IsNull())
+ {
+ for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
+ {
+ const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
+ if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
+ {
+ continue;
+ }
+
+ aStatus->SubIntensityOn();
+ myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
+ }
+ }
+ else
+ {
+ Handle(AIS_GlobalStatus) aStatus;
+ if (!myObjects.Find (theObject, aStatus))
+ {
+ return;
+ }
+
+ if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
+ {
+ return;
+ }
+
+ aStatus->SubIntensityOn();
+ myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
+ }
+}
+
+//=======================================================================
+//function : highlightWithSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Integer theMode) const
+{
+ // the only differ with selection highlight is color, so
+ // sync transparency values
+ myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
+}
+
+//=======================================================================
+//function : highlightWithSubintensity
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Standard_Integer theMode) const
+{
+ // the only differ with selection highlight is color, so
+ // sync transparency values
+ myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
+
+ theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
+}
+
+//=======================================================================
+//function : isSlowHiStyle
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Handle(V3d_Viewer)& theViewer) const
+{
+ if (const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()))
+ {
+ const Handle(Prs3d_Drawer)& aHiStyle = getHiStyle (anObj, myLastPicked);
+ return aHiStyle->ZLayer() == Graphic3d_ZLayerId_UNKNOWN
+ || !theViewer->ZLayerSettings (aHiStyle->ZLayer()).IsImmediate();
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : MoveTo
+//purpose :
+//=======================================================================
+AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
+ const Standard_Integer theYPix,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate)
+{
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
+ }
+
+ myCurDetected = 0;
+ myCurHighlighted = 0;
+ myDetectedSeq.Clear();
+ myLastActiveView = theView.get();
+
+ // preliminaires
+ AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
+ Standard_Boolean toUpdateViewer = Standard_False;
+
+ myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
+ myMainSel->Pick (theXPix, theYPix, theView);
+
+ // filling of myAISDetectedSeq sequence storing information about detected AIS objects
+ // (the objects must be AIS_Shapes)
+ const Standard_Integer aDetectedNb = myMainSel->NbPicked();
+ Standard_Integer aNewDetected = 0;
+ Standard_Boolean toIgnoreDetTop = Standard_False;
+ for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
+ if (anOwner.IsNull()
+ || !myFilters->IsOk (anOwner))
+ {
+ if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
+ {
+ toIgnoreDetTop = Standard_True;
+ }
+ continue;
+ }
+
+ if (aNewDetected < 1
+ && !toIgnoreDetTop)
+ {
+ aNewDetected = aDetIter;
+ }
+
+ myDetectedSeq.Append (aDetIter);
+ }
+
+ if (aNewDetected >= 1)
+ {
+ myCurHighlighted = myDetectedSeq.Lower();
+
+ // Does nothing if previously detected object is equal to the current one.
+ // However in advanced selection modes the owners comparison
+ // is not effective because in that case only one owner manage the
+ // selection in current selection mode. It is necessary to check the current detected
+ // entity and hilight it only if the detected entity is not the same as
+ // previous detected (IsForcedHilight call)
+ Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
+ if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
+ {
+ return myLastPicked->IsSelected()
+ ? AIS_SOD_Selected
+ : AIS_SOD_OnlyOneDetected;
+ }
+
+ // Previously detected object is unhilighted if it is not selected or hilighted
+ // with selection color if it is selected. Such highlighting with selection color
+ // is needed only if myToHilightSelected flag is true. In this case previously detected
+ // object has been already highlighted with myHilightColor during previous MoveTo()
+ // method call. As result it is necessary to rehighligt it with mySelectionColor.
+ if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
+ {
+ if (isSlowHiStyle (myLastPicked, theView->Viewer()))
+ {
+ theView->Viewer()->Invalidate();
+ }
+
+ clearDynamicHighlight();
+ toUpdateViewer = Standard_True;
+ }
+
+ // initialize myLastPicked field with currently detected object
+ myLastPicked = aNewPickedOwner;
+
+ // highlight detected object if it is not selected or myToHilightSelected flag is true
+ if (myLastPicked->HasSelectable())
+ {
+ if (myAutoHilight
+ && (!myLastPicked->IsSelected()
+ || myToHilightSelected))
+ {
+ if (isSlowHiStyle (myLastPicked, theView->Viewer()))
+ {
+ theView->Viewer()->Invalidate();
+ }
+
+ highlightWithColor (myLastPicked, theView->Viewer());
+ toUpdateViewer = Standard_True;
+ }
+
+ aStatus = myLastPicked->IsSelected()
+ ? AIS_SOD_Selected
+ : AIS_SOD_OnlyOneDetected;
+ }
+ }
+ else
+ {
+ // previously detected object is unhilighted if it is not selected or hilighted
+ // with selection color if it is selected
+ aStatus = AIS_SOD_Nothing;
+ if (myAutoHilight
+ && !myLastPicked.IsNull()
+ && myLastPicked->HasSelectable())
+ {
+ if (isSlowHiStyle (myLastPicked, theView->Viewer()))
+ {
+ theView->Viewer()->Invalidate();
+ }
+
+ clearDynamicHighlight();
+ toUpdateViewer = Standard_True;
+ }
+
+ myLastPicked.Nullify();
+ }
+
+ if (toUpdateViewer
+ && theToRedrawOnUpdate)
+ {
+ if (theView->ComputedMode())
+ {
+ theView->Viewer()->Update();
+ }
+ else
+ {
+ if (theView->IsInvalidated())
+ {
+ theView->Viewer()->Redraw();
+ }
+ else
+ {
+ theView->Viewer()->RedrawImmediate();
+ }
+ }
+ }
+
+ return aStatus;
+}
+
+//=======================================================================
+//function : AddSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
+{
+ mySelection->AddSelect (theObject);
+
+ Standard_Integer aSelNum = NbSelected();
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+}
+
+//=======================================================================
+//function : SelectRectangle
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::SelectRectangle (const Graphic3d_Vec2i& thePntMin,
+ const Graphic3d_Vec2i& thePntMax,
+ const Handle(V3d_View)& theView,
+ const AIS_SelectionScheme theSelScheme)
+{
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::SelectRectangle() - invalid argument");
+ }
+
+ myLastActiveView = theView.get();
+ myMainSel->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView);
+
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
+ {
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
+ }
+ }
+
+ return Select (aPickedOwners, theSelScheme);
+}
+
+//=======================================================================
+//function : SelectPolygon
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline,
+ const Handle(V3d_View)& theView,
+ const AIS_SelectionScheme theSelScheme)
+{
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::SelectPolygon() - invalid argument");
+ }
+
+ myLastActiveView = theView.get();
+ myMainSel->Pick (thePolyline, theView);
+
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
+ {
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
+ }
+ }
+
+ return Select (aPickedOwners, theSelScheme);
+}
+
+//=======================================================================
+//function : SelectPoint
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::SelectPoint (const Graphic3d_Vec2i& thePnt,
+ const Handle(V3d_View)& theView,
+ const AIS_SelectionScheme theSelScheme)
+{
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::SelectPoint() - invalid argument");
+ }
+
+ myLastActiveView = theView.get();
+ myMainSel->Pick (thePnt.x(), thePnt.y(), theView);
+
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
+ {
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
+ }
+ }
+
+ return Select (aPickedOwners, theSelScheme);
+}
+
+//=======================================================================
+//function : SelectDetected
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::SelectDetected (const AIS_SelectionScheme theSelScheme)
+{
+ if (theSelScheme == AIS_SelectionScheme_Replace && !myLastPicked.IsNull())
+ {
+ Graphic3d_Vec2i aMousePos (-1, -1);
+ if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
+ {
+ aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
+ (Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
+ }
+ if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
+ {
+ return AIS_SOP_NothingSelected;
+ }
+ }
+
+ AIS_NArray1OfEntityOwner aPickedOwners (1, 1);
+ aPickedOwners.SetValue (1, myLastPicked);
+ return Select (aPickedOwners, theSelScheme);
+}
+
+//=======================================================================
+//function : Select
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
+ const Standard_Integer theYPMin,
+ const Standard_Integer theXPMax,
+ const Standard_Integer theYPMax,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin),
+ Graphic3d_Vec2i (theXPMax, theYPMax),
+ theView);
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : Select
+//purpose : Selection by polyline
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView);
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : Select
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectDetected();
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : ShiftSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectDetected (AIS_SelectionScheme_XOR);
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : ShiftSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
+ const Standard_Integer theYPMin,
+ const Standard_Integer theXPMax,
+ const Standard_Integer theYPMax,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin),
+ Graphic3d_Vec2i (theXPMax, theYPMax),
+ theView,
+ AIS_SelectionScheme_XOR);
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : ShiftSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToUpdateViewer)
+{
+ AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView, AIS_SelectionScheme_XOR);
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+ return aStatus;
+}
+
+//=======================================================================
+//function : Select
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NArray1OfEntityOwner& theOwners,
+ const AIS_SelectionScheme theSelScheme)
+{
+ NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> aSelOwnerMap (myAutoHilight ? mySelection->Objects().Size() : 0);
+ if (myAutoHilight)
+ {
+ clearDynamicHighlight();
+
+ // collect currently selected owners
+ for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ aSelOwnerMap.Add (anOwnerIter.Value());
+ }
+ }
+
+ mySelection->SelectOwners (theOwners, theSelScheme, myMainSel->GetManager().IsOverlapAllowed(), myFilters);
+
+ if (myAutoHilight)
+ {
+ // collect lists of owners to unhighlight (unselected) and to highlight (selected)
+ AIS_NListOfEntityOwner anOwnersToUnhighlight, anOwnersToHighlight;
+ for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ // add newly selected owners
+ const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
+ if (!aSelOwnerMap.RemoveKey (anOwner))
+ {
+ // newly selected owner
+ anOwnersToHighlight.Append (anOwner);
+ }
+ else
+ {
+ // already selected owner
+ if (!anOwner->IsAutoHilight()
+ && theSelScheme != AIS_SelectionScheme_XOR
+ && theSelScheme != AIS_SelectionScheme_Add)
+ {
+ // hack to perform AIS_InteractiveObject::ClearSelected() before highlighting
+ anOwnersToUnhighlight.Append (anOwner);
+ anOwnersToHighlight.Append (anOwner);
+ }
+ else if (anOwner->IsForcedHilight()
+ || !anOwner->IsAutoHilight())
+ {
+ anOwnersToHighlight.Append (anOwner);
+ }
+ }
+ }
+
+ for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anOwnerIter (aSelOwnerMap); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ // owners removed from selection
+ const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
+ anOwnersToUnhighlight.Append (anOwner);
+ }
+
+ unhighlightOwners (anOwnersToUnhighlight);
+ highlightOwners (anOwnersToHighlight, Handle(Prs3d_Drawer)());
+ }
+
+ Standard_Integer aSelNum = NbSelected();
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+}
+
+//=======================================================================
+//function : HilightSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
+{
+ // In case of selection without using local context
+ clearDynamicHighlight();
+
+ highlightOwners (mySelection->Objects(), Handle(Prs3d_Drawer)());
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+//function : highlightOwners
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners,
+ const Handle(Prs3d_Drawer)& theStyle)
+{
+ NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > anObjOwnerMap;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anObj.IsNull())
+ continue;
+
+ const Handle(Prs3d_Drawer)& anObjSelStyle = !theStyle.IsNull() ? theStyle : getSelStyle (anObj, anOwner);
+ Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
+ if (!aStatusPtr)
+ {
+ continue;
+ }
+ if (anOwner == anObj->GlobalSelOwner())
+ {
+ (*aStatusPtr)->SetHilightStatus (Standard_True);
+ (*aStatusPtr)->SetHilightStyle (anObjSelStyle);
+ }
+ if (!anOwner->IsAutoHilight())
+ {
+ NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
+ if (anObjOwnerMap.Find (anObj, aSeq))
+ {
+ aSeq->Append (anOwner);
+ }
+ else
+ {
+ aSeq = new SelectMgr_SequenceOfOwner();
+ aSeq->Append (anOwner);
+ anObjOwnerMap.Bind (anObj, aSeq);
+ }
+ }
+ else
+ {
+ const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, (*aStatusPtr)->DisplayMode());
+ anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
+ }
+ }
+
+ if (!anObjOwnerMap.IsEmpty())
+ {
+ for (NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> >::Iterator anIter (anObjOwnerMap);
+ anIter.More(); anIter.Next())
+ {
+ anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
+ }
+ anObjOwnerMap.Clear();
+ }
+}
+
+//=======================================================================
+//function : UnhilightSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
+{
+ unhighlightSelected();
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+//function : ClearSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
+{
+ if (NbSelected() == 0)
+ {
+ return;
+ }
+
+ if (myAutoHilight)
+ {
+ unhighlightSelected();
+ }
+
+ mySelection->Clear();
+ if (myAutoHilight)
+ {
+ clearDynamicHighlight();
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+//function : SetSelected
+//purpose : Sets the whole object as selected and highlights it with selection color
+//=======================================================================
+void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theObject.IsNull())
+ {
+ return;
+ }
+
+ if (!myObjects.IsBound (theObject))
+ {
+ return;
+ }
+
+ Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
+ if (anOwner.IsNull())
+ {
+ return;
+ }
+
+ const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
+ if (NbSelected() == 1 && myObjects (theObject)->IsHilighted() && myAutoHilight)
+ {
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (HighlightStyle (theObject, aCustomStyle))
+ {
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
+ {
+ HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
+ }
+ }
+ return;
+ }
+
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
+ if (!myFilters->IsOk (aSelOwner))
+ {
+ continue;
+ }
+
+ Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
+ if (myAutoHilight)
+ {
+ Unhilight (aSelectable, Standard_False);
+ }
+ if (aSelOwner == aSelectable->GlobalSelOwner())
+ {
+ if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable))
+ {
+ (*aStatusPtr)->SetHilightStatus (Standard_False);
+ }
+ }
+ }
+
+ // added to avoid untimely viewer update...
+ mySelection->ClearAndSelect (anOwner);
+
+ if (myAutoHilight)
+ {
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (HighlightStyle (theObject, aCustomStyle))
+ {
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
+ {
+ HilightWithColor (theObject, anObjSelStyle, Standard_False);
+ }
+ }
+ else
+ {
+ HilightWithColor (theObject, anObjSelStyle, Standard_False);
+ }
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+//function : SetSelected
+//purpose : Sets the whole object as selected and highlights it with selection color
+//=======================================================================
+void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
+ {
+ return;
+ }
+
+ const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
+ if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
+ {
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (myAutoHilight && HighlightStyle (theOwner, aCustomStyle))
+ {
+ if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
+ {
+ const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
+ theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
+ }
+ }
+ return;
+ }
+
+ if (!myObjects.IsBound (anObject))
+ {
+ return;
+ }
+
+ if (myAutoHilight)
+ {
+ unhighlightSelected();
+ }
+
+ mySelection->ClearAndSelect (theOwner);
+ if (myAutoHilight)
+ {
+ Handle(Prs3d_Drawer) aCustomStyle;
+ if (!HighlightStyle (theOwner, aCustomStyle) ||
+ (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
+ {
+ highlightSelected (theOwner);
+ }
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+//function : AddOrRemoveSelected
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theObject.IsNull()
+ || !myObjects.IsBound (theObject))
+ {
+ return;
+ }
+
+ const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
+ if (!anOwner.IsNull()
+ && anOwner->HasSelectable())
+ {
+ AddOrRemoveSelected (anOwner, theToUpdateViewer);
+ }
+}
+
+//=======================================================================
+//function : AddOrRemoveSelected
+//purpose : Allows to highlight or unhighlight the owner given depending on
+// its selection status
+//=======================================================================
+void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theOwner.IsNull() || !theOwner->HasSelectable())
+ {
+ return;
+ }
+
+ if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
+ {
+ return;
+ }
+
+ mySelection->Select (theOwner);
+
+ if (myAutoHilight)
+ {
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
+ if (!aStatusPtr)
+ {
+ return;
+ }
+
+ if (theOwner->IsSelected())
+ {
+ highlightSelected (theOwner);
+ }
+ else
+ {
+ AIS_NListOfEntityOwner anOwners;
+ anOwners.Append (theOwner);
+ unhighlightOwners (anOwners);
+
+ (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
+ }
+ }
+
+ if (theToUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
+}
+
+// =======================================================================
+// function : SetSelectedState
+// purpose :
+// =======================================================================
+Standard_Boolean AIS_InteractiveContext::SetSelectedState (const Handle(SelectMgr_EntityOwner)& theEntity,
+ const Standard_Boolean theIsSelected)
+{
+ if (theEntity.IsNull())
+ {
+ throw Standard_ProgramError ("Internal error: AIS_InteractiveContext::SetSelectedState() called with NO object");
+ }
+
+ if (!theEntity->HasSelectable()
+ || mySelection->IsSelected (theEntity) == theIsSelected)
+ {
+ return false;
+ }
+
+ if (theEntity->IsAutoHilight())
+ {
+ AddOrRemoveSelected (theEntity, false);
+ return true;
+ }
+
+ if (theIsSelected)
+ {
+ const AIS_SelectStatus aSelStatus = mySelection->AddSelect (theEntity);
+ theEntity->SetSelected (true);
+ return aSelStatus == AIS_SS_Added;
+ }
+ else
+ {
+ const AIS_SelectStatus aSelStatus = mySelection->Select (theEntity);
+ theEntity->SetSelected (false);
+ return aSelStatus == AIS_SS_Removed;
+ }
+}
+
+//=======================================================================
+//function : IsSelected
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
+{
+ if (theObj.IsNull())
+ {
+ return Standard_False;
+ }
+
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ if (aStatus == NULL)
+ {
+ return Standard_False;
+ }
+
+ const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
+ const TColStd_ListOfInteger& anActivatedModes = (*aStatus)->SelectionModes();
+ for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
+ {
+ if (aModeIter.Value() == aGlobalSelMode)
+ {
+ if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner())
+ {
+ return aGlobOwner->IsSelected();
+ }
+ return Standard_False;
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : FirstSelectedObject
+//purpose :
+//=======================================================================
+Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject() const
+{
+ return !mySelection->Objects().IsEmpty()
+ ? Handle(AIS_InteractiveObject)::DownCast (mySelection->Objects().First()->Selectable())
+ : Handle(AIS_InteractiveObject)();
+}
+
+//=======================================================================
+//function : HasSelectedShape
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
+{
+ if (!mySelection->More())
+ {
+ return Standard_False;
+ }
+
+ const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
+ return !anOwner.IsNull() && anOwner->HasShape();
+}
+
+//=======================================================================
+//function : SelectedShape
+//purpose :
+//=======================================================================
+TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
+{
+ if (!mySelection->More())
+ {
+ return TopoDS_Shape();
+ }
+
+ const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
+ if (anOwner.IsNull() || !anOwner->HasSelectable())
+ {
+ return TopoDS_Shape();
+ }
+
+ return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
+}
+
+//=======================================================================
+//function : EntityOwners
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
+ const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theMode) const
+{
+ if (theIObj.IsNull())
+ {
+ return;
+ }
+
+ TColStd_ListOfInteger aModes;
+ if (theMode == -1)
+ {
+ ActivatedModes (theIObj, aModes);
+ }
+ else
+ {
+ aModes.Append (theMode);
+ }
+
+ if (theOwners.IsNull())
+ {
+ theOwners = new SelectMgr_IndexedMapOfOwner();
+ }
+
+ for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next())
+ {
+ const int aMode = anItr.Value();
+ const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode);
+ if (aSel.IsNull())
+ {
+ continue;
+ }
+
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ if (Handle(Select3D_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive())
+ {
+ if (const Handle(SelectMgr_EntityOwner)& aOwner = aEntity->OwnerId())
+ {
+ theOwners->Add (aOwner);
+ }
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : HasDetectedShape
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
+{
+ Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
+ return !anOwner.IsNull()
+ && anOwner->HasShape();
+}
+
+//=======================================================================
+//function : DetectedShape
+//purpose :
+//=======================================================================
+const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const
+{
+ Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
+ return anOwner->Shape();
+}
+
+//=======================================================================
+//function : HilightNextDetected
+//purpose :
+//=======================================================================
+Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawImmediate)
+{
+ myMainPM->ClearImmediateDraw();
+ if (myDetectedSeq.IsEmpty())
+ {
+ return 0;
+ }
+
+ if (++myCurHighlighted > myDetectedSeq.Upper())
+ {
+ myCurHighlighted = myDetectedSeq.Lower();
+ }
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
+ if (anOwner.IsNull())
+ {
+ return 0;
+ }
+
+ highlightWithColor (anOwner, theView->Viewer());
+ myLastPicked = anOwner;
+
+ if (theToRedrawImmediate)
+ {
+ myMainPM->RedrawImmediate (theView->Viewer());
+ myMainVwr->RedrawImmediate();
+ }
+
+ return myCurHighlighted;
+}
+
+//=======================================================================
+//function : HilightPreviousDetected
+//purpose :
+//=======================================================================
+Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawImmediate)
+{
+ myMainPM->ClearImmediateDraw();
+ if (myDetectedSeq.IsEmpty())
+ {
+ return 0;
+ }
+
+ if (--myCurHighlighted < myDetectedSeq.Lower())
+ {
+ myCurHighlighted = myDetectedSeq.Upper();
+ }
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
+ if (anOwner.IsNull())
+ {
+ return 0;
+ }
+
+ highlightWithColor (anOwner, theView->Viewer());
+ myLastPicked = anOwner;
+
+ if (theToRedrawImmediate)
+ {
+ myMainPM->RedrawImmediate (theView->Viewer());
+ myMainVwr->RedrawImmediate();
+ }
+
+ return myCurHighlighted;
+}
+
+//=======================================================================
+//function : DetectedCurrentOwner
+//purpose :
+//=======================================================================
+Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedCurrentOwner() const
+{
+ return MoreDetected()
+ ? myMainSel->Picked (myDetectedSeq (myCurDetected))
+ : Handle(SelectMgr_EntityOwner)();
+}
+
+//=======================================================================
+//function : DetectedCurrentShape
+//purpose :
+//=======================================================================
+const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
+{
+ static const TopoDS_Shape AIS_InteractiveContext_myDummyShape;
+
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
+ Standard_ENABLE_DEPRECATION_WARNINGS
+ return !aCurrentShape.IsNull()
+ ? aCurrentShape->Shape()
+ : AIS_InteractiveContext_myDummyShape;
+}
+
+//=======================================================================
+//function : DetectedCurrentObject
+//purpose :
+//=======================================================================
+Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
+{
+ return MoreDetected()
+ ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
+ : Handle(AIS_InteractiveObject)();
+}
+
+//=======================================================================
+//function : SetSelectionModeActive
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Integer theMode,
+ const Standard_Boolean theIsActive,
+ const AIS_SelectionModesConcurrency theActiveFilter,
+ const Standard_Boolean theIsForce)
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ const Handle(AIS_GlobalStatus)* aStat = myObjects.Seek (theObj);
+ if (aStat == NULL)
+ {
+ return;
+ }
+
+ if (!theIsActive
+ || (theMode == -1
+ && theActiveFilter == AIS_SelectionModesConcurrency_Single))
+ {
+ if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
+ || theIsForce)
+ {
+ if (theMode == -1)
+ {
+ for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
+ {
+ mgrSelector->Deactivate (theObj, aModeIter.Value());
+ }
+ }
+ else
+ {
+ mgrSelector->Deactivate (theObj, theMode);
+ }
+ }
+
+ if (theMode == -1)
+ {
+ (*aStat)->ClearSelectionModes();
+ }
+ else
+ {
+ (*aStat)->RemoveSelectionMode (theMode);
+ }
+ return;
+ }
+ else if (theMode == -1)
+ {
+ return;
+ }
+
+ if ((*aStat)->SelectionModes().Size() == 1
+ && (*aStat)->SelectionModes().First() == theMode)
+ {
+ return;
+ }
+
+ if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
+ || theIsForce)
+ {
+ switch (theActiveFilter)
+ {
+ case AIS_SelectionModesConcurrency_Single:
+ {
+ for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
+ {
+ mgrSelector->Deactivate (theObj, aModeIter.Value());
+ }
+ (*aStat)->ClearSelectionModes();
+ break;
+ }
+ case AIS_SelectionModesConcurrency_GlobalOrLocal:
+ {
+ const Standard_Integer aGlobSelMode = theObj->GlobalSelectionMode();
+ TColStd_ListOfInteger aRemovedModes;
+ for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
+ {
+ if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode)
+ || (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode))
+ {
+ mgrSelector->Deactivate (theObj, aModeIter.Value());
+ aRemovedModes.Append (aModeIter.Value());
+ }
+ }
+ if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size())
+ {
+ (*aStat)->ClearSelectionModes();
+ }
+ else
+ {
+ for (TColStd_ListIteratorOfListOfInteger aModeIter (aRemovedModes); aModeIter.More(); aModeIter.Next())
+ {
+ (*aStat)->RemoveSelectionMode (aModeIter.Value());
+ }
+ }
+ break;
+ }
+ case AIS_SelectionModesConcurrency_Multiple:
+ {
+ break;
+ }
+ }
+ mgrSelector->Activate (theObj, theMode);
+ }
+ (*aStat)->AddSelectionMode (theMode);
+}
+
+// ============================================================================
+// function : Activate
+// purpose :
+// ============================================================================
+void AIS_InteractiveContext::Activate (const Standard_Integer theMode,
+ const Standard_Boolean theIsForce)
+{
+ AIS_ListOfInteractive aDisplayedObjects;
+ DisplayedObjects (aDisplayedObjects);
+ for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next())
+ {
+ Load (anIter.Value(), -1);
+ Activate (anIter.Value(), theMode, theIsForce);
+ }
+}
+
+// ============================================================================
+// function : Deactivate
+// purpose :
+// ============================================================================
+void AIS_InteractiveContext::Deactivate (const Standard_Integer theMode)
+{
+ AIS_ListOfInteractive aDisplayedObjects;
+ DisplayedObjects (aDisplayedObjects);
+ for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next())
+ {
+ Deactivate (anIter.Value(), theMode);
+ }
+}
+
+// ============================================================================
+// function : Deactivate
+// purpose :
+// ============================================================================
+void AIS_InteractiveContext::Deactivate()
+{
+ AIS_ListOfInteractive aDisplayedObjects;
+ DisplayedObjects (aDisplayedObjects);
+
+ for (AIS_ListOfInteractive::Iterator anIter (aDisplayedObjects); anIter.More(); anIter.Next())
+ {
+ Deactivate (anIter.Value());
+ }
+}
+
+//=======================================================================
+//function : ActivatedModes
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::ActivatedModes (const Handle(AIS_InteractiveObject)& theObj,
+ TColStd_ListOfInteger& theList) const
+{
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ if (aStatus != NULL)
+ {
+ for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next())
+ {
+ theList.Append (aModeIter.Value());
+ }
+ }
+}
+
+//=======================================================================
+//function : SubIntensityOn
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SubIntensityOn (const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Boolean theToUpdateViewer)
+{
+ turnOnSubintensity (theObj);
+ if (theToUpdateViewer)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : SubIntensityOff
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Boolean theToUpdateViewer)
+{
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ if (aStatus == NULL
+ || !(*aStatus)->IsSubIntensityOn())
+ {
+ return;
+ }
+
+ (*aStatus)->SubIntensityOff();
+ Standard_Boolean toUpdateMain = Standard_False;
+ if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
+ {
+ myMainPM->Unhighlight (theObj);
+ toUpdateMain = Standard_True;
+ }
+
+ if (IsSelected (theObj))
+ {
+ highlightSelected (theObj->GlobalSelOwner());
+ }
+
+ if (theToUpdateViewer && toUpdateMain)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : DisplayActiveSensitive
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& theView)
+{
+ myMainSel->DisplaySensitive (theView);
+}
+
+//=======================================================================
+//function : DisplayActiveSensitive
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& theObj,
+ const Handle(V3d_View)& theView)
+{
+ const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
+ if (aStatus == NULL)
+ {
+ return;
+ }
+
+ for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = theObj->Selection (aModeIter.Value());
+ myMainSel->DisplaySensitive (aSel, theObj->Transformation(), theView, Standard_False);
+ }
+}
+
+//=======================================================================
+//function : ClearActiveSensitive
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::ClearActiveSensitive (const Handle(V3d_View)& theView)
+{
+ myMainSel->ClearSensitive (theView);
+}
+
+//=======================================================================
+//function : PurgeDisplay
+//purpose :
+//=======================================================================
+Standard_Integer AIS_InteractiveContext::PurgeDisplay()
+{
+ Standard_Integer NbStr = PurgeViewer(myMainVwr);
+ myMainVwr->Update();
+ return NbStr;
+}
+
+//=======================================================================
+//function : PurgeViewer
+//purpose :
+//=======================================================================
+Standard_Integer AIS_InteractiveContext::PurgeViewer (const Handle(V3d_Viewer)& theViewer)
+{
+ Handle(Graphic3d_StructureManager) GSM = theViewer->StructureManager();
+ Standard_Integer aNbCleared = 0;
+ Graphic3d_MapOfStructure SOS;
+ GSM->DisplayedStructures (SOS);
+ for (Graphic3d_MapOfStructure::Iterator It(SOS); It.More();It.Next())
+ {
+ Handle(Graphic3d_Structure) G = It.Key();
+ Standard_Address anOwner = G->Owner();
+ if (anOwner == NULL)
+ {
+ G->Erase();
+ G->Clear();// it means that it is not referenced as a presentation of InterfactiveObject...
+ ++aNbCleared;
+ }
+ Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject* )anOwner;
+ if (!myObjects.IsBound (IO))
+ {
+ G->Erase();
+ ++aNbCleared;
+ }
+ }
+ return aNbCleared;
+}
+
+//=======================================================================
+//function : IsImmediateModeOn
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
+{
+ return myMainPM->IsImmediateModeOn();
+}
+
+//=======================================================================
+//function : BeginImmediateDraw
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
+{
+ if (myMainPM->IsImmediateModeOn())
+ {
+ myMainPM->BeginImmediateDraw();
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : ImmediateAdd
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Integer theMode)
+{
+ if (myMainPM->IsImmediateModeOn())
+ {
+ myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode));
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : EndImmediateDraw
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView)
+{
+ if (myMainPM->IsImmediateModeOn())
+ {
+ myMainPM->EndImmediateDraw (theView->Viewer());
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : EndImmediateDraw
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
+{
+ if (myMainPM->IsImmediateModeOn())
+ {
+ myMainPM->EndImmediateDraw (myMainVwr);
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : SetPolygonOffsets
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theObj,
+ const Standard_Integer theMode,
+ const Standard_ShortReal theFactor,
+ const Standard_ShortReal theUnits,
+ const Standard_Boolean theToUpdateViewer)
+{
+ if (theObj.IsNull())
+ {
+ return;
+ }
+
+ setContextToObject (theObj);
+ theObj->SetPolygonOffsets (theMode, theFactor, theUnits);
+
+ const Handle(AIS_GlobalStatus)* aStatus = theToUpdateViewer ? myObjects.Seek (theObj) : NULL;
+ if (aStatus != NULL
+ && theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
+ {
+ myMainVwr->Update();
+ }
+}
+
+//=======================================================================
+//function : HasPolygonOffsets
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_InteractiveContext::HasPolygonOffsets (const Handle(AIS_InteractiveObject)& theObj) const
+{
+ return !theObj.IsNull() && theObj->HasPolygonOffsets();
+}
+
+//=======================================================================
+//function : PolygonOffsets
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::PolygonOffsets (const Handle(AIS_InteractiveObject)& theObj,
+ Standard_Integer& theMode,
+ Standard_ShortReal& theFactor,
+ Standard_ShortReal& theUnits) const
+{
+ if (HasPolygonOffsets (theObj))
+ {
+ theObj->PolygonOffsets (theMode, theFactor, theUnits);
+ }
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size())
+
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainSel.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView)
+
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get())
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected)
+
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get())
+
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected])
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic])
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected])
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic])
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity])
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size())
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode)
+}
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <SelectMgr_ListOfFilter.hxx>
#include <SelectMgr_PickingStrategy.hxx>
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
{ myFilters->SetFilterType (theFilterType); }
//! Returns the list of filters active in a local context.
- Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const;
+ const SelectMgr_ListOfFilter& Filters() const { return myFilters->StoredFilters(); }
//! Allows you to add the filter.
- Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter);
+ void AddFilter (const Handle(SelectMgr_Filter)& theFilter) { myFilters->Add (theFilter); }
//! Removes a filter from context.
- Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter);
+ void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter) { myFilters->Remove (theFilter); }
//! Remove all filters from context.
- Standard_EXPORT void RemoveFilters();
+ void RemoveFilters() { myFilters->Clear(); }
//! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default.
//! @sa MoveTo()/Filters()
+++ /dev/null
-// Created on: 1997-01-29
-// Created by: Robert COUBLANC
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
-#include <AIS_GlobalStatus.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_MapIteratorOfMapOfInteractive.hxx>
-#include <AIS_MapOfInteractive.hxx>
-#include <AIS_Selection.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_StatusOfDetection.hxx>
-#include <AIS_StatusOfPick.hxx>
-#include <Aspect_Grid.hxx>
-#include <Prs3d_BasicAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Quantity_Color.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_OrFilter.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_Transient.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TopLoc_Location.hxx>
-#include <V3d_AmbientLight.hxx>
-#include <V3d_DirectionalLight.hxx>
-#include <V3d_Light.hxx>
-#include <V3d_PositionalLight.hxx>
-#include <V3d_SpotLight.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
-
-namespace
-{
- TopoDS_Shape AIS_InteractiveContext_myDummyShape;
-}
-
-//=======================================================================
-//function : highlightWithColor
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Handle(V3d_Viewer)& theViewer)
-{
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
- if (anObj.IsNull())
- {
- return;
- }
-
- const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner);
- const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
-
- myMainPM->BeginImmediateDraw();
- theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
- myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
-}
-
-//=======================================================================
-//function : highlightSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
-{
- AIS_NListOfEntityOwner anOwners;
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
- if (anObj.IsNull())
- {
- return;
- }
-
- if (!theOwner->IsAutoHilight())
- {
- SelectMgr_SequenceOfOwner aSeq;
- for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
- {
- if (aSelIter.Value()->IsSameSelectable (anObj))
- {
- anOwners.Append (aSelIter.Value());
- }
- }
- }
- else
- {
- anOwners.Append (theOwner);
- }
- highlightOwners (anOwners, Handle(Prs3d_Drawer)());
-}
-
-//=======================================================================
-//function : highlightGlobal
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
- const Handle(Prs3d_Drawer)& theStyle,
- const Standard_Integer theDispMode)
-{
- if (theObj.IsNull())
- {
- return;
- }
-
- const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
- const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
-
- if (aGlobOwner.IsNull())
- {
- myMainPM->Color (theObj, theStyle, aHiMode);
- return;
- }
-
- AIS_NListOfEntityOwner anOwners;
- if (!aGlobOwner->IsAutoHilight())
- {
- SelectMgr_SequenceOfOwner aSeq;
- for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
- {
- if (aSelIter.Value()->IsSameSelectable (theObj))
- {
- anOwners.Append (aSelIter.Value());
- }
- }
- }
- else
- {
- anOwners.Append (aGlobOwner);
- }
- highlightOwners (anOwners, theStyle);
-}
-
-//=======================================================================
-//function : unhighlightSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
-{
- unhighlightOwners (mySelection->Objects(), theIsToHilightSubIntensity);
-}
-
-//=======================================================================
-//function : unhighlightOwners
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
- const Standard_Boolean theIsToHilightSubIntensity)
-{
- NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
- for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
- {
- const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
- const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive);
- if (!aStatusPtr)
- {
- continue;
- }
-
- if (anOwner->IsAutoHilight())
- {
- anOwner->Unhilight (myMainPM);
- if (theIsToHilightSubIntensity)
- {
- if ((*aStatusPtr)->IsSubIntensityOn())
- {
- const Standard_Integer aHiMode = getHilightMode (anInteractive, (*aStatusPtr)->HilightStyle(), (*aStatusPtr)->DisplayMode());
- highlightWithSubintensity (anOwner, aHiMode);
- }
- }
- }
- else
- {
- anObjToClear.Add (anInteractive);
- }
- if (anOwner == anInteractive->GlobalSelOwner())
- {
- (*aStatusPtr)->SetHilightStatus (Standard_False);
- }
- (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
- }
- for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
- {
- const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
- myMainPM->Unhighlight (anObj);
- anObj->ClearSelected();
- }
-}
-
-//=======================================================================
-//function : unhighlightGlobal
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj)
-{
- if (theObj.IsNull())
- {
- return;
- }
-
- const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
- if (aGlobOwner.IsNull())
- {
- myMainPM->Unhighlight (theObj);
- return;
- }
-
- AIS_NListOfEntityOwner anOwners;
- anOwners.Append (aGlobOwner);
- unhighlightOwners (anOwners);
-}
-
-//=======================================================================
-//function : turnOnSubintensity
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
- const Standard_Integer theDispMode,
- const Standard_Boolean theIsDisplayedOnly) const
-{
- // the only differ with selection highlight is color, so sync transparency values
- const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];
- aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
-
- if (theObject.IsNull())
- {
- for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
- {
- const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
- if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
- {
- continue;
- }
-
- aStatus->SubIntensityOn();
- myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
- }
- }
- else
- {
- Handle(AIS_GlobalStatus) aStatus;
- if (!myObjects.Find (theObject, aStatus))
- {
- return;
- }
-
- if (theObject->DisplayStatus() != PrsMgr_DisplayStatus_Displayed && theIsDisplayedOnly)
- {
- return;
- }
-
- aStatus->SubIntensityOn();
- myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
- }
-}
-
-//=======================================================================
-//function : highlightWithSubintensity
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
- const Standard_Integer theMode) const
-{
- // the only differ with selection highlight is color, so
- // sync transparency values
- myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
-
- myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
-}
-
-//=======================================================================
-//function : highlightWithSubintensity
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Standard_Integer theMode) const
-{
- // the only differ with selection highlight is color, so
- // sync transparency values
- myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
-
- theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
-}
-
-//=======================================================================
-//function : isSlowHiStyle
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Handle(V3d_Viewer)& theViewer) const
-{
- if (const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()))
- {
- const Handle(Prs3d_Drawer)& aHiStyle = getHiStyle (anObj, myLastPicked);
- return aHiStyle->ZLayer() == Graphic3d_ZLayerId_UNKNOWN
- || !theViewer->ZLayerSettings (aHiStyle->ZLayer()).IsImmediate();
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : MoveTo
-//purpose :
-//=======================================================================
-AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
- const Standard_Integer theYPix,
- const Handle(V3d_View)& theView,
- const Standard_Boolean theToRedrawOnUpdate)
-{
- if (theView->Viewer() != myMainVwr)
- {
- throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
- }
-
- myCurDetected = 0;
- myCurHighlighted = 0;
- myDetectedSeq.Clear();
- myLastActiveView = theView.get();
-
- // preliminaires
- AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
- Standard_Boolean toUpdateViewer = Standard_False;
-
- myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
- myMainSel->Pick (theXPix, theYPix, theView);
-
- // filling of myAISDetectedSeq sequence storing information about detected AIS objects
- // (the objects must be AIS_Shapes)
- const Standard_Integer aDetectedNb = myMainSel->NbPicked();
- Standard_Integer aNewDetected = 0;
- Standard_Boolean toIgnoreDetTop = Standard_False;
- for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
- {
- Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
- if (anOwner.IsNull()
- || !myFilters->IsOk (anOwner))
- {
- if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
- {
- toIgnoreDetTop = Standard_True;
- }
- continue;
- }
-
- if (aNewDetected < 1
- && !toIgnoreDetTop)
- {
- aNewDetected = aDetIter;
- }
-
- myDetectedSeq.Append (aDetIter);
- }
-
- if (aNewDetected >= 1)
- {
- myCurHighlighted = myDetectedSeq.Lower();
-
- // Does nothing if previously detected object is equal to the current one.
- // However in advanced selection modes the owners comparison
- // is not effective because in that case only one owner manage the
- // selection in current selection mode. It is necessary to check the current detected
- // entity and hilight it only if the detected entity is not the same as
- // previous detected (IsForcedHilight call)
- Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
- if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
- {
- return myLastPicked->IsSelected()
- ? AIS_SOD_Selected
- : AIS_SOD_OnlyOneDetected;
- }
-
- // Previously detected object is unhilighted if it is not selected or hilighted
- // with selection color if it is selected. Such highlighting with selection color
- // is needed only if myToHilightSelected flag is true. In this case previously detected
- // object has been already highlighted with myHilightColor during previous MoveTo()
- // method call. As result it is necessary to rehighligt it with mySelectionColor.
- if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
- {
- if (isSlowHiStyle (myLastPicked, theView->Viewer()))
- {
- theView->Viewer()->Invalidate();
- }
-
- clearDynamicHighlight();
- toUpdateViewer = Standard_True;
- }
-
- // initialize myLastPicked field with currently detected object
- myLastPicked = aNewPickedOwner;
-
- // highlight detected object if it is not selected or myToHilightSelected flag is true
- if (myLastPicked->HasSelectable())
- {
- if (myAutoHilight
- && (!myLastPicked->IsSelected()
- || myToHilightSelected))
- {
- if (isSlowHiStyle (myLastPicked, theView->Viewer()))
- {
- theView->Viewer()->Invalidate();
- }
-
- highlightWithColor (myLastPicked, theView->Viewer());
- toUpdateViewer = Standard_True;
- }
-
- aStatus = myLastPicked->IsSelected()
- ? AIS_SOD_Selected
- : AIS_SOD_OnlyOneDetected;
- }
- }
- else
- {
- // previously detected object is unhilighted if it is not selected or hilighted
- // with selection color if it is selected
- aStatus = AIS_SOD_Nothing;
- if (myAutoHilight
- && !myLastPicked.IsNull()
- && myLastPicked->HasSelectable())
- {
- if (isSlowHiStyle (myLastPicked, theView->Viewer()))
- {
- theView->Viewer()->Invalidate();
- }
-
- clearDynamicHighlight();
- toUpdateViewer = Standard_True;
- }
-
- myLastPicked.Nullify();
- }
-
- if (toUpdateViewer
- && theToRedrawOnUpdate)
- {
- if (theView->ComputedMode())
- {
- theView->Viewer()->Update();
- }
- else
- {
- if (theView->IsInvalidated())
- {
- theView->Viewer()->Redraw();
- }
- else
- {
- theView->Viewer()->RedrawImmediate();
- }
- }
- }
-
- return aStatus;
-}
-
-//=======================================================================
-//function : AddSelect
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
-{
- mySelection->AddSelect (theObject);
-
- Standard_Integer aSelNum = NbSelected();
- return (aSelNum == 0) ? AIS_SOP_NothingSelected
- : (aSelNum == 1) ? AIS_SOP_OneSelected
- : AIS_SOP_SeveralSelected;
-}
-
-//=======================================================================
-//function : SelectRectangle
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::SelectRectangle (const Graphic3d_Vec2i& thePntMin,
- const Graphic3d_Vec2i& thePntMax,
- const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme)
-{
- if (theView->Viewer() != myMainVwr)
- {
- throw Standard_ProgramError ("AIS_InteractiveContext::SelectRectangle() - invalid argument");
- }
-
- myLastActiveView = theView.get();
- myMainSel->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView);
-
- AIS_NArray1OfEntityOwner aPickedOwners;
- if (myMainSel->NbPicked() > 0)
- {
- aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
- {
- aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
- }
- }
-
- return Select (aPickedOwners, theSelScheme);
-}
-
-//=======================================================================
-//function : SelectPolygon
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline,
- const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme)
-{
- if (theView->Viewer() != myMainVwr)
- {
- throw Standard_ProgramError ("AIS_InteractiveContext::SelectPolygon() - invalid argument");
- }
-
- myLastActiveView = theView.get();
- myMainSel->Pick (thePolyline, theView);
-
- AIS_NArray1OfEntityOwner aPickedOwners;
- if (myMainSel->NbPicked() > 0)
- {
- aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
- {
- aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
- }
- }
-
- return Select (aPickedOwners, theSelScheme);
-}
-
-//=======================================================================
-//function : SelectPoint
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::SelectPoint (const Graphic3d_Vec2i& thePnt,
- const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme)
-{
- if (theView->Viewer() != myMainVwr)
- {
- throw Standard_ProgramError ("AIS_InteractiveContext::SelectPoint() - invalid argument");
- }
-
- myLastActiveView = theView.get();
- myMainSel->Pick (thePnt.x(), thePnt.y(), theView);
-
- AIS_NArray1OfEntityOwner aPickedOwners;
- if (myMainSel->NbPicked() > 0)
- {
- aPickedOwners.Resize (1, myMainSel->NbPicked(), false);
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
- {
- aPickedOwners.SetValue (aPickIter, myMainSel->Picked (aPickIter));
- }
- }
-
- return Select (aPickedOwners, theSelScheme);
-}
-
-//=======================================================================
-//function : SelectDetected
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::SelectDetected (const AIS_SelectionScheme theSelScheme)
-{
- if (theSelScheme == AIS_SelectionScheme_Replace && !myLastPicked.IsNull())
- {
- Graphic3d_Vec2i aMousePos (-1, -1);
- if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
- {
- aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
- (Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
- }
- if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
- {
- return AIS_SOP_NothingSelected;
- }
- }
-
- AIS_NArray1OfEntityOwner aPickedOwners (1, 1);
- aPickedOwners.SetValue (1, myLastPicked);
- return Select (aPickedOwners, theSelScheme);
-}
-
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
- const Standard_Integer theYPMin,
- const Standard_Integer theXPMax,
- const Standard_Integer theYPMax,
- const Handle(V3d_View)& theView,
- const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin),
- Graphic3d_Vec2i (theXPMax, theYPMax),
- theView);
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : Select
-//purpose : Selection by polyline
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
- const Handle(V3d_View)& theView,
- const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView);
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectDetected();
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : ShiftSelect
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectDetected (AIS_SelectionScheme_XOR);
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : ShiftSelect
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
- const Standard_Integer theYPMin,
- const Standard_Integer theXPMax,
- const Standard_Integer theYPMax,
- const Handle(V3d_View)& theView,
- const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin),
- Graphic3d_Vec2i (theXPMax, theYPMax),
- theView,
- AIS_SelectionScheme_XOR);
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : ShiftSelect
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
- const Handle(V3d_View)& theView,
- const Standard_Boolean theToUpdateViewer)
-{
- AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView, AIS_SelectionScheme_XOR);
- if (theToUpdateViewer)
- {
- UpdateCurrentViewer();
- }
- return aStatus;
-}
-
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NArray1OfEntityOwner& theOwners,
- const AIS_SelectionScheme theSelScheme)
-{
- NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> aSelOwnerMap (myAutoHilight ? mySelection->Objects().Size() : 0);
- if (myAutoHilight)
- {
- clearDynamicHighlight();
-
- // collect currently selected owners
- for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
- {
- aSelOwnerMap.Add (anOwnerIter.Value());
- }
- }
-
- mySelection->SelectOwners (theOwners, theSelScheme, myMainSel->GetManager().IsOverlapAllowed(), myFilters);
-
- if (myAutoHilight)
- {
- // collect lists of owners to unhighlight (unselected) and to highlight (selected)
- AIS_NListOfEntityOwner anOwnersToUnhighlight, anOwnersToHighlight;
- for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
- {
- // add newly selected owners
- const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
- if (!aSelOwnerMap.RemoveKey (anOwner))
- {
- // newly selected owner
- anOwnersToHighlight.Append (anOwner);
- }
- else
- {
- // already selected owner
- if (!anOwner->IsAutoHilight()
- && theSelScheme != AIS_SelectionScheme_XOR
- && theSelScheme != AIS_SelectionScheme_Add)
- {
- // hack to perform AIS_InteractiveObject::ClearSelected() before highlighting
- anOwnersToUnhighlight.Append (anOwner);
- anOwnersToHighlight.Append (anOwner);
- }
- else if (anOwner->IsForcedHilight()
- || !anOwner->IsAutoHilight())
- {
- anOwnersToHighlight.Append (anOwner);
- }
- }
- }
-
- for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anOwnerIter (aSelOwnerMap); anOwnerIter.More(); anOwnerIter.Next())
- {
- // owners removed from selection
- const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
- anOwnersToUnhighlight.Append (anOwner);
- }
-
- unhighlightOwners (anOwnersToUnhighlight);
- highlightOwners (anOwnersToHighlight, Handle(Prs3d_Drawer)());
- }
-
- Standard_Integer aSelNum = NbSelected();
- return (aSelNum == 0) ? AIS_SOP_NothingSelected
- : (aSelNum == 1) ? AIS_SOP_OneSelected
- : AIS_SOP_SeveralSelected;
-}
-
-//=======================================================================
-//function : HilightSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
-{
- // In case of selection without using local context
- clearDynamicHighlight();
-
- highlightOwners (mySelection->Objects(), Handle(Prs3d_Drawer)());
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-//=======================================================================
-//function : highlightOwners
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners,
- const Handle(Prs3d_Drawer)& theStyle)
-{
- AIS_MapOfObjSelectedOwners anObjOwnerMap;
- for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
- {
- const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (anObj.IsNull())
- continue;
-
- const Handle(Prs3d_Drawer)& anObjSelStyle = !theStyle.IsNull() ? theStyle : getSelStyle (anObj, anOwner);
- Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
- if (!aStatusPtr)
- {
- continue;
- }
- if (anOwner == anObj->GlobalSelOwner())
- {
- (*aStatusPtr)->SetHilightStatus (Standard_True);
- (*aStatusPtr)->SetHilightStyle (anObjSelStyle);
- }
- if (!anOwner->IsAutoHilight())
- {
- NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
- if (anObjOwnerMap.Find (anObj, aSeq))
- {
- aSeq->Append (anOwner);
- }
- else
- {
- aSeq = new SelectMgr_SequenceOfOwner();
- aSeq->Append (anOwner);
- anObjOwnerMap.Bind (anObj, aSeq);
- }
- }
- else
- {
- const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, (*aStatusPtr)->DisplayMode());
- anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
- }
- }
-
- if (!anObjOwnerMap.IsEmpty())
- {
- for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
- {
- anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
- }
- anObjOwnerMap.Clear();
- }
-}
-
-//=======================================================================
-//function : UnhilightSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
-{
- unhighlightSelected();
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-
-//=======================================================================
-//function : ClearSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
-{
- if (NbSelected() == 0)
- return;
-
- if (myAutoHilight)
- {
- unhighlightSelected();
- }
-
- mySelection->Clear();
- if (myAutoHilight)
- {
- clearDynamicHighlight();
- }
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-//=======================================================================
-//function : SetSelected
-//purpose : Sets the whole object as selected and highlights it with selection color
-//=======================================================================
-void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theObject.IsNull())
- {
- return;
- }
-
- if (!myObjects.IsBound (theObject))
- {
- return;
- }
-
- Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
- if (anOwner.IsNull())
- {
- return;
- }
-
- const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
- if (NbSelected() == 1 && myObjects (theObject)->IsHilighted() && myAutoHilight)
- {
- Handle(Prs3d_Drawer) aCustomStyle;
- if (HighlightStyle (theObject, aCustomStyle))
- {
- if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
- {
- HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
- }
- }
- return;
- }
-
- for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
- {
- const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
- if (!myFilters->IsOk (aSelOwner))
- {
- continue;
- }
-
- Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
- if (myAutoHilight)
- {
- Unhilight (aSelectable, Standard_False);
- }
- if (aSelOwner == aSelectable->GlobalSelOwner())
- {
- if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable))
- {
- (*aStatusPtr)->SetHilightStatus (Standard_False);
- }
- }
- }
-
- // added to avoid untimely viewer update...
- mySelection->ClearAndSelect (anOwner);
-
- if (myAutoHilight)
- {
- Handle(Prs3d_Drawer) aCustomStyle;
- if (HighlightStyle (theObject, aCustomStyle))
- {
- if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
- {
- HilightWithColor (theObject, anObjSelStyle, Standard_False);
- }
- }
- else
- {
- HilightWithColor (theObject, anObjSelStyle, Standard_False);
- }
- }
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-//=======================================================================
-//function : SetSelected
-//purpose : Sets the whole object as selected and highlights it with selection color
-//=======================================================================
-void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
- return;
-
- const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
- const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
- if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
- {
- Handle(Prs3d_Drawer) aCustomStyle;
- if (myAutoHilight && HighlightStyle (theOwner, aCustomStyle))
- {
- if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
- {
- const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
- theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
- }
- }
- return;
- }
-
- if (!myObjects.IsBound (anObject))
- return;
-
- if (myAutoHilight)
- {
- unhighlightSelected();
- }
-
- mySelection->ClearAndSelect (theOwner);
- if (myAutoHilight)
- {
- Handle(Prs3d_Drawer) aCustomStyle;
- if (!HighlightStyle (theOwner, aCustomStyle) ||
- (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
- {
- highlightSelected (theOwner);
- }
- }
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-//=======================================================================
-//function : AddOrRemoveSelected
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theObject.IsNull()
- || !myObjects.IsBound (theObject))
- {
- return;
- }
-
- const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
- if (!anOwner.IsNull()
- && anOwner->HasSelectable())
- {
- AddOrRemoveSelected (anOwner, theToUpdateViewer);
- }
-}
-
-//=======================================================================
-//function : AddOrRemoveSelected
-//purpose : Allows to highlight or unhighlight the owner given depending on
-// its selection status
-//=======================================================================
-void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Standard_Boolean theToUpdateViewer)
-{
- if (theOwner.IsNull() || !theOwner->HasSelectable())
- return;
-
- if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
- return;
-
- mySelection->Select (theOwner);
-
- if (myAutoHilight)
- {
- const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
- Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
- if (!aStatusPtr)
- {
- return;
- }
-
- if (theOwner->IsSelected())
- {
- highlightSelected (theOwner);
- }
- else
- {
- AIS_NListOfEntityOwner anOwners;
- anOwners.Append (theOwner);
- unhighlightOwners (anOwners);
-
- (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
- }
- }
-
- if (theToUpdateViewer)
- UpdateCurrentViewer();
-}
-
-// =======================================================================
-// function : SetSelectedState
-// purpose :
-// =======================================================================
-Standard_Boolean AIS_InteractiveContext::SetSelectedState (const Handle(SelectMgr_EntityOwner)& theEntity,
- const Standard_Boolean theIsSelected)
-{
- if (theEntity.IsNull())
- {
- throw Standard_ProgramError ("Internal error: AIS_InteractiveContext::SetSelectedState() called with NO object");
- }
-
- if (!theEntity->HasSelectable()
- || mySelection->IsSelected (theEntity) == theIsSelected)
- {
- return false;
- }
-
- if (theEntity->IsAutoHilight())
- {
- AddOrRemoveSelected (theEntity, false);
- return true;
- }
-
- if (theIsSelected)
- {
- const AIS_SelectStatus aSelStatus = mySelection->AddSelect (theEntity);
- theEntity->SetSelected (true);
- return aSelStatus == AIS_SS_Added;
- }
- else
- {
- const AIS_SelectStatus aSelStatus = mySelection->Select (theEntity);
- theEntity->SetSelected (false);
- return aSelStatus == AIS_SS_Removed;
- }
-}
-
-//=======================================================================
-//function : IsSelected
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
-{
- if (theObj.IsNull())
- {
- return Standard_False;
- }
-
- const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
- if (aStatus == NULL)
- {
- return Standard_False;
- }
-
- const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
- const TColStd_ListOfInteger& anActivatedModes = (*aStatus)->SelectionModes();
- for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
- {
- if (aModeIter.Value() == aGlobalSelMode)
- {
- if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner())
- {
- return aGlobOwner->IsSelected();
- }
- return Standard_False;
- }
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : FirstSelectedObject
-//purpose :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject() const
-{
- return !mySelection->Objects().IsEmpty()
- ? Handle(AIS_InteractiveObject)::DownCast (mySelection->Objects().First()->Selectable())
- : Handle(AIS_InteractiveObject)();
-}
-
-//=======================================================================
-//function : HasSelectedShape
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
-{
- if (!mySelection->More())
- return Standard_False;
-
- const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
- return !anOwner.IsNull() && anOwner->HasShape();
-}
-
-//=======================================================================
-//function : SelectedShape
-//purpose :
-//=======================================================================
-TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
-{
- if (!mySelection->More())
- return TopoDS_Shape();
-
- const Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
- if (anOwner.IsNull() || !anOwner->HasSelectable())
- return TopoDS_Shape();
-
- return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
-}
-
-//=======================================================================
-//function : EntityOwners
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
- const Handle(AIS_InteractiveObject)& theIObj,
- const Standard_Integer theMode) const
-{
- if (theIObj.IsNull())
- {
- return;
- }
-
- TColStd_ListOfInteger aModes;
- if (theMode == -1)
- {
- ActivatedModes (theIObj, aModes);
- }
- else
- {
- aModes.Append (theMode);
- }
-
- if (theOwners.IsNull())
- {
- theOwners = new SelectMgr_IndexedMapOfOwner();
- }
-
- for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next())
- {
- const int aMode = anItr.Value();
- const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode);
- if (aSel.IsNull())
- {
- continue;
- }
-
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
- {
- if (Handle(Select3D_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive())
- {
- if (const Handle(SelectMgr_EntityOwner)& aOwner = aEntity->OwnerId())
- {
- theOwners->Add (aOwner);
- }
- }
- }
- }
-}
-
-//=======================================================================
-//function : HasDetectedShape
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
-{
- Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
- return !anOwner.IsNull()
- && anOwner->HasShape();
-}
-
-//=======================================================================
-//function : DetectedShape
-//purpose :
-//=======================================================================
-const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const
-{
- Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
- return anOwner->Shape();
-}
-
-//=======================================================================
-//function : HilightNextDetected
-//purpose :
-//=======================================================================
-Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
- const Standard_Boolean theToRedrawImmediate)
-{
- myMainPM->ClearImmediateDraw();
- if (myDetectedSeq.IsEmpty())
- {
- return 0;
- }
-
- if (++myCurHighlighted > myDetectedSeq.Upper())
- {
- myCurHighlighted = myDetectedSeq.Lower();
- }
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
- if (anOwner.IsNull())
- {
- return 0;
- }
-
- highlightWithColor (anOwner, theView->Viewer());
- myLastPicked = anOwner;
-
- if (theToRedrawImmediate)
- {
- myMainPM->RedrawImmediate (theView->Viewer());
- myMainVwr->RedrawImmediate();
- }
-
- return myCurHighlighted;
-}
-
-//=======================================================================
-//function : HilightPreviousDetected
-//purpose :
-//=======================================================================
-Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
- const Standard_Boolean theToRedrawImmediate)
-{
- myMainPM->ClearImmediateDraw();
- if (myDetectedSeq.IsEmpty())
- {
- return 0;
- }
-
- if (--myCurHighlighted < myDetectedSeq.Lower())
- {
- myCurHighlighted = myDetectedSeq.Upper();
- }
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
- if (anOwner.IsNull())
- {
- return 0;
- }
-
- highlightWithColor (anOwner, theView->Viewer());
- myLastPicked = anOwner;
-
- if (theToRedrawImmediate)
- {
- myMainPM->RedrawImmediate (theView->Viewer());
- myMainVwr->RedrawImmediate();
- }
-
- return myCurHighlighted;
-}
-
-//=======================================================================
-//function : DetectedCurrentOwner
-//purpose :
-//=======================================================================
-Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedCurrentOwner() const
-{
- return MoreDetected()
- ? myMainSel->Picked (myDetectedSeq (myCurDetected))
- : Handle(SelectMgr_EntityOwner)();
-}
-
-//=======================================================================
-//function : DetectedCurrentShape
-//purpose :
-//=======================================================================
-const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
-{
- Standard_DISABLE_DEPRECATION_WARNINGS
- Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
- Standard_ENABLE_DEPRECATION_WARNINGS
- return !aCurrentShape.IsNull()
- ? aCurrentShape->Shape()
- : AIS_InteractiveContext_myDummyShape;
-}
-
-//=======================================================================
-//function : DetectedCurrentObject
-//purpose :
-//=======================================================================
-Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
-{
- return MoreDetected()
- ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
- : Handle(AIS_InteractiveObject)();
-}
+++ /dev/null
-// Created on: 1997-01-29
-// Created by: Robert COUBLANC
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
-#include <AIS_GlobalStatus.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_Selection.hxx>
-#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
-#include <Graphic3d_MapOfStructure.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_StructureManager.hxx>
-#include <Prs3d_BasicAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Quantity_Color.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_OrFilter.hxx>
-#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_Transient.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-//=======================================================================
-//function : SetSelectionModeActive
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetSelectionModeActive (const Handle(AIS_InteractiveObject)& theObj,
- const Standard_Integer theMode,
- const Standard_Boolean theIsActive,
- const AIS_SelectionModesConcurrency theActiveFilter,
- const Standard_Boolean theIsForce)
-{
- if (theObj.IsNull())
- {
- return;
- }
-
- const Handle(AIS_GlobalStatus)* aStat = myObjects.Seek (theObj);
- if (aStat == NULL)
- {
- return;
- }
-
- if (!theIsActive
- || (theMode == -1
- && theActiveFilter == AIS_SelectionModesConcurrency_Single))
- {
- if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
- || theIsForce)
- {
- if (theMode == -1)
- {
- for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
- {
- mgrSelector->Deactivate (theObj, aModeIter.Value());
- }
- }
- else
- {
- mgrSelector->Deactivate (theObj, theMode);
- }
- }
-
- if (theMode == -1)
- {
- (*aStat)->ClearSelectionModes();
- }
- else
- {
- (*aStat)->RemoveSelectionMode (theMode);
- }
- return;
- }
- else if (theMode == -1)
- {
- return;
- }
-
- if ((*aStat)->SelectionModes().Size() == 1
- && (*aStat)->SelectionModes().First() == theMode)
- {
- return;
- }
-
- if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed
- || theIsForce)
- {
- switch (theActiveFilter)
- {
- case AIS_SelectionModesConcurrency_Single:
- {
- for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
- {
- mgrSelector->Deactivate (theObj, aModeIter.Value());
- }
- (*aStat)->ClearSelectionModes();
- break;
- }
- case AIS_SelectionModesConcurrency_GlobalOrLocal:
- {
- const Standard_Integer aGlobSelMode = theObj->GlobalSelectionMode();
- TColStd_ListOfInteger aRemovedModes;
- for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStat)->SelectionModes()); aModeIter.More(); aModeIter.Next())
- {
- if ((theMode == aGlobSelMode && aModeIter.Value() != aGlobSelMode)
- || (theMode != aGlobSelMode && aModeIter.Value() == aGlobSelMode))
- {
- mgrSelector->Deactivate (theObj, aModeIter.Value());
- aRemovedModes.Append (aModeIter.Value());
- }
- }
- if (aRemovedModes.Size() == (*aStat)->SelectionModes().Size())
- {
- (*aStat)->ClearSelectionModes();
- }
- else
- {
- for (TColStd_ListIteratorOfListOfInteger aModeIter (aRemovedModes); aModeIter.More(); aModeIter.Next())
- {
- (*aStat)->RemoveSelectionMode (aModeIter.Value());
- }
- }
- break;
- }
- case AIS_SelectionModesConcurrency_Multiple:
- {
- break;
- }
- }
- mgrSelector->Activate (theObj, theMode);
- }
- (*aStat)->AddSelectionMode (theMode);
-}
-
-// ============================================================================
-// function : Activate
-// purpose :
-// ============================================================================
-void AIS_InteractiveContext::Activate (const Standard_Integer theMode,
- const Standard_Boolean theIsForce)
-{
- AIS_ListOfInteractive aDisplayedObjects;
- DisplayedObjects (aDisplayedObjects);
-
- for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next())
- {
- Load (anIter.Value(), -1);
- Activate (anIter.Value(), theMode, theIsForce);
- }
-
-}
-
-// ============================================================================
-// function : Deactivate
-// purpose :
-// ============================================================================
-void AIS_InteractiveContext::Deactivate (const Standard_Integer theMode)
-{
- AIS_ListOfInteractive aDisplayedObjects;
- DisplayedObjects (aDisplayedObjects);
-
- for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next())
- {
- Deactivate (anIter.Value(), theMode);
- }
-}
-
-// ============================================================================
-// function : Deactivate
-// purpose :
-// ============================================================================
-void AIS_InteractiveContext::Deactivate()
-{
- AIS_ListOfInteractive aDisplayedObjects;
- DisplayedObjects (aDisplayedObjects);
-
- for (AIS_ListIteratorOfListOfInteractive anIter (aDisplayedObjects); anIter.More(); anIter.Next())
- {
- Deactivate (anIter.Value());
- }
-}
-
-//=======================================================================
-//function : ActivatedModes
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::ActivatedModes (const Handle(AIS_InteractiveObject)& theObj,
- TColStd_ListOfInteger& theList) const
-{
- const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
- if (aStatus != NULL)
- {
- for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next())
- {
- theList.Append (aModeIter.Value());
- }
- }
-}
-
-//=======================================================================
-//function : SubIntensityOn
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::
-SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
- const Standard_Boolean updateviewer)
-{
- turnOnSubintensity (anIObj);
- if (updateviewer)
- myMainVwr->Update();
-}
-//=======================================================================
-//function : SubIntensityOff
-//purpose :
-//=======================================================================
-
-void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject)& theObj,
- const Standard_Boolean theToUpdateViewer)
-{
- const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
- if (aStatus == NULL
- || !(*aStatus)->IsSubIntensityOn())
- {
- return;
- }
-
- (*aStatus)->SubIntensityOff();
- Standard_Boolean toUpdateMain = Standard_False;
- if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
- {
- myMainPM->Unhighlight (theObj);
- toUpdateMain = Standard_True;
- }
-
- if (IsSelected (theObj))
- {
- highlightSelected (theObj->GlobalSelOwner());
- }
-
- if (theToUpdateViewer && toUpdateMain)
- {
- myMainVwr->Update();
- }
-}
-
-//=======================================================================
-//function : AddFilter
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::AddFilter(const Handle(SelectMgr_Filter)& aFilter)
-{
- myFilters->Add(aFilter);
-}
-
-//=======================================================================
-//function : RemoveFilter
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
-{
- myFilters->Remove(aFilter);
-}
-
-//=======================================================================
-//function : RemoveFilters
-//purpose :
-//=======================================================================
-
-void AIS_InteractiveContext::RemoveFilters()
-{
- myFilters->Clear();
-}
-
-//=======================================================================
-//function : Filters
-//purpose :
-//=======================================================================
-const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const
-{
- return myFilters->StoredFilters();
-}
-
-//=======================================================================
-//function : DisplayActiveSensitive
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(V3d_View)& aviou)
-{
- myMainSel->DisplaySensitive(aviou);
-}
-//=======================================================================
-//function : DisplayActiveSensitive
-//purpose :
-//=======================================================================
-
-void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_InteractiveObject)& theObj,
- const Handle(V3d_View)& theView)
-{
- const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj);
- if (aStatus == NULL)
- {
- return;
- }
-
- for (TColStd_ListIteratorOfListOfInteger aModeIter ((*aStatus)->SelectionModes()); aModeIter.More(); aModeIter.Next())
- {
- const Handle(SelectMgr_Selection)& aSel = theObj->Selection (aModeIter.Value());
- myMainSel->DisplaySensitive (aSel, theObj->Transformation(), theView, Standard_False);
- }
-}
-
-//=======================================================================
-//function : ClearActiveSensitive
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::ClearActiveSensitive (const Handle(V3d_View)& theView)
-{
- myMainSel->ClearSensitive (theView);
-}
-
-//=======================================================================
-//function : PurgeDisplay
-//purpose :
-//=======================================================================
-
-Standard_Integer AIS_InteractiveContext::PurgeDisplay()
-{
- Standard_Integer NbStr = PurgeViewer(myMainVwr);
- myMainVwr->Update();
- return NbStr;
-}
-
-
-//=======================================================================
-//function : PurgeViewer
-//purpose :
-//=======================================================================
-Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr)
-{
- Handle(Graphic3d_StructureManager) GSM = Vwr->StructureManager();
- Standard_Integer NbCleared(0);
- Graphic3d_MapOfStructure SOS;
- GSM->DisplayedStructures(SOS);
-
- Handle(Graphic3d_Structure) G;
- for(Graphic3d_MapIteratorOfMapOfStructure It(SOS); It.More();It.Next()){
- G = It.Key();
- Standard_Address Add = G->Owner();
- if(Add==NULL){
- G->Erase();
- G->Clear();// it means that it is not referenced as a presentation of InterfactiveObject...
- NbCleared++;
- }
- Handle(AIS_InteractiveObject) IO = (AIS_InteractiveObject*)Add;
- if(!myObjects.IsBound(IO)){
- G->Erase();
- NbCleared++;
- }
- }
- return NbCleared;
-}
-
-//=======================================================================
-//function : IsImmediateModeOn
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
-{
- return myMainPM->IsImmediateModeOn();
-}
-
-//=======================================================================
-//function : BeginImmediateDraw
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
-{
- if (myMainPM->IsImmediateModeOn())
- {
- myMainPM->BeginImmediateDraw();
- return Standard_True;
- }
- return Standard_False;
-}
-
-//=======================================================================
-//function : ImmediateAdd
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj,
- const Standard_Integer theMode)
-{
- if (!myMainPM->IsImmediateModeOn())
- {
- return Standard_False;
- }
-
- myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode));
- return Standard_True;
-}
-
-//=======================================================================
-//function : EndImmediateDraw
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView)
-{
- if (!myMainPM->IsImmediateModeOn())
- {
- return Standard_False;
- }
-
- myMainPM->EndImmediateDraw (theView->Viewer());
- return Standard_True;
-}
-
-//=======================================================================
-//function : EndImmediateDraw
-//purpose :
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
-{
- if (!myMainPM->IsImmediateModeOn())
- {
- return Standard_False;
- }
-
- myMainPM->EndImmediateDraw (myMainVwr);
- return Standard_True;
-}
+++ /dev/null
-// Created on: 2001-01-09
-// Created by: Sergey Altukhov
-// Copyright (c) 2001-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// Modified: 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets
-
-#include <AIS_GlobalStatus.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <Prs3d_BasicAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Quantity_Color.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Filter.hxx>
-#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_Transient.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopLoc_Location.hxx>
-#include <TopoDS_Shape.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-//=======================================================================
-//function : SetPolygonOffsets
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::SetPolygonOffsets(
- const Handle(AIS_InteractiveObject)& anObj,
- const Standard_Integer aMode,
- const Standard_ShortReal aFactor,
- const Standard_ShortReal aUnits,
- const Standard_Boolean updateviewer)
-{
- if ( anObj.IsNull() )
- return;
-
- setContextToObject (anObj);
- anObj->SetPolygonOffsets( aMode, aFactor, aUnits );
-
- const Handle(AIS_GlobalStatus)* aStatus = updateviewer ? myObjects.Seek (anObj) : NULL;
- if (aStatus != NULL
- && anObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
- {
- myMainVwr->Update();
- }
-}
-
-
-//=======================================================================
-//function : HasPolygonOffsets
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_InteractiveContext::HasPolygonOffsets(const Handle(AIS_InteractiveObject)& anObj) const
-{
- return ( !anObj.IsNull() && anObj->HasPolygonOffsets() );
-}
-
-//=======================================================================
-//function : PolygonOffsets
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::PolygonOffsets(
- const Handle(AIS_InteractiveObject)& anObj,
- Standard_Integer& aMode,
- Standard_ShortReal& aFactor,
- Standard_ShortReal& aUnits) const
-{
- if ( HasPolygonOffsets( anObj ) )
- anObj->PolygonOffsets( aMode, aFactor, aUnits );
-}
-// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
-
-//=======================================================================
-//function : DumpJson
-//purpose :
-//=======================================================================
-void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
-{
- OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size())
-
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainSel.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView)
-
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get())
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected)
-
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get())
-
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected])
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic])
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected])
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic])
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity])
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size())
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode)
-}
+++ /dev/null
-// Created on: 1997-04-23
-// Created by: Guest Design
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
AIS_AnimationObject.hxx
AIS_AttributeFilter.cxx
AIS_AttributeFilter.hxx
-AIS_AttributeFilter.lxx
AIS_Axis.cxx
AIS_Axis.hxx
AIS_BadEdgeFilter.cxx
AIS_DragAction.hxx
AIS_ExclusionFilter.cxx
AIS_ExclusionFilter.hxx
-AIS_ExclusionFilter.lxx
AIS_GlobalStatus.cxx
AIS_GlobalStatus.hxx
AIS_GraphicTool.cxx
AIS_IndexedDataMapOfOwnerPrs.hxx
AIS_InteractiveContext.cxx
AIS_InteractiveContext.hxx
-AIS_InteractiveContext_1.cxx
-AIS_InteractiveContext_2.cxx
-AIS_InteractiveContext_3.cxx
AIS_InteractiveObject.cxx
AIS_InteractiveObject.hxx
AIS_KindOfInteractive.hxx
AIS_MouseGesture.hxx
AIS_MultipleConnectedInteractive.cxx
AIS_MultipleConnectedInteractive.hxx
-AIS_MultipleConnectedInteractive.lxx
AIS_NavigationMode.hxx
AIS_NArray1OfEntityOwner.hxx
AIS_NListOfEntityOwner.hxx
V3d_UnMapped.hxx
V3d_View.cxx
V3d_View.hxx
-V3d_View_2.cxx
-V3d_View_3.cxx
-V3d_View_4.cxx
V3d_Viewer.cxx
V3d_Viewer.hxx
-V3d_Viewer_4.cxx
V3d_ViewerPointer.hxx
V3d_ViewPointer.hxx
#include <V3d_View.hxx>
+#include <Aspect_CircularGrid.hxx>
#include <Aspect_GradientBackground.hxx>
#include <Aspect_Grid.hxx>
+#include <Aspect_RectangularGrid.hxx>
#include <Aspect_Window.hxx>
#include <Bnd_Box.hxx>
#include <gp_Ax3.hxx>
return myView->ChangeRenderingParams();
}
+
+//=============================================================================
+//function : SetLightOn
+//purpose :
+//=============================================================================
+void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight)
+{
+ if (!myActiveLights.Contains (theLight))
+ {
+ myActiveLights.Append (theLight);
+ UpdateLights();
+ }
+}
+
+//=============================================================================
+//function : SetLightOff
+//purpose :
+//=============================================================================
+void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight)
+{
+ if (MyViewer->IsGlobalLight (theLight))
+ throw Standard_TypeMismatch("V3d_View::SetLightOff, the light is global");
+ myActiveLights.Remove (theLight);
+ UpdateLights();
+}
+
+//=============================================================================
+//function : IsActiveLight
+//purpose :
+//=============================================================================
+Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const
+{
+ return !theLight.IsNull()
+ && myActiveLights.Contains (theLight);
+}
+
+//=============================================================================
+//function : SetLightOn
+//purpose :
+//=============================================================================
+void V3d_View::SetLightOn()
+{
+ for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next())
+ {
+ if (!myActiveLights.Contains (aDefLightIter.Value()))
+ {
+ myActiveLights.Append (aDefLightIter.Value());
+ }
+ }
+ UpdateLights();
+}
+
+//=============================================================================
+//function : SetLightOff
+//purpose :
+//=============================================================================
+void V3d_View::SetLightOff()
+{
+ for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();)
+ {
+ if (!MyViewer->IsGlobalLight (anActiveLightIter.Value()))
+ {
+ myActiveLights.Remove (anActiveLightIter);
+ }
+ else
+ {
+ anActiveLightIter.Next();
+ }
+ }
+ UpdateLights();
+}
+
+//=============================================================================
+//function : IfMoreLights
+//purpose :
+//=============================================================================
+Standard_Boolean V3d_View::IfMoreLights() const
+{
+ return myActiveLights.Extent() < LightLimit();
+}
+
+//=======================================================================
+//function : LightLimit
+//purpose :
+//=======================================================================
+Standard_Integer V3d_View::LightLimit() const
+{
+ return Viewer()->Driver()->InquireLightLimit();
+}
+
+//=======================================================================
+//function : AddClipPlane
+//purpose :
+//=======================================================================
+void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
+{
+ Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
+ if (aSeqOfPlanes.IsNull())
+ {
+ aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane();
+ }
+ else
+ {
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ if (aPlane == thePlane)
+ {
+ // plane is already defined in view
+ return;
+ }
+ }
+ }
+
+ aSeqOfPlanes->Append (thePlane);
+ SetClipPlanes (aSeqOfPlanes);
+}
+
+//=======================================================================
+//function : RemoveClipPlane
+//purpose :
+//=======================================================================
+void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
+{
+ Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
+ if (aSeqOfPlanes.IsNull())
+ {
+ return;
+ }
+
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ if (aPlane != thePlane)
+ {
+ continue;
+ }
+
+ aSeqOfPlanes->Remove (aPlaneIt);
+ SetClipPlanes (aSeqOfPlanes);
+ return;
+ }
+}
+
+//=======================================================================
+//function : SetClipPlanes
+//purpose :
+//=======================================================================
+void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
+{
+ myView->SetClipPlanes (thePlanes);
+}
+
+//=======================================================================
+//function : ClipPlanes
+//purpose :
+//=======================================================================
+const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const
+{
+ return myView->ClipPlanes();
+}
+
+//=======================================================================
+//function : PlaneLimit
+//purpose :
+//=======================================================================
+Standard_Integer V3d_View::PlaneLimit() const
+{
+ return Viewer()->Driver()->InquirePlaneLimit();
+}
+
+//=============================================================================
+//function : Move
+//purpose :
+//=============================================================================
+void V3d_View::Move (const Standard_Real theDx,
+ const Standard_Real theDy,
+ const Standard_Real theDz,
+ const Standard_Boolean theStart)
+{
+ Handle(Graphic3d_Camera) aCamera = Camera();
+ if (theStart)
+ {
+ myCamStartOpEye = aCamera->Eye();
+
+ gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+ gp_Dir anUp (aCamera->Up());
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
+ }
+ }
+
+ Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
+ myXscreenAxis.Coord (XX,XY,XZ);
+ myYscreenAxis.Coord (YX,YY,YZ);
+ myZscreenAxis.Coord (ZX,ZY,ZZ);
+
+ aCamera->SetEye (myCamStartOpEye);
+
+ aCamera->SetEye (aCamera->Eye().XYZ()
+ + theDx * gp_Pnt (XX, XY, XZ).XYZ()
+ + theDy * gp_Pnt (YX, YY, YZ).XYZ()
+ + theDz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ ImmediateUpdate();
+}
+
+//=============================================================================
+//function : Move
+//purpose :
+//=============================================================================
+void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart)
+{
+ Handle(Graphic3d_Camera) aCamera = Camera();
+ if (theStart)
+ {
+ myCamStartOpEye = aCamera->Eye();
+ }
+ aCamera->SetEye (myCamStartOpEye);
+ aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
+
+ ImmediateUpdate();
+}
+
+//=============================================================================
+//function : Move
+//purpose :
+//=============================================================================
+void V3d_View::Move (const V3d_TypeOfAxe theAxe,
+ const Standard_Real theLength,
+ const Standard_Boolean theStart)
+{
+ switch (theAxe)
+ {
+ case V3d_X:
+ Move (theLength,0.,0.,theStart);
+ break;
+ case V3d_Y:
+ Move (0.,theLength,0.,theStart);
+ break;
+ case V3d_Z:
+ Move (0.,0.,theLength,theStart);
+ break;
+ }
+}
+
+//=============================================================================
+//function : Translate
+//purpose :
+//=============================================================================
+void V3d_View::Translate (const Standard_Real theDx,
+ const Standard_Real theDy,
+ const Standard_Real theDz,
+ const Standard_Boolean theStart)
+{
+ Handle(Graphic3d_Camera) aCamera = Camera();
+ if (theStart)
+ {
+ myCamStartOpEye = aCamera->Eye();
+ myCamStartOpCenter = aCamera->Center();
+
+ gp_Dir aReferencePlane (aCamera->Direction().Reversed());
+ gp_Dir anUp (aCamera->Up());
+ if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
+ {
+ throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
+ }
+ }
+
+ aCamera->SetEye (myCamStartOpEye);
+ aCamera->SetCenter (myCamStartOpCenter);
+
+ aCamera->SetCenter (aCamera->Center().XYZ()
+ - theDx * myXscreenAxis.XYZ()
+ - theDy * myYscreenAxis.XYZ()
+ - theDz * myZscreenAxis.XYZ()
+ );
+
+ aCamera->SetEye (aCamera->Eye().XYZ()
+ - theDx * myXscreenAxis.XYZ()
+ - theDy * myYscreenAxis.XYZ()
+ - theDz * myZscreenAxis.XYZ()
+ );
+
+ ImmediateUpdate();
+}
+
+//=============================================================================
+//function : Translate
+//purpose :
+//=============================================================================
+void V3d_View::Translate (const V3d_TypeOfAxe theAxe, const Standard_Real theLength,const Standard_Boolean theStart)
+{
+ switch (theAxe)
+ {
+ case V3d_X:
+ Translate (theLength,0.,0., theStart);
+ break;
+ case V3d_Y:
+ Translate (0.,theLength,0., theStart);
+ break;
+ case V3d_Z:
+ Translate (0.,0.,theLength, theStart);
+ break;
+ }
+}
+
+//=======================================================================
+//function : Place
+//purpose :
+//=======================================================================
+void V3d_View::Place (const Standard_Integer theXp,
+ const Standard_Integer theYp,
+ const Standard_Real theZoomFactor)
+{
+ Standard_Integer aWinWidth = 0;
+ Standard_Integer aWinHeight = 0;
+ View()->Window()->Size (aWinWidth, aWinHeight);
+
+ Standard_Integer aWinCXp = aWinWidth / 2;
+ Standard_Integer aWinCYp = aWinHeight / 2;
+ Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale());
+}
+
+//=======================================================================
+//function : Translate
+//purpose :
+//=======================================================================
+void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
+{
+ Handle(Graphic3d_Camera) aCamera = Camera();
+ if (theStart)
+ {
+ myCamStartOpCenter = aCamera->Center() ;
+ }
+
+ gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength);
+ aCamera->SetCenter (aNewCenter);
+
+ ImmediateUpdate();
+}
+
+//=============================================================================
+//function : SetGrid
+//purpose :
+//=============================================================================
+void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
+{
+ MyPlane = aPlane;
+ MyGrid = aGrid;
+
+ Standard_Real xl, yl, zl;
+ Standard_Real xdx, xdy, xdz;
+ Standard_Real ydx, ydy, ydz;
+ Standard_Real dx, dy, dz;
+ aPlane.Location ().Coord (xl, yl, zl);
+ aPlane.XDirection ().Coord (xdx, xdy, xdz);
+ aPlane.YDirection ().Coord (ydx, ydy, ydz);
+ aPlane.Direction ().Coord (dx, dy, dz);
+
+ Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
+ Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
+
+ TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
+ Trsf1 (4, 4) = 1.0;
+ Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
+ // Translation
+ Trsf1 (1, 4) = xl,
+ Trsf1 (2, 4) = yl,
+ Trsf1 (3, 4) = zl;
+ // Transformation change of marker
+ Trsf1 (1, 1) = xdx,
+ Trsf1 (2, 1) = xdy,
+ Trsf1 (3, 1) = xdz,
+ Trsf1 (1, 2) = ydx,
+ Trsf1 (2, 2) = ydy,
+ Trsf1 (3, 2) = ydz,
+ Trsf1 (1, 3) = dx,
+ Trsf1 (2, 3) = dy,
+ Trsf1 (3, 3) = dz;
+
+ TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
+ Trsf2 (4, 4) = 1.0;
+ Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
+ // Translation of the origin
+ Trsf2 (1, 4) = -MyGrid->XOrigin (),
+ Trsf2 (2, 4) = -MyGrid->YOrigin (),
+ Trsf2 (3, 4) = 0.0;
+ // Rotation Alpha around axis -Z
+ Trsf2 (1, 1) = CosAlpha,
+ Trsf2 (2, 1) = -SinAlpha,
+ Trsf2 (3, 1) = 0.0,
+ Trsf2 (1, 2) = SinAlpha,
+ Trsf2 (2, 2) = CosAlpha,
+ Trsf2 (3, 2) = 0.0,
+ Trsf2 (1, 3) = 0.0,
+ Trsf2 (2, 3) = 0.0,
+ Trsf2 (3, 3) = 1.0;
+
+ Standard_Real valuetrsf;
+ Standard_Real valueoldtrsf;
+ Standard_Real valuenewtrsf;
+ Standard_Integer i, j, k;
+ // Calculation of the product of matrices
+ for (i=1; i<=4; i++)
+ for (j=1; j<=4; j++) {
+ MyTrsf (i, j) = 0.0;
+ for (k=1; k<=4; k++) {
+ valueoldtrsf = Trsf1 (i, k);
+ valuetrsf = Trsf2 (k, j);
+ valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
+ MyTrsf (i, j) = valuenewtrsf;
+ }
+ }
+}
+
+//=============================================================================
+//function : SetGridActivity
+//purpose :
+//=============================================================================
+void V3d_View::SetGridActivity (const Standard_Boolean AFlag)
+{
+ if (AFlag) MyGrid->Activate ();
+ else MyGrid->Deactivate ();
+}
+
+//=============================================================================
+//function : toPolarCoords
+//purpose :
+//=============================================================================
+void toPolarCoords (const Standard_Real theX, const Standard_Real theY,
+ Standard_Real& theR, Standard_Real& thePhi)
+{
+ theR = Sqrt (theX * theX + theY * theY);
+ thePhi = ATan2 (theY, theX);
+}
+
+//=============================================================================
+//function : toCartesianCoords
+//purpose :
+//=============================================================================
+void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi,
+ Standard_Real& theX, Standard_Real& theY)
+{
+ theX = theR * Cos (thePhi);
+ theY = theR * Sin (thePhi);
+}
+
+//=============================================================================
+//function : Compute
+//purpose :
+//=============================================================================
+Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const
+{
+ const Handle(Graphic3d_Camera)& aCamera = Camera();
+ gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane
+ gp_Dir GPN = MyPlane.Direction();
+
+ Standard_Real XPp = 0.0, YPp = 0.0;
+ Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp);
+
+ // Casw when the plane of the grid and the plane of the view
+ // are perpendicular to MYEPSILON2 close radians
+ #define MYEPSILON2 M_PI / 180.0 // Delta between 2 angles
+ if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2)
+ {
+ return theVertex;
+ }
+
+ const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf);
+
+ // get grid axes in world space
+ const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf);
+ gp_Vec aGridX (aPnt0, aPnt1);
+ aGridX.Normalize();
+
+ const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf);
+ gp_Vec aGridY (aPnt0, aPnt2);
+ aGridY.Normalize();
+
+ // project ray from camera onto grid plane
+ const gp_Vec aProjection = aCamera->IsOrthographic()
+ ? gp_Vec (aCamera->Direction())
+ : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized();
+ const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0);
+ const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction());
+ const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT;
+
+ if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid))
+ {
+ // project point on plane to grid local space
+ const gp_Vec aToPoint (aPnt0, aPointOnPlane);
+ const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep());
+ const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep());
+
+ // clamp point to grid
+ const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep()
+ + aGridY * anYSteps * aRectGrid->YStep()
+ + gp_Vec (aPnt0);
+ return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
+ }
+ else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid))
+ {
+ const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber());
+
+ // project point on plane to grid local space
+ const gp_Vec aToPoint (aPnt0, aPointOnPlane);
+ Standard_Real aLocalX = aGridX.Dot (aToPoint);
+ Standard_Real aLocalY = aGridY.Dot (aToPoint);
+ Standard_Real anR = 0.0, aPhi = 0.0;
+ toPolarCoords (aLocalX, aLocalY, anR, aPhi);
+
+ // clamp point to grid
+ const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep());
+ const Standard_Real aPhiSteps = Round (aPhi / anAlpha);
+ toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY);
+
+ const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0);
+ return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
+ }
+ return Graphic3d_Vertex (0.0, 0.0, 0.0);
+}
+
+//=============================================================================
+//function : ZBufferTriedronSetup
+//purpose :
+//=============================================================================
+void V3d_View::ZBufferTriedronSetup (const Quantity_Color& theXColor,
+ const Quantity_Color& theYColor,
+ const Quantity_Color& theZColor,
+ const Standard_Real theSizeRatio,
+ const Standard_Real theAxisDiametr,
+ const Standard_Integer theNbFacettes)
+{
+ const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
+ aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
+ aTrihedron->SetSizeRatio (theSizeRatio);
+ aTrihedron->SetNbFacets (theNbFacettes);
+ aTrihedron->SetArrowDiameter (theAxisDiametr);
+}
+
+//=============================================================================
+//function : TriedronDisplay
+//purpose :
+//=============================================================================
+void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
+ const Quantity_Color& theColor,
+ const Standard_Real theScale,
+ const V3d_TypeOfVisualization theMode)
+{
+ const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
+ aTrihedron->SetLabelsColor (theColor);
+ aTrihedron->SetScale (theScale);
+ aTrihedron->SetPosition (thePosition);
+ aTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
+
+ aTrihedron->Display (*this);
+}
+
+//=============================================================================
+//function : TriedronErase
+//purpose :
+//=============================================================================
+void V3d_View::TriedronErase()
+{
+ if (!myTrihedron.IsNull())
+ {
+ myTrihedron->Erase();
+ }
+}
+
+//=============================================================================
+//function : GetGraduatedTrihedron
+//purpose :
+//=============================================================================
+const Graphic3d_GraduatedTrihedron& V3d_View::GetGraduatedTrihedron() const
+{
+ return myView->GetGraduatedTrihedron();
+}
+
+//=============================================================================
+//function : GraduatedTrihedronDisplay
+//purpose :
+//=============================================================================
+void V3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
+{
+ myView->GraduatedTrihedronDisplay (theTrihedronData);
+}
+
+//=============================================================================
+//function : GraduatedTrihedronErase
+//purpose :
+//=============================================================================
+void V3d_View::GraduatedTrihedronErase()
+{
+ myView->GraduatedTrihedronErase();
+}
+
// =======================================================================
// function : DumpJson
// purpose :
+++ /dev/null
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-/***********************************************************************
- FONCTION :
- ----------
- Classe V3d_View_2.cxx :
- HISTORIQUE DES MODIFICATIONS :
- --------------------------------
- 00-09-92 : GG ; Creation.
- 24-12-97 : FMN ; Suppression de GEOMLITE
- 23-11-00 : GG ; Add IsActiveLight() and IsActivePlane() methods
-************************************************************************/
-/*
- * Includes
- */
-
-#include <Aspect_GradientBackground.hxx>
-#include <Aspect_Grid.hxx>
-#include <Aspect_Window.hxx>
-#include <Bnd_Box.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Dir.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_TextureEnv.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_TypeMismatch.hxx>
-#include <V3d.hxx>
-#include <V3d_BadValue.hxx>
-#include <V3d_Light.hxx>
-#include <V3d_UnMapped.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-//=============================================================================
-//function : SetLightOn
-//purpose :
-//=============================================================================
-void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight)
-{
- if (!myActiveLights.Contains (theLight))
- {
- myActiveLights.Append (theLight);
- UpdateLights();
- }
-}
-
-//=============================================================================
-//function : SetLightOff
-//purpose :
-//=============================================================================
-void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight)
-{
- if (MyViewer->IsGlobalLight (theLight))
- throw Standard_TypeMismatch("V3d_View::SetLightOff, the light is global");
- myActiveLights.Remove (theLight);
- UpdateLights();
-}
-
-//=============================================================================
-//function : IsActiveLight
-//purpose :
-//=============================================================================
-Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const
-{
- return !theLight.IsNull()
- && myActiveLights.Contains (theLight);
-}
-
-//=============================================================================
-//function : SetLightOn
-//purpose :
-//=============================================================================
-void V3d_View::SetLightOn()
-{
- for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next())
- {
- if (!myActiveLights.Contains (aDefLightIter.Value()))
- {
- myActiveLights.Append (aDefLightIter.Value());
- }
- }
- UpdateLights();
-}
-
-//=============================================================================
-//function : SetLightOff
-//purpose :
-//=============================================================================
-void V3d_View::SetLightOff()
-{
- for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();)
- {
- if (!MyViewer->IsGlobalLight (anActiveLightIter.Value()))
- {
- myActiveLights.Remove (anActiveLightIter);
- }
- else
- {
- anActiveLightIter.Next();
- }
- }
- UpdateLights();
-}
-
-//=============================================================================
-//function : IfMoreLights
-//purpose :
-//=============================================================================
-Standard_Boolean V3d_View::IfMoreLights() const
-{
- return myActiveLights.Extent() < LightLimit();
-}
-
-//=======================================================================
-//function : LightLimit
-//purpose :
-//=======================================================================
-Standard_Integer V3d_View::LightLimit() const
-{
- return Viewer()->Driver()->InquireLightLimit();
-}
-
-//=======================================================================
-//function : AddClipPlane
-//purpose :
-//=======================================================================
-void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
-{
- Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
- if (aSeqOfPlanes.IsNull())
- {
- aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane();
- }
- else
- {
- for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
- if (aPlane == thePlane)
- {
- // plane is already defined in view
- return;
- }
- }
- }
-
- aSeqOfPlanes->Append (thePlane);
- SetClipPlanes (aSeqOfPlanes);
-}
-
-//=======================================================================
-//function : RemoveClipPlane
-//purpose :
-//=======================================================================
-void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
-{
- Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
- if (aSeqOfPlanes.IsNull())
- {
- return;
- }
-
- for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt(*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
- if (aPlane != thePlane)
- continue;
-
- aSeqOfPlanes->Remove (aPlaneIt);
- SetClipPlanes (aSeqOfPlanes);
- return;
- }
-}
-
-//=======================================================================
-//function : SetClipPlanes
-//purpose :
-//=======================================================================
-void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
-{
- myView->SetClipPlanes (thePlanes);
-}
-
-//=======================================================================
-//function : ClipPlanes
-//purpose :
-//=======================================================================
-const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const
-{
- return myView->ClipPlanes();
-}
-
-//=======================================================================
-//function : PlaneLimit
-//purpose :
-//=======================================================================
-Standard_Integer V3d_View::PlaneLimit() const
-{
- return Viewer()->Driver()->InquirePlaneLimit();
-}
+++ /dev/null
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <Aspect_GradientBackground.hxx>
-#include <Aspect_Grid.hxx>
-#include <Aspect_Window.hxx>
-#include <Bnd_Box.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Dir.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_TextureEnv.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_TypeMismatch.hxx>
-#include <V3d_BadValue.hxx>
-#include <V3d_Light.hxx>
-#include <V3d_UnMapped.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-//=============================================================================
-//function : Move
-//purpose :
-//=============================================================================
-void V3d_View::Move (const Standard_Real Dx,
- const Standard_Real Dy,
- const Standard_Real Dz,
- const Standard_Boolean Start)
-{
- Handle(Graphic3d_Camera) aCamera = Camera();
-
- if( Start )
- {
- myCamStartOpEye = aCamera->Eye();
-
- gp_Dir aReferencePlane (aCamera->Direction().Reversed());
- gp_Dir anUp (aCamera->Up());
- if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
- {
- throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
- }
- }
-
- Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
-
- myXscreenAxis.Coord (XX,XY,XZ);
- myYscreenAxis.Coord (YX,YY,YZ);
- myZscreenAxis.Coord (ZX,ZY,ZZ);
-
- aCamera->SetEye (myCamStartOpEye);
-
- aCamera->SetEye (aCamera->Eye().XYZ()
- + Dx * gp_Pnt (XX, XY, XZ).XYZ()
- + Dy * gp_Pnt (YX, YY, YZ).XYZ()
- + Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
- );
-
- ImmediateUpdate();
-}
-
-//=============================================================================
-//function : Move
-//purpose :
-//=============================================================================
-void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart)
-{
- Handle(Graphic3d_Camera) aCamera = Camera();
- if (theStart)
- {
- myCamStartOpEye = aCamera->Eye();
- }
- aCamera->SetEye (myCamStartOpEye);
- aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
-
- ImmediateUpdate();
-}
-
-//=============================================================================
-//function : Move
-//purpose :
-//=============================================================================
-void V3d_View::Move (const V3d_TypeOfAxe Axe , const Standard_Real Length, const Standard_Boolean Start)
-{
- switch (Axe) {
- case V3d_X :
- Move(Length,0.,0.,Start);
- break ;
- case V3d_Y :
- Move(0.,Length,0.,Start);
- break ;
- case V3d_Z :
- Move(0.,0.,Length,Start);
- break ;
- }
-}
-
-//=============================================================================
-//function : Translate
-//purpose :
-//=============================================================================
-void V3d_View::Translate (const Standard_Real Dx,
- const Standard_Real Dy,
- const Standard_Real Dz,
- const Standard_Boolean Start)
-{
- Handle(Graphic3d_Camera) aCamera = Camera();
-
- if( Start )
- {
- myCamStartOpEye = aCamera->Eye();
- myCamStartOpCenter = aCamera->Center();
-
- gp_Dir aReferencePlane (aCamera->Direction().Reversed());
- gp_Dir anUp (aCamera->Up());
- if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
- {
- throw V3d_BadValue("V3d_View::Translate, alignment of Eye,At,Up");
- }
- }
-
- aCamera->SetEye (myCamStartOpEye);
- aCamera->SetCenter (myCamStartOpCenter);
-
- aCamera->SetCenter (aCamera->Center().XYZ()
- - Dx * myXscreenAxis.XYZ()
- - Dy * myYscreenAxis.XYZ()
- - Dz * myZscreenAxis.XYZ()
- );
-
- aCamera->SetEye (aCamera->Eye().XYZ()
- - Dx * myXscreenAxis.XYZ()
- - Dy * myYscreenAxis.XYZ()
- - Dz * myZscreenAxis.XYZ()
- );
-
- ImmediateUpdate();
-}
-
-//=============================================================================
-//function : Translate
-//purpose :
-//=============================================================================
-void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,const Standard_Boolean Start) {
-
- switch (Axe) {
- case V3d_X :
- Translate(Length,0.,0., Start);
- break ;
- case V3d_Y :
- Translate(0.,Length,0., Start);
- break ;
- case V3d_Z :
- Translate(0.,0.,Length, Start);
- break ;
- }
-}
-
-//=======================================================================
-//function : Place
-//purpose :
-//=======================================================================
-void V3d_View::Place (const Standard_Integer theXp,
- const Standard_Integer theYp,
- const Standard_Real theZoomFactor)
-{
- Standard_Integer aWinWidth = 0;
- Standard_Integer aWinHeight = 0;
- View()->Window()->Size (aWinWidth, aWinHeight);
-
- Standard_Integer aWinCXp = aWinWidth / 2;
- Standard_Integer aWinCYp = aWinHeight / 2;
- Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale());
-}
-
-//=======================================================================
-//function : Place
-//purpose :
-//=======================================================================
-void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
-{
- Handle(Graphic3d_Camera) aCamera = Camera();
- if (theStart)
- {
- myCamStartOpCenter = aCamera->Center() ;
- }
-
- gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength);
- aCamera->SetCenter (aNewCenter);
-
- ImmediateUpdate();
-}
+++ /dev/null
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <Aspect_GradientBackground.hxx>
-#include <Aspect_Grid.hxx>
-#include <Aspect_RectangularGrid.hxx>
-#include <Aspect_Window.hxx>
-#include <Bnd_Box.hxx>
-#include <gp_Ax3.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Dir2d.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_TextureEnv.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard_MultiplyDefined.hxx>
-#include <Standard_TypeMismatch.hxx>
-#include <TColStd_Array2OfReal.hxx>
-#include <V3d_BadValue.hxx>
-#include <V3d_CircularGrid.hxx>
-#include <V3d_Light.hxx>
-#include <V3d_RectangularGrid.hxx>
-#include <V3d_UnMapped.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-#include <Aspect_CircularGrid.hxx>
-
-#define MYEPSILON1 0.0001 // Comparison with 0.0
-#define MYEPSILON2 M_PI / 180. // Delta between 2 angles
-
-//=============================================================================
-//function : SetGrid
-//purpose :
-//=============================================================================
-void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
-{
- MyPlane = aPlane;
- MyGrid = aGrid;
-
- Standard_Real xl, yl, zl;
- Standard_Real xdx, xdy, xdz;
- Standard_Real ydx, ydy, ydz;
- Standard_Real dx, dy, dz;
- aPlane.Location ().Coord (xl, yl, zl);
- aPlane.XDirection ().Coord (xdx, xdy, xdz);
- aPlane.YDirection ().Coord (ydx, ydy, ydz);
- aPlane.Direction ().Coord (dx, dy, dz);
-
- Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
- Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
-
- TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
- Trsf1 (4, 4) = 1.0;
- Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
- // Translation
- Trsf1 (1, 4) = xl,
- Trsf1 (2, 4) = yl,
- Trsf1 (3, 4) = zl;
- // Transformation change of marker
- Trsf1 (1, 1) = xdx,
- Trsf1 (2, 1) = xdy,
- Trsf1 (3, 1) = xdz,
- Trsf1 (1, 2) = ydx,
- Trsf1 (2, 2) = ydy,
- Trsf1 (3, 2) = ydz,
- Trsf1 (1, 3) = dx,
- Trsf1 (2, 3) = dy,
- Trsf1 (3, 3) = dz;
-
- TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
- Trsf2 (4, 4) = 1.0;
- Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
- // Translation of the origin
- Trsf2 (1, 4) = -MyGrid->XOrigin (),
- Trsf2 (2, 4) = -MyGrid->YOrigin (),
- Trsf2 (3, 4) = 0.0;
- // Rotation Alpha around axis -Z
- Trsf2 (1, 1) = CosAlpha,
- Trsf2 (2, 1) = -SinAlpha,
- Trsf2 (3, 1) = 0.0,
- Trsf2 (1, 2) = SinAlpha,
- Trsf2 (2, 2) = CosAlpha,
- Trsf2 (3, 2) = 0.0,
- Trsf2 (1, 3) = 0.0,
- Trsf2 (2, 3) = 0.0,
- Trsf2 (3, 3) = 1.0;
-
- Standard_Real valuetrsf;
- Standard_Real valueoldtrsf;
- Standard_Real valuenewtrsf;
- Standard_Integer i, j, k;
- // Calculation of the product of matrices
- for (i=1; i<=4; i++)
- for (j=1; j<=4; j++) {
- MyTrsf (i, j) = 0.0;
- for (k=1; k<=4; k++) {
- valueoldtrsf = Trsf1 (i, k);
- valuetrsf = Trsf2 (k, j);
- valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
- MyTrsf (i, j) = valuenewtrsf;
- }
- }
-}
-
-//=============================================================================
-//function : SetGridActivity
-//purpose :
-//=============================================================================
-void V3d_View::SetGridActivity (const Standard_Boolean AFlag)
-{
- if (AFlag) MyGrid->Activate ();
- else MyGrid->Deactivate ();
-}
-
-//=============================================================================
-//function : toPolarCoords
-//purpose :
-//=============================================================================
-void toPolarCoords (const Standard_Real theX, const Standard_Real theY,
- Standard_Real& theR, Standard_Real& thePhi)
-{
- theR = Sqrt (theX * theX + theY * theY);
- thePhi = ATan2 (theY, theX);
-}
-
-//=============================================================================
-//function : toCartesianCoords
-//purpose :
-//=============================================================================
-void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi,
- Standard_Real& theX, Standard_Real& theY)
-{
- theX = theR * Cos (thePhi);
- theY = theR * Sin (thePhi);
-}
-
-//=============================================================================
-//function : Compute
-//purpose :
-//=============================================================================
-Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const
-{
- const Handle(Graphic3d_Camera)& aCamera = Camera();
- gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane
- gp_Dir GPN = MyPlane.Direction();
-
- Standard_Real XPp = 0.0, YPp = 0.0;
- Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp);
-
- // Casw when the plane of the grid and the plane of the view
- // are perpendicular to MYEPSILON2 close radians
- if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2)
- {
- return theVertex;
- }
-
- const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf);
-
- // get grid axes in world space
- const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf);
- gp_Vec aGridX (aPnt0, aPnt1);
- aGridX.Normalize();
-
- const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf);
- gp_Vec aGridY (aPnt0, aPnt2);
- aGridY.Normalize();
-
- // project ray from camera onto grid plane
- const gp_Vec aProjection = aCamera->IsOrthographic()
- ? gp_Vec (aCamera->Direction())
- : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized();
- const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0);
- const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction());
- const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT;
-
- if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid))
- {
- // project point on plane to grid local space
- const gp_Vec aToPoint (aPnt0, aPointOnPlane);
- const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep());
- const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep());
-
- // clamp point to grid
- const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep()
- + aGridY * anYSteps * aRectGrid->YStep()
- + gp_Vec (aPnt0);
- return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
- }
- else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid))
- {
- const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber());
-
- // project point on plane to grid local space
- const gp_Vec aToPoint (aPnt0, aPointOnPlane);
- Standard_Real aLocalX = aGridX.Dot (aToPoint);
- Standard_Real aLocalY = aGridY.Dot (aToPoint);
- Standard_Real anR = 0.0, aPhi = 0.0;
- toPolarCoords (aLocalX, aLocalY, anR, aPhi);
-
- // clamp point to grid
- const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep());
- const Standard_Real aPhiSteps = Round (aPhi / anAlpha);
- toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY);
-
- const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0);
- return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
- }
- return Graphic3d_Vertex (0.0, 0.0, 0.0);
-}
-
-//=============================================================================
-//function : ZBufferTriedronSetup
-//purpose :
-//=============================================================================
-void V3d_View::ZBufferTriedronSetup(const Quantity_Color& theXColor,
- const Quantity_Color& theYColor,
- const Quantity_Color& theZColor,
- const Standard_Real theSizeRatio,
- const Standard_Real theAxisDiametr,
- const Standard_Integer theNbFacettes)
-{
- const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
- aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
- aTrihedron->SetSizeRatio (theSizeRatio);
- aTrihedron->SetNbFacets (theNbFacettes);
- aTrihedron->SetArrowDiameter (theAxisDiametr);
-}
-
-//=============================================================================
-//function : TriedronDisplay
-//purpose :
-//=============================================================================
-void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
- const Quantity_Color& theColor,
- const Standard_Real theScale,
- const V3d_TypeOfVisualization theMode)
-{
- const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
- aTrihedron->SetLabelsColor (theColor);
- aTrihedron->SetScale (theScale);
- aTrihedron->SetPosition (thePosition);
- aTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
-
- aTrihedron->Display (*this);
-}
-
-//=============================================================================
-//function : TriedronErase
-//purpose :
-//=============================================================================
-void V3d_View::TriedronErase()
-{
- if (!myTrihedron.IsNull())
- {
- myTrihedron->Erase();
- }
-}
-
-//=============================================================================
-//function : GetGraduatedTrihedron
-//purpose :
-//=============================================================================
-const Graphic3d_GraduatedTrihedron& V3d_View::GetGraduatedTrihedron() const
-{
- return myView->GetGraduatedTrihedron();
-}
-
-//=============================================================================
-//function : GraduatedTrihedronDisplay
-//purpose :
-//=============================================================================
-void V3d_View::GraduatedTrihedronDisplay(const Graphic3d_GraduatedTrihedron& theTrihedronData)
-{
- myView->GraduatedTrihedronDisplay (theTrihedronData);
-}
-
-//=============================================================================
-//function : GraduatedTrihedronErase
-//purpose :
-//=============================================================================
-void V3d_View::GraduatedTrihedronErase()
-{
- myView->GraduatedTrihedronErase();
-}
#include <Aspect_Grid.hxx>
#include <Aspect_IdentDefinitionError.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Text.hxx>
#include <Standard_ErrorHandler.hxx>
-#include <Standard_Type.hxx>
#include <V3d.hxx>
#include <V3d_BadValue.hxx>
#include <V3d_CircularGrid.hxx>
myPlaneStructure->Display();
}
+// =======================================================================
+// function : Grid
+// purpose :
+// =======================================================================
+Handle(Aspect_Grid) V3d_Viewer::Grid (Aspect_GridType theGridType, bool theToCreate)
+{
+ switch (theGridType)
+ {
+ case Aspect_GT_Circular:
+ {
+ if (myCGrid.IsNull() && theToCreate)
+ {
+ myCGrid = new V3d_CircularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+ }
+ return Handle(Aspect_Grid) (myCGrid);
+ }
+ case Aspect_GT_Rectangular:
+ {
+ if (myRGrid.IsNull() && theToCreate)
+ {
+ myRGrid = new V3d_RectangularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+ }
+ return Handle(Aspect_Grid) (myRGrid);
+ }
+ }
+ return Handle(Aspect_Grid)();
+}
+
+// =======================================================================
+// function : GridDrawMode
+// purpose :
+// =======================================================================
+Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
+{
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ return !aGrid.IsNull() ? aGrid->DrawMode() : Aspect_GDM_Lines;
+}
+
+// =======================================================================
+// function : ActivateGrid
+// purpose :
+// =======================================================================
+void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
+ const Aspect_GridDrawMode theMode)
+{
+ if (Handle(Aspect_Grid) anOldGrid = Grid (false))
+ {
+ anOldGrid->Erase();
+ }
+
+ myGridType = theType;
+ Handle(Aspect_Grid) aGrid = Grid (true);
+ aGrid->SetDrawMode (theMode);
+ if (theMode != Aspect_GDM_None)
+ {
+ aGrid->Display();
+ }
+ aGrid->Activate();
+ for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
+ }
+}
+
+// =======================================================================
+// function : DeactivateGrid
+// purpose :
+// =======================================================================
+void V3d_Viewer::DeactivateGrid()
+{
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ if (aGrid.IsNull())
+ {
+ return;
+ }
+
+ aGrid->Erase();
+ aGrid->Deactivate();
+
+ myGridType = Aspect_GT_Rectangular;
+ for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->SetGridActivity (Standard_False);
+ if (myGridEcho
+ && !myGridEchoStructure.IsNull())
+ {
+ myGridEchoStructure->Erase();
+ }
+ }
+}
+
+// =======================================================================
+// function : IsGridActive
+// purpose :
+// =======================================================================
+Standard_Boolean V3d_Viewer::IsGridActive()
+{
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ return !aGrid.IsNull() && aGrid->IsActive();
+}
+
+// =======================================================================
+// function : RectangularGridValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::RectangularGridValues (Standard_Real& theXOrigin,
+ Standard_Real& theYOrigin,
+ Standard_Real& theXStep,
+ Standard_Real& theYStep,
+ Standard_Real& theRotationAngle)
+{
+ Grid (Aspect_GT_Rectangular, true);
+ theXOrigin = myRGrid->XOrigin();
+ theYOrigin = myRGrid->YOrigin();
+ theXStep = myRGrid->XStep();
+ theYStep = myRGrid->YStep();
+ theRotationAngle = myRGrid->RotationAngle();
+}
+
+// =======================================================================
+// function : SetRectangularGridValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetRectangularGridValues (const Standard_Real theXOrigin,
+ const Standard_Real theYOrigin,
+ const Standard_Real theXStep,
+ const Standard_Real theYStep,
+ const Standard_Real theRotationAngle)
+{
+ Grid (Aspect_GT_Rectangular, true);
+ myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
+ for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myRGrid);
+ }
+}
+
+// =======================================================================
+// function : CircularGridValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::CircularGridValues (Standard_Real& theXOrigin,
+ Standard_Real& theYOrigin,
+ Standard_Real& theRadiusStep,
+ Standard_Integer& theDivisionNumber,
+ Standard_Real& theRotationAngle)
+{
+ Grid (Aspect_GT_Circular, true);
+ theXOrigin = myCGrid->XOrigin();
+ theYOrigin = myCGrid->YOrigin();
+ theRadiusStep = myCGrid->RadiusStep();
+ theDivisionNumber = myCGrid->DivisionNumber();
+ theRotationAngle = myCGrid->RotationAngle();
+}
+
+// =======================================================================
+// function : SetCircularGridValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetCircularGridValues (const Standard_Real theXOrigin,
+ const Standard_Real theYOrigin,
+ const Standard_Real theRadiusStep,
+ const Standard_Integer theDivisionNumber,
+ const Standard_Real theRotationAngle)
+{
+ Grid (Aspect_GT_Circular, true);
+ myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
+ theDivisionNumber, theRotationAngle);
+ for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myCGrid);
+ }
+}
+
+// =======================================================================
+// function : RectangularGridGraphicValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::RectangularGridGraphicValues (Standard_Real& theXSize,
+ Standard_Real& theYSize,
+ Standard_Real& theOffSet)
+{
+ Grid (Aspect_GT_Rectangular, true);
+ myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
+}
+
+// =======================================================================
+// function : SetRectangularGridGraphicValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetRectangularGridGraphicValues (const Standard_Real theXSize,
+ const Standard_Real theYSize,
+ const Standard_Real theOffSet)
+{
+ Grid (Aspect_GT_Rectangular, true);
+ myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
+}
+
+// =======================================================================
+// function : CircularGridGraphicValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::CircularGridGraphicValues (Standard_Real& theRadius,
+ Standard_Real& theOffSet)
+{
+ Grid (Aspect_GT_Circular, true);
+ myCGrid->GraphicValues (theRadius, theOffSet);
+}
+
+// =======================================================================
+// function : SetCircularGridGraphicValues
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetCircularGridGraphicValues (const Standard_Real theRadius,
+ const Standard_Real theOffSet)
+{
+ Grid (Aspect_GT_Circular, true);
+ myCGrid->SetGraphicValues (theRadius, theOffSet);
+}
+
+// =======================================================================
+// function : SetGridEcho
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
+{
+ if (myGridEcho == theToShowGrid)
+ {
+ return;
+ }
+
+ myGridEcho = theToShowGrid;
+ if (theToShowGrid
+ || myGridEchoStructure.IsNull())
+ {
+ return;
+ }
+
+ myGridEchoStructure->Erase();
+}
+
+// =======================================================================
+// function : SetGridEcho
+// purpose :
+// =======================================================================
+void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker)
+{
+ if (myGridEchoStructure.IsNull())
+ {
+ myGridEchoStructure = new Graphic3d_Structure (StructureManager());
+ myGridEchoGroup = myGridEchoStructure->NewGroup();
+ }
+
+ myGridEchoAspect = theMarker;
+ myGridEchoGroup->SetPrimitivesAspect (theMarker);
+}
+
+// =======================================================================
+// function : ShowGridEcho
+// purpose :
+// =======================================================================
+void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
+ const Graphic3d_Vertex& theVertex)
+{
+ if (!myGridEcho)
+ {
+ return;
+ }
+
+ if (myGridEchoStructure.IsNull())
+ {
+ myGridEchoStructure = new Graphic3d_Structure (StructureManager());
+ myGridEchoGroup = myGridEchoStructure->NewGroup();
+
+ myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
+ myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
+ }
+
+ if (theVertex.X() == myGridEchoLastVert.X()
+ && theVertex.Y() == myGridEchoLastVert.Y()
+ && theVertex.Z() == myGridEchoLastVert.Z())
+ {
+ return;
+ }
+
+ myGridEchoLastVert = theVertex;
+ myGridEchoGroup->Clear();
+ myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
+
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
+ anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
+ myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
+
+ myGridEchoStructure->SetZLayer (Graphic3d_ZLayerId_Topmost);
+ myGridEchoStructure->SetInfiniteState (Standard_True);
+ myGridEchoStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
+ myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
+ myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), true);
+ myGridEchoStructure->Display();
+}
+
+// =======================================================================
+// function : HideGridEcho
+// purpose :
+// =======================================================================
+void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView)
+{
+ if (myGridEchoStructure.IsNull())
+ {
+ return;
+ }
+
+ myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast());
+ const Handle(Graphic3d_ViewAffinity)& anAffinity = myGridEchoStructure->CStructure()->ViewAffinity;
+ if (!anAffinity.IsNull() && anAffinity->IsVisible (theView->View()->Identification()))
+ {
+ myGridEchoStructure->Erase();
+ }
+}
+
//=======================================================================
//function : DumpJson
//purpose :
+++ /dev/null
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <Aspect_Background.hxx>
-#include <Aspect_GradientBackground.hxx>
-#include <Aspect_Grid.hxx>
-#include <gp_Ax3.hxx>
-#include <Graphic3d_ArrayOfPoints.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Quantity_Color.hxx>
-#include <V3d_BadValue.hxx>
-#include <V3d_CircularGrid.hxx>
-#include <V3d_Light.hxx>
-#include <V3d_RectangularGrid.hxx>
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-// =======================================================================
-// function : Grid
-// purpose :
-// =======================================================================
-Handle(Aspect_Grid) V3d_Viewer::Grid (Aspect_GridType theGridType, bool theToCreate)
-{
- switch (theGridType)
- {
- case Aspect_GT_Circular:
- {
- if (myCGrid.IsNull() && theToCreate)
- {
- myCGrid = new V3d_CircularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
- }
- return Handle(Aspect_Grid) (myCGrid);
- }
- case Aspect_GT_Rectangular:
- {
- if (myRGrid.IsNull() && theToCreate)
- {
- myRGrid = new V3d_RectangularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
- }
- return Handle(Aspect_Grid) (myRGrid);
- }
- }
- return Handle(Aspect_Grid)();
-}
-
-// =======================================================================
-// function : GridDrawMode
-// purpose :
-// =======================================================================
-Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
-{
- Handle(Aspect_Grid) aGrid = Grid (false);
- return !aGrid.IsNull() ? aGrid->DrawMode() : Aspect_GDM_Lines;
-}
-
-// =======================================================================
-// function : ActivateGrid
-// purpose :
-// =======================================================================
-void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
- const Aspect_GridDrawMode theMode)
-{
- if (Handle(Aspect_Grid) anOldGrid = Grid (false))
- {
- anOldGrid->Erase();
- }
-
- myGridType = theType;
- Handle(Aspect_Grid) aGrid = Grid (true);
- aGrid->SetDrawMode (theMode);
- if (theMode != Aspect_GDM_None)
- {
- aGrid->Display();
- }
- aGrid->Activate();
- for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
- }
-}
-
-// =======================================================================
-// function : DeactivateGrid
-// purpose :
-// =======================================================================
-void V3d_Viewer::DeactivateGrid()
-{
- Handle(Aspect_Grid) aGrid = Grid (false);
- if (aGrid.IsNull())
- {
- return;
- }
-
- aGrid->Erase();
- aGrid->Deactivate();
-
- myGridType = Aspect_GT_Rectangular;
- for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- anActiveViewIter.Value()->SetGridActivity (Standard_False);
- if (myGridEcho
- && !myGridEchoStructure.IsNull())
- {
- myGridEchoStructure->Erase();
- }
- }
-}
-
-// =======================================================================
-// function : IsGridActive
-// purpose :
-// =======================================================================
-Standard_Boolean V3d_Viewer::IsGridActive()
-{
- Handle(Aspect_Grid) aGrid = Grid (false);
- return !aGrid.IsNull() && aGrid->IsActive();
-}
-
-// =======================================================================
-// function : RectangularGridValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::RectangularGridValues (Standard_Real& theXOrigin,
- Standard_Real& theYOrigin,
- Standard_Real& theXStep,
- Standard_Real& theYStep,
- Standard_Real& theRotationAngle)
-{
- Grid (Aspect_GT_Rectangular, true);
- theXOrigin = myRGrid->XOrigin();
- theYOrigin = myRGrid->YOrigin();
- theXStep = myRGrid->XStep();
- theYStep = myRGrid->YStep();
- theRotationAngle = myRGrid->RotationAngle();
-}
-
-// =======================================================================
-// function : SetRectangularGridValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetRectangularGridValues (const Standard_Real theXOrigin,
- const Standard_Real theYOrigin,
- const Standard_Real theXStep,
- const Standard_Real theYStep,
- const Standard_Real theRotationAngle)
-{
- Grid (Aspect_GT_Rectangular, true);
- myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
- for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myRGrid);
- }
-}
-
-// =======================================================================
-// function : CircularGridValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::CircularGridValues (Standard_Real& theXOrigin,
- Standard_Real& theYOrigin,
- Standard_Real& theRadiusStep,
- Standard_Integer& theDivisionNumber,
- Standard_Real& theRotationAngle)
-{
- Grid (Aspect_GT_Circular, true);
- theXOrigin = myCGrid->XOrigin();
- theYOrigin = myCGrid->YOrigin();
- theRadiusStep = myCGrid->RadiusStep();
- theDivisionNumber = myCGrid->DivisionNumber();
- theRotationAngle = myCGrid->RotationAngle();
-}
-
-// =======================================================================
-// function : SetCircularGridValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetCircularGridValues (const Standard_Real theXOrigin,
- const Standard_Real theYOrigin,
- const Standard_Real theRadiusStep,
- const Standard_Integer theDivisionNumber,
- const Standard_Real theRotationAngle)
-{
- Grid (Aspect_GT_Circular, true);
- myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
- theDivisionNumber, theRotationAngle);
- for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
- {
- anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myCGrid);
- }
-}
-
-// =======================================================================
-// function : RectangularGridGraphicValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::RectangularGridGraphicValues (Standard_Real& theXSize,
- Standard_Real& theYSize,
- Standard_Real& theOffSet)
-{
- Grid (Aspect_GT_Rectangular, true);
- myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
-}
-
-// =======================================================================
-// function : SetRectangularGridGraphicValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetRectangularGridGraphicValues (const Standard_Real theXSize,
- const Standard_Real theYSize,
- const Standard_Real theOffSet)
-{
- Grid (Aspect_GT_Rectangular, true);
- myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
-}
-
-// =======================================================================
-// function : CircularGridGraphicValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::CircularGridGraphicValues (Standard_Real& theRadius,
- Standard_Real& theOffSet)
-{
- Grid (Aspect_GT_Circular, true);
- myCGrid->GraphicValues (theRadius, theOffSet);
-}
-
-// =======================================================================
-// function : SetCircularGridGraphicValues
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetCircularGridGraphicValues (const Standard_Real theRadius,
- const Standard_Real theOffSet)
-{
- Grid (Aspect_GT_Circular, true);
- myCGrid->SetGraphicValues (theRadius, theOffSet);
-}
-
-// =======================================================================
-// function : SetGridEcho
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
-{
- if (myGridEcho == theToShowGrid)
- {
- return;
- }
-
- myGridEcho = theToShowGrid;
- if (theToShowGrid
- || myGridEchoStructure.IsNull())
- {
- return;
- }
-
- myGridEchoStructure->Erase();
-}
-
-// =======================================================================
-// function : SetGridEcho
-// purpose :
-// =======================================================================
-void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker)
-{
- if (myGridEchoStructure.IsNull())
- {
- myGridEchoStructure = new Graphic3d_Structure (StructureManager());
- myGridEchoGroup = myGridEchoStructure->NewGroup();
- }
-
- myGridEchoAspect = theMarker;
- myGridEchoGroup->SetPrimitivesAspect (theMarker);
-}
-
-// =======================================================================
-// function : ShowGridEcho
-// purpose :
-// =======================================================================
-void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
- const Graphic3d_Vertex& theVertex)
-{
- if (!myGridEcho)
- {
- return;
- }
-
- if (myGridEchoStructure.IsNull())
- {
- myGridEchoStructure = new Graphic3d_Structure (StructureManager());
- myGridEchoGroup = myGridEchoStructure->NewGroup();
-
- myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
- myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
- }
-
- if (theVertex.X() == myGridEchoLastVert.X()
- && theVertex.Y() == myGridEchoLastVert.Y()
- && theVertex.Z() == myGridEchoLastVert.Z())
- {
- return;
- }
-
- myGridEchoLastVert = theVertex;
- myGridEchoGroup->Clear();
- myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
-
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
- anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
- myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
-
- myGridEchoStructure->SetZLayer (Graphic3d_ZLayerId_Topmost);
- myGridEchoStructure->SetInfiniteState (Standard_True);
- myGridEchoStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
- myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
- myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), true);
- myGridEchoStructure->Display();
-}
-
-// =======================================================================
-// function : HideGridEcho
-// purpose :
-// =======================================================================
-void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView)
-{
- if (myGridEchoStructure.IsNull())
- {
- return;
- }
-
- myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast());
- const Handle(Graphic3d_ViewAffinity)& anAffinity = myGridEchoStructure->CStructure()->ViewAffinity;
- if (!anAffinity.IsNull() && anAffinity->IsVisible (theView->View()->Identification()))
- myGridEchoStructure->Erase();
-}