myDrawer->ArrowAspect()->SetLength (10.0);
Graphic3d_MaterialAspect aShadingMaterial;
- aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+ aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
+ aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
+ aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
aShadingMaterial.SetTransparency (0.0);
Graphic3d_MaterialAspect aBackMaterial;
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
aHighlightMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+ myDynHilightDrawer->SetShadingAspect (new Prs3d_ShadingAspect);
myDynHilightDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myDynHilightDrawer->ShadingAspect()->SetMaterial (aHighlightMaterial);
myDynHilightDrawer->ShadingAspect()->SetColor (Quantity_NOC_CYAN1);
Standard_Integer aHeight = 0;
myView->Window()->Size (aWidth, aHeight);
- if (myPosition & Aspect_TOTP_CENTER)
- {
- return Graphic3d_Vec2i (aWidth / 2, aHeight / 2);
- }
-
- Graphic3d_Vec2i aPosition;
+ Graphic3d_Vec2i aPosition (aWidth / 2, aHeight / 2);
if (myPosition & Aspect_TOTP_TOP)
{
aPosition.y() = myOffset.y();
SetView (theView);
theContext->Display (this, 0, 0, Standard_False);
+ SetViewAffinity (theView);
+}
+
+//=======================================================================
+//function : SetViewAffinity
+//purpose :
+//=======================================================================
+void AIS_ViewCube::SetViewAffinity (const Handle(V3d_View)& theView)
+{
+ const Handle(AIS_InteractiveContext)& aContext = GetContext();
+ if (aContext.IsNull())
+ {
+ return;
+ }
// Set view affinity for child object
- Handle(Graphic3d_ViewAffinity) anAffinity = GetContext()->CurrentViewer()->StructureManager()->RegisterObject (myFlatPart);
+ myFlatPart->Presentation()->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity;
+ myFlatPart->Presentation()->CStructure()->ViewAffinity->SetVisible (Standard_False);
+
+ Handle(Graphic3d_ViewAffinity) anAffinity = aContext->CurrentViewer()->StructureManager()->ObjectAffinity (this);
anAffinity->SetVisible (Standard_False);
// View Affinity should be applied after Display
- for (V3d_ListOfViewIterator aViewIter (theContext->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
+ /*for (V3d_ListOfViewIterator aViewIter (aContext->CurrentViewer()->DefinedViewIterator()); aViewIter.More(); aViewIter.Next())
{
- theContext->SetViewAffinity (this, aViewIter.Value(), Standard_False);
- aViewIter.Value()->View()->ChangeHiddenObjects()->Add (myFlatPart.get());
-
+ aContext->SetViewAffinity (this, aViewIter.Value(), Standard_False);
}
- theContext->SetViewAffinity (this, theView, Standard_True);
+ aContext->SetViewAffinity (this, theView, Standard_True);
+ */
+
anAffinity->SetVisible (theView->View()->Identification(), Standard_True);
- theView->View()->ChangeHiddenObjects()->Remove (myFlatPart.get());
+ myFlatPart->Presentation()->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), Standard_True);
+
}
//=======================================================================
//purpose :
//=======================================================================
Standard_Integer AIS_ViewCube::addPart (const Handle(Part)& thePart,
- const gp_Dir& theDir, const gp_Dir& theUp,
- const Standard_Integer thePriority)
+ const gp_Dir& theDir, const gp_Dir& theUp,
+ const Standard_Integer thePriority)
{
Handle(SelectMgr_EntityOwner) anOwner = new AIS_ViewCubeOwner (this, thePriority);
myStates.Add (anOwner, new CameraStateReplace (theDir, theUp));
//purpose :
//=======================================================================
Standard_Integer AIS_ViewCube::addPart (const Handle(Part)& thePart,
- const Standard_Real theAngleX, const Standard_Real theAngleY, const Standard_Real theAngleZ,
- const Standard_Integer thePriority)
+ const Standard_Real theAngleX, const Standard_Real theAngleY, const Standard_Real theAngleZ,
+ const Standard_Integer thePriority)
{
Handle(SelectMgr_EntityOwner) anOwner = new AIS_ViewCubeOwner (this, thePriority);
myStates.Add (anOwner, new CameraStateRotate (theAngleX, theAngleY, theAngleZ));
//purpose :
//=======================================================================
void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
- const Handle(Prs3d_Drawer)& theStyle,
- const Handle(SelectMgr_EntityOwner)& theOwner)
+ const Handle(Prs3d_Drawer)& theStyle,
+ const Handle(SelectMgr_EntityOwner)& theOwner)
{
if (theOwner.IsNull())
{
return;
}
+ // Manage view affinity if it is enabled for object
+ Handle(Graphic3d_ViewAffinity) anAffinity = GetContext()->CurrentViewer()->StructureManager()->ObjectAffinity (this);
+ if (anAffinity->IsVisible (View()->View()->Identification()))
+ {
+ if (aPresentation->CStructure()->ViewAffinity.IsNull())
+ {
+ aPresentation->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity;
+ }
+ aPresentation->CStructure()->ViewAffinity->SetVisible (Standard_False);
+ aPresentation->CStructure()->ViewAffinity->SetVisible (View()->View()->Identification(), Standard_True);
+ }
+
aPresentation->Highlight (theStyle);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
aTopRight = aTopLeft.XYZ() + aPosition.XDirection().XYZ() * aSize;
aBottomRight = aBottomLeft.XYZ() + aPosition.XDirection().XYZ() * aSize;
const Standard_Real aCoef = aSize * 0.5;
- gp_Ax2 aTextPosition (aPosition.Translated (gp_Vec (aPosition.XDirection().XYZ() * aCoef + aPosition.YDirection().XYZ() * aCoef + aPosition.Direction().XYZ() * aSize * 0.01)));
+ gp_Ax2 aTextPosition (aPosition.Translated (gp_Vec (aPosition.XDirection().XYZ() * aCoef + aPosition.YDirection().XYZ() * aCoef + aPosition.Direction().XYZ() * aSize * 0.02)));
Handle(Graphic3d_ArrayOfTriangles) anArray;
Handle(Poly_Triangulation) aTri;
//! Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
//! aViewCube->AddTo (aContext, aView);
//! @endcode
-//! or
+//! or it can be just be displayed without iew affinity option (in this case it will be displayed in all views):
//! @code
-//! aView->SetView (aView);
-//! aContext->Display (aViewCube, 0, 0, Standard_False);
+//! Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
+//! Handle(AIS_InteractiveContext) aContext;
+//! aContext->Display (aViewCube, Standard_False);
//! @endcode
-//! But View Affinity should be taken into account here also.
+//!
//! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection), and every its owner corresponds to camera transformation.
//! So, once one of the owners of View Cube is detected, application is to be call StartTransform (anOwner) and Transform (anOwner) for starting
//! animation of transformation.
//! that includes transformation loop.
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterTransform(),
//! that is to be redefined on application level.
+//! Note that after modification end no highlighting is restored by default.
+//! This means that after transformation of box if mouse pointer still points to box, it will not be highlighted.
+//! Highlighting restoring of box is to be made on application level with AIS_InteracitveContext::MoveTo() method.
//!
//! @b Positioning:
//! View Cube is attached to one defined point in the view plane. This point of attachment is placed in the center of view
//! @param theView [in] 3D view.
Standard_EXPORT void AddTo (const Handle(AIS_InteractiveContext)& theContext, const Handle(V3d_View)& theView);
+ //! Make view cube visible only in the input view
+ //! @param theView [in] V3d View object
+ //! @warning This method should be called after View Cube is displayed in context
+ //! or it will have no effect
+ Standard_EXPORT void SetViewAffinity (const Handle(V3d_View)& theView);
+
//! Hide View Cube in view
Standard_EXPORT void Hide();
//! Set default visual attributes
Standard_EXPORT void setDefaultAttributes();
+ //! Set default dynamic highlight properties
Standard_EXPORT void setDefaultHighlightAttributes();
public: //! @name Geometry management API
+ //! @return position of center of View Cube in terms of 2d trandform persistence.
+ //! @sa Aspect_TypeOfTriedronPosition, Graphic3d_Vec2i
Standard_EXPORT void Position (Aspect_TypeOfTriedronPosition& thePosition,
Graphic3d_Vec2i& theOffset);
+ //! @return position of center of View Cube in screen cooordinates
+ //! (origin of system if topleft corner).
Standard_EXPORT Graphic3d_Vec2i Position() const;
//! Set position of center of View Cube in view plane depending on size of view.
# Color
# -------------------------------------
vviewcube -enable -boxcolor 0.69 0.88 1 -arrowcolor 0 0.4 0.54 -textcolor 0 0.4 0.54
-if {[vreadpixel 118 273 name] != "LIGHTSLATEGRAY 1" || [vreadpixel 270 260 name] != "GRAY15 0.24705882352941178"} {
+if {[vreadpixel 118 273 name] != "LIGHTSLATEGRAY 1" || [vreadpixel 270 260 name] != "GRAY15 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube colors."
}
vdump $anImage1
# -------------------------------------
vviewcube -reset
vviewcube -transparency 0.5
-if {[vreadpixel 118 273 name] != "GRAY17 0.37254901960784315" || [vreadpixel 270 260 name] != "GRAY48 0.24705882352941178"} {
+if {[vreadpixel 118 273 name] != "GRAY17 0.37254902720451355" || [vreadpixel 270 260 name] != "GRAY48 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube common transparency."
}
vdump $anImage2
vviewcube -reset
vviewcube -boxtransparency 0.4 -arrowtransparency 0.2
-if {[vreadpixel 118 273 name] != "GRAY16 0.50588235294117645" || [vreadpixel 270 260 name] != "GRAY76 0.63921568627450975"} {
+if {[vreadpixel 118 273 name] != "GRAY16 0.5058823823928833" || [vreadpixel 270 260 name] != "GRAY76 0.63921570777893066"} {
puts "ERROR: Errors in changing View Cube separate transparency."
}
vdump $anImage3
# -------------------------------------
vviewcube -reset
vviewcube -arrowangle 30 -arrowlength 30
-if {[vreadpixel 270 268 name] != "BLACK 0" || [vreadpixel 291 259 name] != "GRAY48 0.24705882352941178"} {
+if {[vreadpixel 270 268 name] != "BLACK 0" || [vreadpixel 291 259 name] != "GRAY48 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube arrow style."
}
vdump $anImage4
# -------------------------------------
vviewcube -reset
vviewcube -font "Impact" -fontheight 16
-if {[vreadpixel 151 198 name] != "BLACK 1" || [vreadpixel 168 391 name] != "RED 1"} {
+if {[vreadpixel 150 200 name] != "BLACK 0.729411780834198" || [vreadpixel 168 391 name] != "RED 1"} {
puts "ERROR: Errors in changing View Cube font."
}
vdump $anImage5