KiCad PCB EDA Suite
sg_index.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_INDEX_H
30 #define SG_INDEX_H
31 
32 #include <vector>
33 #include "3d_cache/sg/sg_node.h"
34 
35 class SGINDEX : public SGNODE
36 {
37 protected:
38  bool writeCoordIndex( std::ostream& aFile );
39  bool writeColorIndex( std::ostream& aFile );
40  bool writeIndexList( std::ostream& aFile );
41 
42 public:
43  // for internal SG consumption only
44  std::vector< int > index;
45  void unlinkChildNode( const SGNODE* aCaller ) override;
46  void unlinkRefNode( const SGNODE* aCaller ) override;
47 
48 public:
49  SGINDEX( SGNODE* aParent );
50  virtual ~SGINDEX();
51 
52  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
53 
54  SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) override;
55  bool AddRefNode( SGNODE* aNode ) override;
56  bool AddChildNode( SGNODE* aNode ) override;
57 
70  bool GetIndices( size_t& nIndices, int*& aIndexList );
71 
79  void SetIndices( size_t nIndices, int* aIndexList );
80 
81 
89  void AddIndex( int aIndex );
90 
91  void ReNameNodes( void ) override;
92  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
93 
94  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
95  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
96 };
97 
98 #endif // SG_INDEX_H
SGINDEX(SGNODE *aParent)
Definition: sg_index.cpp:31
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Definition: sg_index.cpp:57
bool AddChildNode(SGNODE *aNode) override
Definition: sg_index.cpp:138
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...
Definition: sg_index.cpp:197
bool writeColorIndex(std::ostream &aFile)
Definition: sg_index.cpp:261
defines the base class of the intermediate scene graph NODE
std::vector< int > index
Definition: sg_index.h:44
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
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...
Definition: sg_index.cpp:297
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations...
Definition: sg_index.cpp:187
bool writeCoordIndex(std::ostream &aFile)
Definition: sg_index.cpp:209
void unlinkRefNode(const SGNODE *aCaller) override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
Definition: sg_index.cpp:112
bool GetIndices(size_t &nIndices, int *&aIndexList)
Function GetIndices retrieves the number of indices and a pointer to the list.
Definition: sg_index.cpp:151
virtual ~SGINDEX()
Definition: sg_index.cpp:50
bool writeIndexList(std::ostream &aFile)
Definition: sg_index.cpp:268
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...
Definition: sg_index.cpp:87
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
Definition: sg_index.cpp:366
void SetIndices(size_t nIndices, int *aIndexList)
Function SetIndices sets the number of indices and creates a copy of the given index data...
Definition: sg_index.cpp:166
bool AddRefNode(SGNODE *aNode) override
Definition: sg_index.cpp:125
void unlinkChildNode(const SGNODE *aCaller) override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: sg_index.cpp:99
void AddIndex(int aIndex)
Function AddIndex adds a single index to the list.
Definition: sg_index.cpp:180