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
26
27/*
28 * Notes on deleting unsupported entities:
29 * 1. PROTO: PROTO ProtoName [parameter list] {body}
30 * the parameter list will always have '[]'. So the items
31 * to delete are: String, List, Body
32 * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
33 * delete: string, string, string, list, list
34 * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
35 * This scheme should also apply to PROTO'd node types.
36 * 4. ROUTE: ROUTE nodename1.event to nodename2.event
37 * Delete a String 3 times
38 * 5. Script: Script { ... }
39 */
40
41#ifndef VRML2_BASE_H
42#define VRML2_BASE_H
43
44#include <list>
45#include <string>
46#include <map>
47#include <cstdint>
48
49#include "vrml2_node.h"
51
52class SGNODE;
53class WRL2INLINE;
55
59class WRL2BASE : public WRL2NODE
60{
61public:
62 WRL2BASE();
63 virtual ~WRL2BASE();
64
65 // function to enable/disable Inline{} expansion
66 void SetEnableInline( bool enable );
67 bool GetEnableInline( void );
68
69 // function to check if unit conversion should be applied
70 // when false, coordinates are used as-is (PCBnew export style with top-level scale)
71 // when true, coordinates are multiplied by 2.54 (legacy KiCad 0.1 inch units)
72 bool GetApplyUnitConversion( void ) const;
73 void SetApplyUnitConversion( bool apply );
74 void SetImportOptions( const S3D::MODEL_IMPORT_OPTIONS& aOptions, MODEL_IMPORT_STATUS* aStatus );
75 bool HadIncompleteInline() const { return m_incompleteInline; }
76
77 // function to manipulate Inline{} objects
78 SGNODE* GetInlineData( const std::string& aName );
79
80 // function to read entire VRML file
81 bool Read( WRLPROC& proc );
82
83 // read in a VRML node
84 bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
85
86 virtual std::string GetName( void ) override;
87 virtual bool SetName( const std::string& aName ) override;
88
89 bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
90 bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
91 SGNODE* TranslateToSG( SGNODE* aParent ) override;
92
93 bool isDangling( void ) override;
94
95private:
96 // handle cases of USE / DEF
97 bool implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
98 bool implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
99
100 bool readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
101 bool readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
102 bool readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
103 bool readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
104 bool readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
105 bool readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
106 bool readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
107 bool readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
108 bool readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
109 bool readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
110 bool readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
111 bool readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
112 bool readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
113
115 bool m_applyUnitConversion; // if true, multiply coords by 2.54 (legacy mode)
116 bool m_incompleteInline = false;
119 std::string m_dir; // parent directory of the file
120 std::map< std::string, SGNODE* > m_inlineModels;
121};
122
123#endif // VRML2_BASE_H
The base class of all Scene Graph nodes.
Definition sg_node.h:71
The top node of a VRML2 model.
Definition vrml2_base.h:60
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
MODEL_IMPORT_STATUS * m_status
Definition vrml2_base.h:118
std::map< std::string, SGNODE * > m_inlineModels
Definition vrml2_base.h:120
bool m_useInline
Definition vrml2_base.h:114
virtual bool SetName(const std::string &aName) override
void SetEnableInline(bool enable)
void SetImportOptions(const S3D::MODEL_IMPORT_OPTIONS &aOptions, MODEL_IMPORT_STATUS *aStatus)
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:115
S3D::MODEL_IMPORT_OPTIONS m_options
Definition vrml2_base.h:117
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 m_incompleteInline
Definition vrml2_base.h:116
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 HadIncompleteInline() const
Definition vrml2_base.h:75
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:119
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
The base class for VRML2.0 nodes.