KiCad PCB EDA Suite
Loading...
Searching...
No Matches
vrml2_base.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-2016 Cirilo Bernardo <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
25
26/*
27 * Notes on deleting unsupported entities:
28 * 1. PROTO: PROTO ProtoName [parameter list] {body}
29 * the parameter list will always have '[]'. So the items
30 * to delete are: String, List, Body
31 * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
32 * delete: string, string, string, list, list
33 * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
34 * This scheme should also apply to PROTO'd node types.
35 * 4. ROUTE: ROUTE nodename1.event to nodename2.event
36 * Delete a String 3 times
37 * 5. Script: Script { ... }
38 */
39
40#ifndef VRML2_BASE_H
41#define VRML2_BASE_H
42
43#include <list>
44#include <string>
45#include <map>
46
47#include "vrml2_node.h"
48
49class SGNODE;
50class WRL2INLINE;
51
55class WRL2BASE : public WRL2NODE
56{
57public:
58 WRL2BASE();
59 virtual ~WRL2BASE();
60
61 // function to enable/disable Inline{} expansion
62 void SetEnableInline( bool enable );
63 bool GetEnableInline( void );
64
65 // function to check if unit conversion should be applied
66 // when false, coordinates are used as-is (PCBnew export style with top-level scale)
67 // when true, coordinates are multiplied by 2.54 (legacy KiCad 0.1 inch units)
68 bool GetApplyUnitConversion( void ) const;
69 void SetApplyUnitConversion( bool apply );
70
71 // function to manipulate Inline{} objects
72 SGNODE* GetInlineData( const std::string& aName );
73
74 // function to read entire VRML file
75 bool Read( WRLPROC& proc );
76
77 // read in a VRML node
78 bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
79
80 virtual std::string GetName( void ) override;
81 virtual bool SetName( const std::string& aName ) override;
82
83 bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
84 bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
85 SGNODE* TranslateToSG( SGNODE* aParent ) override;
86
87 bool isDangling( void ) override;
88
89private:
90 // handle cases of USE / DEF
91 bool implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
92 bool implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
93
94 bool readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
95 bool readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
96 bool readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
97 bool readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
98 bool readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
99 bool readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
100 bool readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
101 bool readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
102 bool readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
103 bool readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
104 bool readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
105 bool readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
106 bool readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
107
109 bool m_applyUnitConversion; // if true, multiply coords by 2.54 (legacy mode)
110 std::string m_dir; // parent directory of the file
111 std::map< std::string, SGNODE* > m_inlineModels;
112};
113
114#endif // VRML2_BASE_H
The base class of all Scene Graph nodes.
Definition sg_node.h:71
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
std::map< std::string, SGNODE * > m_inlineModels
Definition vrml2_base.h:111
bool m_useInline
Definition vrml2_base.h:108
virtual bool SetName(const std::string &aName) override
void SetEnableInline(bool enable)
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool GetEnableInline(void)
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
SGNODE * GetInlineData(const std::string &aName)
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool m_applyUnitConversion
Definition vrml2_base.h:109
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool SetParent(WRL2NODE *aParent, bool doUnlink=true) override
Set the parent WRL2NODE of this object.
virtual std::string GetName(void) override
virtual ~WRL2BASE()
void SetApplyUnitConversion(bool apply)
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool GetApplyUnitConversion(void) const
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc)
SGNODE * TranslateToSG(SGNODE *aParent) override
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
bool isDangling(void) override
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
std::string m_dir
Definition vrml2_base.h:110
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)