KiCad PCB EDA Suite
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 <>
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
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  *
19  * or you may search the 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  */
29 #ifndef SG_INDEX_H
30 #define SG_INDEX_H
32 #include <vector>
33 #include "3d_cache/sg/sg_node.h"
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 );
42 public:
43  // for internal SG consumption only
44  std::vector< int > index;
45  void unlinkChildNode( const SGNODE* aCaller ) noexcept override;
46  void unlinkRefNode( const SGNODE* aCaller ) noexcept override;
48 public:
49  SGINDEX( SGNODE* aParent );
50  virtual ~SGINDEX();
52  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
54  SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override;
55  bool AddRefNode( SGNODE* aNode ) noexcept override;
56  bool AddChildNode( SGNODE* aNode ) noexcept override;
70  bool GetIndices( size_t& nIndices, int*& aIndexList );
79  void SetIndices( size_t nIndices, int* aIndexList );
88  void AddIndex( int aIndex );
90  void ReNameNodes( void ) override;
91  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
93  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
94  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
95 };
97 #endif // SG_INDEX_H
Definition: sg_index.cpp:31
bool AddRefNode(SGNODE *aNode) noexcept override
Definition: sg_index.cpp:125
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Definition: sg_index.cpp:57
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
void unlinkChildNode(const SGNODE *aCaller) noexcept override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: sg_index.cpp:99
defines the base class of the intermediate scene graph NODE
std::vector< int > index
Definition: sg_index.h:44
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
void unlinkRefNode(const SGNODE *aCaller) noexcept override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
Definition: sg_index.cpp:112
bool writeCoordIndex(std::ostream &aFile)
Definition: sg_index.cpp:209
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
bool AddChildNode(SGNODE *aNode) noexcept override
Definition: sg_index.cpp:138
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
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
Definition: sg_index.cpp:87
void AddIndex(int aIndex)
Function AddIndex adds a single index to the list.
Definition: sg_index.cpp:180