+// 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_SpotLight :
-
HISTORIQUE DES MODIFICATIONS :
--------------------------------
00-09-92 : GG ; Creation.
- 18-06-96 : FMN ; Ajout MyGraphicStructure1 pour sauvegarder snopick
- 30-03-98 : ZOV ; PRO6774 (reconstruction of the class hierarchy and suppressing useless methods)
- IMP230300: GG Add SetColor() and Color() methods
- IMP231100: GG Add IsDisplayed() method
-
************************************************************************/
-
/*----------------------------------------------------------------------*/
/*
* Includes
*/
+#include <Graphic3d_Structure.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard_Type.hxx>
#include <V3d.hxx>
-#include <V3d_Light.ixx>
-
-//-Declarations
-
-
-//-Aliases
-
-//-Global data definitions
-
-//-Local data definitions
-
-//-Constructors
-
-V3d_Light::V3d_Light(const Handle(V3d_Viewer)& VM) {
-
- MyType = V3d_AMBIENT ;
- VM->AddLight(this) ;
+#include <V3d_BadValue.hxx>
+#include <V3d_Light.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(V3d_Light,MMgt_TShared)
+
+// =======================================================================
+// function : V3d_Light
+// purpose :
+// =======================================================================
+V3d_Light::V3d_Light (const Handle(V3d_Viewer)& theViewer)
+{
+ SetType (V3d_AMBIENT);
+ theViewer->AddLight (this);
}
-//-Methods, in order
-
-Handle(Visual3d_Light) V3d_Light::Light() const {
-
- return MyLight ;
+// =======================================================================
+// function : SetType
+// purpose :
+// =======================================================================
+void V3d_Light::SetType (const V3d_TypeOfLight theType)
+{
+ myLight.Type = (Graphic3d_TypeOfLightSource)theType;
}
-void V3d_Light::SetColor(const Quantity_TypeOfColor Type, const Standard_Real v1, const Standard_Real v2, const Standard_Real v3) {
- Standard_Real V1 = v1 ;
- Standard_Real V2 = v2 ;
- Standard_Real V3 = v3 ;
-
- if( V1 < 0. ) V1 = 0. ; else if( V1 > 1. ) V1 = 1. ;
- if( V2 < 0. ) V2 = 0. ; else if( V2 > 1. ) V2 = 1. ;
- if( V3 < 0. ) V3 = 0. ; else if( V3 > 1. ) V3 = 1. ;
-
-
- Quantity_Color C(V1,V2,V3,Type) ;
- MyLight->SetColor(C) ;
+// =======================================================================
+// function : SetColor
+// purpose :
+// =======================================================================
+void V3d_Light::SetColor (const Quantity_Color& theColor)
+{
+ myLight.Color.r() = static_cast<Standard_ShortReal> (theColor.Red());
+ myLight.Color.g() = static_cast<Standard_ShortReal> (theColor.Green());
+ myLight.Color.b() = static_cast<Standard_ShortReal> (theColor.Blue());
}
-void V3d_Light::SetColor(const Quantity_NameOfColor Name) {
- Quantity_Color C(Name) ;
- MyLight->SetColor(C) ;
+// =======================================================================
+// function : Type
+// purpose :
+// =======================================================================
+V3d_TypeOfLight V3d_Light::Type() const
+{
+ return (V3d_TypeOfLight)myLight.Type;
}
-void V3d_Light::SetColor(const Quantity_Color& aColor) {
- MyLight->SetColor(aColor) ;
-}
-
-void V3d_Light::Color(const Quantity_TypeOfColor Type, Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const {
-
- Quantity_Color C ;
- C = MyLight->Color() ;
- C.Values(V1,V2,V3,Type) ;
+// =======================================================================
+// function : SetIntensity
+// purpose :
+// =======================================================================
+void V3d_Light::SetIntensity (const Standard_Real theValue)
+{
+ Standard_ASSERT_RAISE (theValue > 0.,
+ "V3d_Light::SetIntensity, "
+ "Negative value for intensity");
+
+ myLight.Intensity = static_cast<Standard_ShortReal> (theValue);
}
-void V3d_Light::Color(Quantity_NameOfColor& Name) const{
-
- Quantity_Color C ;
- C = MyLight->Color() ;
- Name = C.Name();
+// =======================================================================
+// function : Intensity
+// purpose :
+// =======================================================================
+Standard_Real V3d_Light::Intensity() const
+{
+ return myLight.Intensity;
}
-Quantity_Color V3d_Light::Color() const{
-
- return MyLight->Color();
+// =======================================================================
+// function : Smoothness
+// purpose :
+// =======================================================================
+Standard_Real V3d_Light::Smoothness() const
+{
+ return myLight.Smoothness;
}
-V3d_TypeOfLight V3d_Light::Type() const {
-
- return MyType;
+// =======================================================================
+// function : Headlight
+// purpose :
+// =======================================================================
+Standard_Boolean V3d_Light::Headlight() const
+{
+ return myLight.IsHeadlight;
}
-
-Standard_Boolean V3d_Light::Headlight() const {
- return MyLight->Headlight();
+// =======================================================================
+// function : SetHeadlight
+// purpose :
+// =======================================================================
+void V3d_Light::SetHeadlight (const Standard_Boolean theValue)
+{
+ myLight.IsHeadlight = theValue;
}
+// =======================================================================
+// function : SymetricPointOnSphere
+// purpose :
+// =======================================================================
void V3d_Light::SymetricPointOnSphere (const Handle(V3d_View)& aView, const Graphic3d_Vertex &Center, const Graphic3d_Vertex &aPoint, const Standard_Real Rayon, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ ) {
Standard_Real X0,Y0,Z0,XP,YP,ZP;
DeltaY = Y0 - YP;
DeltaZ = Z0 - ZP;
-// On recherche le point d'intersection des droites definies
-// par :
-// - Droite passant par le point de projection et l'oeil
-// si on est en perspective, parralele a la normale de la
-// vue si on a une vue axonometrique.
-// position dans la vue est // a la normale de la vue
-// - La distance position de la camera cible est egale au
-// rayon.
+// The point of intersection of straight lines defined by :
+// - Straight line passing by the point of projection and the eye
+// if this is a perspective, parralel to the normal of the view
+// if this is an axonometric view.
+// position in the view is parallel to the normal of the view
+// - The distance position of the target camera is equal to the radius.
A = VX*VX + VY*VY + VZ*VZ ;
B = -2. * (VX*DeltaX + VY*DeltaY + VZ*DeltaZ);
}
}
-Standard_Boolean V3d_Light::IsDisplayed() const {
- if( MyGraphicStructure.IsNull() ) return Standard_False;
- return MyGraphicStructure->IsDisplayed();
+// =======================================================================
+// function : IsDisplayed
+// purpose :
+// =======================================================================
+Standard_Boolean V3d_Light::IsDisplayed() const
+{
+ if (myGraphicStructure.IsNull())
+ {
+ return Standard_False;
+ }
+
+ return myGraphicStructure->IsDisplayed();
}