KiCad PCB EDA Suite
sg_appearance.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
29 #ifndef SG_APPEARANCE_H
30 #define SG_APPEARANCE_H
31 
32 #include "3d_cache/sg/sg_node.h"
33 
34 class SGAPPEARANCE : public SGNODE
35 {
36 public:
37  float shininess; // default 0.2
38  float transparency; // default 0.0
39  SGCOLOR ambient; // default 0.05317 0.17879 0.01804
40  SGCOLOR diffuse; // default 0.8 0.8 0.8
41  SGCOLOR emissive; // default 0.0 0.0 0.0
42  SGCOLOR specular; // default 0.0 0.0 0.0
43 
44  void unlinkChildNode( const SGNODE* aNode ) override;
45  void unlinkRefNode( const SGNODE* aNode ) override;
46 
47 public:
48  SGAPPEARANCE( SGNODE* aParent );
49  virtual ~SGAPPEARANCE();
50 
51  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
52 
53  bool SetEmissive( float aRVal, float aGVal, float aBVal );
54  bool SetEmissive( const SGCOLOR* aRGBColor );
55  bool SetEmissive( const SGCOLOR& aRGBColor );
56 
57  bool SetDiffuse( float aRVal, float aGVal, float aBVal );
58  bool SetDiffuse( const SGCOLOR* aRGBColor );
59  bool SetDiffuse( const SGCOLOR& aRGBColor );
60 
61  bool SetSpecular( float aRVal, float aGVal, float aBVal );
62  bool SetSpecular( const SGCOLOR* aRGBColor );
63  bool SetSpecular( const SGCOLOR& aRGBColor );
64 
65  bool SetAmbient( float aRVal, float aGVal, float aBVal );
66  bool SetAmbient( const SGCOLOR* aRGBColor );
67  bool SetAmbient( const SGCOLOR& aRGBColor );
68 
69  SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) override;
70  bool AddRefNode( SGNODE* aNode ) override;
71  bool AddChildNode( SGNODE* aNode ) override;
72 
73  void ReNameNodes( void ) override;
74  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
75 
76  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
77  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
78 };
79 
80 #endif // SG_APPEARANCE_H
SGCOLOR diffuse
Definition: sg_appearance.h:40
SGAPPEARANCE(SGNODE *aParent)
bool AddChildNode(SGNODE *aNode) override
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
virtual ~SGAPPEARANCE()
defines the base class of the intermediate scene graph NODE
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
SGCOLOR emissive
Definition: sg_appearance.h:41
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations...
SGCOLOR ambient
Definition: sg_appearance.h:39
void unlinkRefNode(const SGNODE *aNode) override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
float transparency
Definition: sg_appearance.h:38
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Function WriteVRML writes this node's data to a VRML file; this includes all data of child and refere...
bool SetSpecular(float aRVal, float aGVal, float aBVal)
bool SetEmissive(float aRVal, float aGVal, float aBVal)
SGCOLOR specular
Definition: sg_appearance.h:42
bool SetAmbient(float aRVal, float aGVal, float aBVal)
void unlinkChildNode(const SGNODE *aNode) override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
bool AddRefNode(SGNODE *aNode) override
bool SetDiffuse(float aRVal, float aGVal, float aBVal)