0027900: Coding rules - drop redundant Name parameter from V3d_Viewer constructor
[occt.git] / src / V3d / V3d_View_2.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14/***********************************************************************
7fd59977 15 FONCTION :
16 ----------
17 Classe V3d_View_2.cxx :
7fd59977 18 HISTORIQUE DES MODIFICATIONS :
19 --------------------------------
20 00-09-92 : GG ; Creation.
21 24-12-97 : FMN ; Suppression de GEOMLITE
7fd59977 22 23-11-00 : GG ; Add IsActiveLight() and IsActivePlane() methods
7fd59977 23************************************************************************/
7fd59977 24/*
25 * Includes
26 */
27
42cf5bc1 28#include <Aspect_GradientBackground.hxx>
29#include <Aspect_Grid.hxx>
30#include <Aspect_Window.hxx>
31#include <Bnd_Box.hxx>
32#include <gp_Ax3.hxx>
33#include <gp_Dir.hxx>
34#include <Graphic3d_Group.hxx>
c357e426 35#include <Graphic3d_GraphicDriver.hxx>
42cf5bc1 36#include <Graphic3d_Structure.hxx>
37#include <Graphic3d_TextureEnv.hxx>
38#include <Graphic3d_Vector.hxx>
39#include <Quantity_Color.hxx>
40#include <Standard_MultiplyDefined.hxx>
41#include <Standard_TypeMismatch.hxx>
7fd59977 42#include <V3d.hxx>
42cf5bc1 43#include <V3d_BadValue.hxx>
42cf5bc1 44#include <V3d_Light.hxx>
45#include <V3d_UnMapped.hxx>
46#include <V3d_View.hxx>
47#include <V3d_Viewer.hxx>
c357e426 48
49//=============================================================================
50//function : SetLightOn
51//purpose :
52//=============================================================================
53void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight)
54{
6a24c6de 55 if (!myActiveLights.Contains (theLight))
c357e426 56 {
6a24c6de 57 V3d_BadValue_Raise_if (myActiveLights.Extent() >= LightLimit(),
c357e426 58 "V3d_View::SetLightOn, "
59 "too many lights");
6a24c6de 60 myActiveLights.Append (theLight);
c357e426 61 UpdateLights();
7fd59977 62 }
63}
64
c357e426 65//=============================================================================
66//function : SetLightOff
67//purpose :
68//=============================================================================
69void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight)
70{
71 Standard_TypeMismatch_Raise_if (MyViewer->IsGlobalLight (theLight),
72 "V3d_View::SetLightOff, "
73 "the light is global");
6a24c6de 74 myActiveLights.Remove (theLight);
c357e426 75 UpdateLights();
7fd59977 76}
77
c357e426 78//=============================================================================
79//function : IsActiveLight
80//purpose :
81//=============================================================================
82Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const
83{
6a24c6de 84 return !theLight.IsNull()
85 && myActiveLights.Contains (theLight);
7fd59977 86}
87
c357e426 88//=============================================================================
89//function : SetLightOn
90//purpose :
91//=============================================================================
92void V3d_View::SetLightOn()
93{
6a24c6de 94 for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next())
c357e426 95 {
6a24c6de 96 if (!myActiveLights.Contains (aDefLightIter.Value()))
c357e426 97 {
6a24c6de 98 myActiveLights.Append (aDefLightIter.Value());
7fd59977 99 }
100 }
c357e426 101 UpdateLights();
7fd59977 102}
103
c357e426 104//=============================================================================
105//function : SetLightOff
106//purpose :
107//=============================================================================
108void V3d_View::SetLightOff()
109{
6a24c6de 110 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();)
c357e426 111 {
6a24c6de 112 if (!MyViewer->IsGlobalLight (anActiveLightIter.Value()))
c357e426 113 {
6a24c6de 114 myActiveLights.Remove (anActiveLightIter);
7fd59977 115 }
116 else
c357e426 117 {
6a24c6de 118 anActiveLightIter.Next();
c357e426 119 }
7fd59977 120 }
c357e426 121 UpdateLights();
7fd59977 122}
123
c357e426 124//=============================================================================
125//function : IfMoreLights
126//purpose :
127//=============================================================================
128Standard_Boolean V3d_View::IfMoreLights() const
129{
6a24c6de 130 return myActiveLights.Extent() < LightLimit();
c357e426 131}
7fd59977 132
c357e426 133//=======================================================================
134//function : LightLimit
135//purpose :
136//=======================================================================
137Standard_Integer V3d_View::LightLimit() const
138{
139 return Viewer()->Driver()->InquireLightLimit();
7fd59977 140}
4269bd1b 141
142//=======================================================================
143//function : AddClipPlane
144//purpose :
145//=======================================================================
146void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
147{
3202bf1e 148 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
149 if (aSeqOfPlanes.IsNull())
150 {
151 aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane();
152 }
153
154 aSeqOfPlanes->Append (thePlane);
c357e426 155 SetClipPlanes (aSeqOfPlanes);
4269bd1b 156}
157
158//=======================================================================
159//function : RemoveClipPlane
160//purpose :
161//=======================================================================
162void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
163{
3202bf1e 164 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
165 if (aSeqOfPlanes.IsNull())
166 {
167 return;
168 }
169
170 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt(*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
51b10cd4 171 {
172 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
173 if (aPlane != thePlane)
174 continue;
175
3202bf1e 176 aSeqOfPlanes->Remove (aPlaneIt);
c357e426 177 SetClipPlanes (aSeqOfPlanes);
4269bd1b 178 return;
51b10cd4 179 }
4269bd1b 180}
181
182//=======================================================================
183//function : SetClipPlanes
184//purpose :
185//=======================================================================
3202bf1e 186void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
4269bd1b 187{
c357e426 188 myView->SetClipPlanes (thePlanes);
4269bd1b 189}
190
191//=======================================================================
3202bf1e 192//function : ClipPlanes
4269bd1b 193//purpose :
194//=======================================================================
3202bf1e 195const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const
4269bd1b 196{
c357e426 197 return myView->ClipPlanes();
198}
199
200//=======================================================================
201//function : PlaneLimit
202//purpose :
203//=======================================================================
204Standard_Integer V3d_View::PlaneLimit() const
205{
206 return Viewer()->Driver()->InquirePlaneLimit();
4269bd1b 207}