Skip to content

Commit

Permalink
0029367: Visualization - simplify interface of V3d_View and V3d_Viewer
Browse files Browse the repository at this point in the history
The interface of V3d_View and V3d_Viewer has been simplified.
For the fields myDefinedViews, myActiveViews, myDefinedLights, myActiveLights were added appropriate methods returning the internal raw data.
Make the next methods deprecated:
IfMoreLights(), InitActiveLights(), MoreActiveLights(), NextActiveLights(), ActiveLight() and
InitActiveViews(), MoreActiveViews(), NextActiveViews(), ActiveView(), InitDefinedViews(), MoreDefinedViews(), NextDefinedViews(), DefinedView(),
InitActiveLights(), MoreActiveLights(), NextActiveLights(), ActiveLight(), InitDefinedLights(), MoreDefinedLights(), NextDefinedLights(), DefinedLight().

Remove deprecated methods added in scope of tasks 0029290 and 0028987 (Target Version 7.3.0):
SelectMgr_SelectableObject: Init(), More(), Next(), CurrentSelection().
SelectMgr_Selection: Init(), More(), Next(), Sensitive().
V3d_AmbientLight: one constructor.
V3d_DirectionalLight: two constructors.
V3d_PositionalLight: one constructor.
V3d_SpotLight: two constructors.
  • Loading branch information
osa authored and apn committed Nov 1, 2019
1 parent 67312b7 commit f7fc0c0
Show file tree
Hide file tree
Showing 26 changed files with 141 additions and 356 deletions.
3 changes: 1 addition & 2 deletions samples/mfc/standard/01_Geometry/src/GeomSources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ void GeomSources::DisplaySurface(CGeometryDoc* aDoc,

void GeomSources::ResetView(CGeometryDoc* aDoc)
{
aDoc->GetAISContext()->CurrentViewer()->InitActiveViews();
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveView();
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveViews().First();
aView->Reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void TexturesExt_Presentation::DoSample()
void TexturesExt_Presentation::Init()
{
// initialize v3d_view so it displays TexturesExt well
getViewer()->InitActiveViews();
Handle(V3d_View) aView = getViewer()->ActiveView();
Handle(V3d_View) aView = getViewer()->ActiveViews().First();
aView->SetSize(ZVIEW_SIZE);

// getDocument()->UpdateResultMessageDlg("Textured Shape",
Expand Down
3 changes: 1 addition & 2 deletions samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,7 @@ void CViewer3dDoc::OnDumpView()
pView->UpdateWindow();
}

myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
Handle(V3d_View) aView = myViewer->ActiveViews().First();
ExportView (aView);
}

Expand Down
54 changes: 25 additions & 29 deletions samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,65 +1012,61 @@ aParams.NbMsaaSamples = aParams.NbMsaaSamples == 0 ? 8 : 0;\n\
GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
}

void CViewer3dView::OnClearLights()
void CViewer3dView::OnClearLights()
{
// Setting Off all viewer active lights
TColStd_ListOfTransient lights;
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())
// Setting Off all viewer active lights
V3d_ListOfLight lights;
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())
{
lights.Append(myView->Viewer()->ActiveLight());
lights.Append (anIter.Value());
}
TColStd_ListIteratorOfListOfTransient itrLights(lights);
V3d_ListOfLightIterator itrLights(lights);
for (; itrLights.More(); itrLights.Next())
{
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
myView->Viewer()->SetLightOff(light);
myView->Viewer()->SetLightOff (itrLights.Value());
}

// Setting Off all view active lights
// Setting Off all view active lights
lights.Clear();
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())
{
lights.Append(myView->ActiveLight());
lights.Append (anIter.Value());
}
itrLights.Initialize(lights);
itrLights.Initialize (lights);
for (; itrLights.More(); itrLights.Next())
{
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
myView->SetLightOff(light);
myView->SetLightOff (itrLights.Value());
}

myView->Viewer()->SetDefaultLights();// Setting the default lights on
myView->Viewer()->SetDefaultLights(); // Setting the default lights on

NbActiveLights = 2;// There are 2 default active lights
NbActiveLights = 2; // There are 2 default active lights

myView->Update();
myView->Update();

TCollection_AsciiString Message("\
// Setting Off all viewer active lights\n\
TColStd_ListOfTransient lights;\n\
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())\n\
// Setting Off all viewer active lights\n\
V3d_ListOfLight lights;\n\
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
{\n\
lights.Append(myView->Viewer()->ActiveLight());\n\
lights.Append (anIter.Value());\n\
}\n\
TColStd_ListIteratorOfListOfTransient itrLights(lights);\n\
V3d_ListOfLightIterator itrLights(lights);\n\
for (; itrLights.More(); itrLights.Next())\n\
{\n\
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
myView->Viewer()->SetLightOff(light);\n\
myView->Viewer()->SetLightOff (itrLights.Value())\n\
}\n\
\n\
// Setting Off all view active lights\n\
// Setting Off all view active lights\n\
lights.Clear();\n\
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())\n\
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
{\n\
lights.Append(myView->ActiveLight());\n\
lights.Append (anIter.Value());\n\
}\n\
itrLights.Initialize(lights);\n\
for (; itrLights.More(); itrLights.Next())\n\
{\n\
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
myView->SetLightOff(light);\n\
myView->SetLightOff (itrLights.Value());\n\
}\n\
\n\
myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ void CTriangulationDoc::OnDumpView()
pView->UpdateWindow();
}

myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
Handle(V3d_View) aView = myViewer->ActiveViews().First();
ExportView (aView);
}

Expand Down
3 changes: 1 addition & 2 deletions samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ void COCCDemoDoc::OnDumpView()
pView->UpdateWindow();
}

myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
Handle(V3d_View) aView = myViewer->ActiveViews().First();
ExportView (aView);
}

Expand Down
3 changes: 1 addition & 2 deletions samples/mfc/standard/Common/OCC_3dBaseDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ void OCC_3dBaseDoc::OnUpdateV3dButtons (CCmdUI* pCmdUI)
// Common function to change raytracing params and redraw view
void OCC_3dBaseDoc::OnObjectRayTracingAction()
{
myAISContext->CurrentViewer()->InitActiveViews();
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveView();
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveViews().First();
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
if (myRayTracingIsOn)
aParams.Method = Graphic3d_RM_RAYTRACING;
Expand Down
5 changes: 0 additions & 5 deletions src/AIS/AIS_ColorScale.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,6 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
//=======================================================================
Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const
{
{
Handle(V3d_Viewer) aViewer = GetContext()->CurrentViewer();
aViewer->InitActiveViews(); // for AIS_ColorScale::TextSize()
}

Standard_Integer aWidthMax = 0;
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theLabels); aLabIter.More(); aLabIter.Next())
{
Expand Down
1 change: 0 additions & 1 deletion src/SelectMgr/SelectMgr_SelectableObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ namespace
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
myGlobalSelMode (0),
mycurrent (0),
myAutoHilight (Standard_True)
{
//
Expand Down
19 changes: 0 additions & 19 deletions src/SelectMgr/SelectMgr_SelectableObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,6 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;

public:

//! Begins the iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
void Init() { mycurrent = 1; }

//! Continues the iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
Standard_Boolean More() const { return mycurrent <= myselections.Length(); }

//! Continues the iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
void Next() { ++mycurrent; }

//! Returns the current selection in this framework.
Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); }

protected:

//! Protected empty constructor.
Expand All @@ -214,7 +196,6 @@ protected:
Handle(Prs3d_Presentation) mySelectionPrs; //!< optional presentation for highlighting selected object
Handle(Prs3d_Presentation) myHilightPrs; //!< optional presentation for highlighting detected object
Standard_Integer myGlobalSelMode; //!< global selection mode
Standard_Integer mycurrent; //!< [deprecated] iterator value
Standard_Boolean myAutoHilight; //!< auto-highlighting flag defining

};
Expand Down
3 changes: 1 addition & 2 deletions src/SelectMgr/SelectMgr_Selection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient)
// Purpose :
//==================================================
SelectMgr_Selection::SelectMgr_Selection (const Standard_Integer theModeIdx)
: myEntityIter (0),
myMode (theModeIdx),
: myMode (theModeIdx),
mySelectionState (SelectMgr_SOS_Unknown),
myBVHUpdateStatus (SelectMgr_TBU_None),
mySensFactor (2),
Expand Down
20 changes: 0 additions & 20 deletions src/SelectMgr/SelectMgr_Selection.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,6 @@ public:
//! Return entities.
NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }

//! Begins an iteration scanning for sensitive primitives.
Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
void Init() { myEntityIter = myEntities.Lower(); }

//! Continues the iteration scanning for sensitive
//! primitives with the mode defined in this framework.
Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
Standard_Boolean More() const { return myEntityIter <= myEntities.Upper(); }

//! Returns the next sensitive primitive found in the
//! iteration. This is a scan for entities with the mode
//! defined in this framework.
Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
void Next() { ++myEntityIter; }

//! Returns any sensitive primitive in this framework.
Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
const Handle(SelectMgr_SensitiveEntity)& Sensitive() const { return myEntities.Value (myEntityIter); }

//! Returns the flag UpdateFlag.
//! This flage gives the update status of this framework
//! in a ViewerSelector object:
Expand Down Expand Up @@ -142,7 +123,6 @@ public:
private:

NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
Standard_Integer myEntityIter;
Standard_Integer myMode;
SelectMgr_TypeOfUpdate myUpdateStatus;
mutable SelectMgr_StateOfSelection mySelectionState;
Expand Down
15 changes: 0 additions & 15 deletions src/V3d/V3d_AmbientLight.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,3 @@ V3d_AmbientLight::V3d_AmbientLight (const Quantity_Color& theColor)
{
SetColor (theColor);
}

// =======================================================================
// function : V3d_AmbientLight
// purpose :
// =======================================================================
V3d_AmbientLight::V3d_AmbientLight (const Handle(V3d_Viewer)& theViewer,
const Quantity_Color& theColor)
: Graphic3d_CLight (Graphic3d_TOLS_AMBIENT)
{
SetColor (theColor);
if (!theViewer.IsNull())
{
theViewer->AddLight (this);
}
}
6 changes: 0 additions & 6 deletions src/V3d/V3d_AmbientLight.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public:
//! The default Color of this light source is WHITE.
Standard_EXPORT V3d_AmbientLight (const Quantity_Color& theColor = Quantity_NOC_WHITE);

//! Constructs an ambient light source in the viewer.
//! The default Color of this light source is WHITE.
Standard_DEPRECATED("This constructor is deprecated - the light source should be added to V3d_Viewer explicitly by method V3d_Viewer::AddLight()")
Standard_EXPORT V3d_AmbientLight (const Handle(V3d_Viewer)& theViewer,
const Quantity_Color& theColor = Quantity_NOC_WHITE);

//! @name hidden properties not applicable to ambient light
private:

Expand Down
39 changes: 2 additions & 37 deletions src/V3d/V3d_DirectionalLight.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_DirectionalLight,V3d_PositionLight)
V3d_DirectionalLight::V3d_DirectionalLight (const V3d_TypeOfOrientation theDirection,
const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL, Handle(V3d_Viewer)())
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL)
{
SetColor (theColor);
SetHeadlight (theIsHeadlight);
Expand All @@ -38,48 +38,13 @@ V3d_DirectionalLight::V3d_DirectionalLight (const V3d_TypeOfOrientation theDirec
V3d_DirectionalLight::V3d_DirectionalLight (const gp_Dir& theDirection,
const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL, Handle(V3d_Viewer)())
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL)
{
SetColor (theColor);
SetHeadlight (theIsHeadlight);
SetDirection (theDirection);
}

// =======================================================================
// function : V3d_DirectionalLight
// purpose :
// =======================================================================
V3d_DirectionalLight::V3d_DirectionalLight (const Handle(V3d_Viewer)& theViewer,
const V3d_TypeOfOrientation theDirection,
const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL, theViewer)
{
SetColor (theColor);
SetHeadlight (theIsHeadlight);
SetDirection (V3d::GetProjAxis (theDirection));
}

// =======================================================================
// function : V3d_DirectionalLight
// purpose :
// =======================================================================
V3d_DirectionalLight::V3d_DirectionalLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Real theXt,
const Standard_Real theYt,
const Standard_Real theZt,
const Standard_Real theXp,
const Standard_Real theYp,
const Standard_Real theZp,
const Quantity_Color& theColor,
const Standard_Boolean theIsHeadlight)
: V3d_PositionLight (Graphic3d_TOLS_DIRECTIONAL, theViewer)
{
SetColor (theColor);
SetHeadlight (theIsHeadlight);
SetDirection (gp_Dir (gp_XYZ (theXt, theYt, theZt) - gp_XYZ(theXp, theYp, theZp)));
}

// =======================================================================
// function : SetDirection
// purpose :
Expand Down
23 changes: 0 additions & 23 deletions src/V3d/V3d_DirectionalLight.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,6 @@ public:
Standard_EXPORT void SetDirection (V3d_TypeOfOrientation theDirection);
using Graphic3d_CLight::SetDirection;

public:

Standard_DEPRECATED("This constructor is deprecated - the light source should be added to V3d_Viewer explicitly by method V3d_Viewer::AddLight()")
Standard_EXPORT V3d_DirectionalLight (const Handle(V3d_Viewer)& theViewer,
const V3d_TypeOfOrientation theDirection = V3d_XposYposZpos,
const Quantity_Color& theColor = Quantity_NOC_WHITE,
const Standard_Boolean theIsHeadlight = Standard_False);

//! Creates a directional light source in the viewer.
//! theXt, theYt, theZt : Coordinate of light source Target.
//! theXp, theYp, theZp : Coordinate of light source Position.
//! The others parameters describe before.
Standard_DEPRECATED("This constructor is deprecated - the light source should be added to V3d_Viewer explicitly by method V3d_Viewer::AddLight()")
Standard_EXPORT V3d_DirectionalLight (const Handle(V3d_Viewer)& theViewer,
const Standard_Real theXt,
const Standard_Real theYt,
const Standard_Real theZt,
const Standard_Real theXp,
const Standard_Real theYp,
const Standard_Real theZp,
const Quantity_Color& theColor = Quantity_NOC_WHITE,
const Standard_Boolean theIsHeadlight = Standard_False);

//! @name hidden properties not applicable to directional light
private:

Expand Down
9 changes: 1 addition & 8 deletions src/V3d/V3d_PositionLight.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@

#include <V3d_PositionLight.hxx>

#include <V3d_Viewer.hxx>

IMPLEMENT_STANDARD_RTTIEXT(V3d_PositionLight, Graphic3d_CLight)

// =======================================================================
// function : V3d_PositionLight
// purpose :
// =======================================================================
V3d_PositionLight::V3d_PositionLight (Graphic3d_TypeOfLightSource theType,
const Handle(V3d_Viewer)& theViewer)
V3d_PositionLight::V3d_PositionLight (Graphic3d_TypeOfLightSource theType)
: Graphic3d_CLight (theType)
{
if (!theViewer.IsNull())
{
theViewer->AddLight (this);
}
}
Loading

0 comments on commit f7fc0c0

Please sign in to comment.