1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 /***********************************************************************
22 Classe V3d_View_2.cxx :
24 HISTORIQUE DES MODIFICATIONS :
25 --------------------------------
26 00-09-92 : GG ; Creation.
27 24-12-97 : FMN ; Suppression de GEOMLITE
28 21-02-00 : GG ; Add Transparency() method
29 23-11-00 : GG ; Add IsActiveLight() and IsActivePlane() methods
31 ************************************************************************/
33 #define GER61454 //GG 13-09-99 Activates model clipping planes
34 // Use myView->PlaneLimit() instead Visual3d_ClipPlane::Limit()
35 // Use myView->LightLimit() instead Visual3d_Light::Limit()
39 /*----------------------------------------------------------------------*/
44 #include <V3d_View.jxx>
45 #include <Visual3d_View.hxx>
46 #include <Visual3d_Light.hxx>
47 #include <V3d_Static.hxx>
50 /*----------------------------------------------------------------------*/
52 void V3d_View::SetLightOn( const Handle(V3d_Light)& TheLight ) {
54 if( !MyActiveLights.Contains(TheLight)){
56 V3d_BadValue_Raise_if( MyActiveLights.Extent() >= MyView->LightLimit(),
59 // V3d_BadValue_Raise_if( MyActiveLights.Extent() >= Visual3d_Light::Limit(),
60 // "too many lights");
62 MyActiveLights.Append(TheLight) ;
63 MyViewContext.SetLightOn(TheLight->Light());
64 MyView->SetContext(MyViewContext);
68 void V3d_View::SetLightOff( const Handle(V3d_Light)& TheLight ) {
70 Standard_TypeMismatch_Raise_if(MyViewer->IsGlobalLight(TheLight),"the light is global");
72 MyActiveLights.Remove(TheLight);
73 MyViewContext.SetLightOff(TheLight->Light()) ;
74 MyView->SetContext(MyViewContext) ;
77 Standard_Boolean V3d_View::IsActiveLight(const Handle(V3d_Light)& aLight) const {
78 if( aLight.IsNull() ) return Standard_False;
79 return MyActiveLights.Contains(aLight);
82 void V3d_View::SetLightOn( ) {
84 for(MyViewer->InitDefinedLights();MyViewer->MoreDefinedLights();MyViewer->NextDefinedLights()){
85 if(!MyActiveLights.Contains(MyViewer->DefinedLight())){
86 MyActiveLights.Append(MyViewer->DefinedLight()) ;
87 MyViewContext.SetLightOn(MyViewer->DefinedLight()->Light());
90 MyView->SetContext(MyViewContext) ;
94 void V3d_View::SetLightOff( ) {
97 while(MoreActiveLights()) {
98 if (!MyViewer->IsGlobalLight(ActiveLight())) {
99 MyActiveLights.Remove(ActiveLight());
100 MyViewContext.SetLightOff(ActiveLight()->Light());
105 MyView->SetContext(MyViewContext) ;
109 void V3d_View::SetTransparency(const Standard_Boolean AnActivity) {
111 MyTransparencyFlag = AnActivity;
112 MyView->SetTransparency(AnActivity);
116 Standard_Boolean V3d_View::Transparency() const {
118 return MyTransparencyFlag;
121 void V3d_View::InitActiveLights() {
122 myActiveLightsIterator.Initialize(MyActiveLights);
124 Standard_Boolean V3d_View::MoreActiveLights () const {
125 return myActiveLightsIterator.More();
127 void V3d_View::NextActiveLights () {
128 myActiveLightsIterator.Next();
130 Handle(V3d_Light) V3d_View::ActiveLight() const {
131 return (Handle(V3d_Light)&)(myActiveLightsIterator.Value());}
133 Standard_Boolean V3d_View::IfMoreLights() const {
136 return MyActiveLights.Extent() < MyView->LightLimit();
138 // return MyActiveLights.Extent() < Visual3d_Light::Limit();
139 return MyActiveLights.Extent();
143 //=======================================================================
144 //function : AddClipPlane
146 //=======================================================================
147 void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
149 MyViewContext.ChangeClipPlanes().Append (thePlane);
150 MyView->SetContext (MyViewContext);
153 //=======================================================================
154 //function : RemoveClipPlane
156 //=======================================================================
157 void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
159 Graphic3d_SequenceOfHClipPlane& aSeqOfPlanes = MyViewContext.ChangeClipPlanes();
160 Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (aSeqOfPlanes);
161 for (; aPlaneIt.More(); aPlaneIt.Next())
163 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
164 if (aPlane != thePlane)
167 aSeqOfPlanes.Remove (aPlaneIt);
168 MyView->SetContext (MyViewContext);
173 //=======================================================================
174 //function : SetClipPlanes
176 //=======================================================================
177 void V3d_View::SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes)
179 MyViewContext.ChangeClipPlanes() = thePlanes;
180 MyView->SetContext (MyViewContext);
183 //=======================================================================
184 //function : GetClipPlanes
186 //=======================================================================
187 const Graphic3d_SequenceOfHClipPlane& V3d_View::GetClipPlanes() const
189 return MyViewContext.ClipPlanes();