1 /* 2 * This program source code file is part of KiCad, a free EDA CAD application. 3 * 4 * Copyright (C) 2015 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 24 /** 25 * @file sg_base.h 26 * defines the low level classes common to scene graph nodes 27 */ 28 29 30 #ifndef SG_BASE_H 31 #define SG_BASE_H 32 33 #include "plugins/3dapi/ifsg_defs.h" 34 35 #ifndef SGLIB_API 36 #if defined (COMPILE_SGLIB) 37 #define SGLIB_API APIEXPORT 38 #else 39 #define SGLIB_API APIIMPORT 40 #endif 41 #endif 42 43 class SGLIB_API SGCOLOR 44 { 45 protected: 46 float red; 47 float green; 48 float blue; 49 50 public: 51 SGCOLOR(); 52 SGCOLOR( float aRVal, float aGVal, float aBVal ); 53 54 void GetColor( float& aRedVal, float& aGreenVal, float& aBlueVal ) const noexcept; 55 void GetColor( SGCOLOR& aColor ) const noexcept; 56 void GetColor( SGCOLOR* aColor ) const noexcept; 57 58 bool SetColor( float aRedVal, float aGreenVal, float aBlueVal ); 59 bool SetColor( const SGCOLOR& aColor ) noexcept; 60 bool SetColor( const SGCOLOR* aColor ) noexcept; 61 62 private: 63 bool checkRange( float aRedVal, float aGreenVal, float aBlueVal ) const noexcept; 64 }; 65 66 67 class SGLIB_API SGPOINT 68 { 69 public: 70 double x; 71 double y; 72 double z; 73 74 public: 75 SGPOINT(); 76 SGPOINT( double aXVal, double aYVal, double aZVal ) noexcept; 77 78 void GetPoint( const double& aXVal, const double& aYVal, const double& aZVal ) noexcept; 79 void GetPoint( const SGPOINT& aPoint ) noexcept; 80 void GetPoint( const SGPOINT* aPoint ) noexcept; 81 82 void SetPoint( double aXVal, double aYVal, double aZVal ) noexcept; 83 void SetPoint( const SGPOINT& aPoint ) noexcept; 84 }; 85 86 87 class SGLIB_API SGVECTOR 88 { 89 private: 90 void normalize( void ) noexcept; 91 92 double vx; 93 double vy; 94 double vz; 95 96 public: 97 SGVECTOR(); 98 SGVECTOR( double aXVal, double aYVal, double aZVal ); 99 100 void GetVector( double& aXVal, double& aYVal, double& aZVal ) const noexcept; 101 102 void SetVector( double aXVal, double aYVal, double aZVal ); 103 void SetVector( const SGVECTOR& aVector ); 104 105 SGVECTOR& operator=( const SGVECTOR& source ) noexcept; 106 }; 107 108 109 #endif // SG_BASE_H 110