Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GaussianProcessTuning/ILNumerics.2.14.4735.573/Drawing/Graphs/ILSceneGraphShapedLeaf.cs @ 10179

Last change on this file since 10179 was 9102, checked in by gkronber, 12 years ago

#1967: ILNumerics source for experimentation

File size: 6.2 KB
Line 
1///
2///    This file is part of ILNumerics Community Edition.
3///
4///    ILNumerics Community Edition - high performance computing for applications.
5///    Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
6///
7///    ILNumerics Community Edition is free software: you can redistribute it and/or modify
8///    it under the terms of the GNU General Public License version 3 as published by
9///    the Free Software Foundation.
10///
11///    ILNumerics Community Edition 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 ILNumerics Community Edition. See the file License.txt in the root
18///    of your distribution package. If not, see <http://www.gnu.org/licenses/>.
19///
20///    In addition this software uses the following components and/or licenses:
21///
22///    =================================================================================
23///    The Open Toolkit Library License
24///   
25///    Copyright (c) 2006 - 2009 the Open Toolkit library.
26///   
27///    Permission is hereby granted, free of charge, to any person obtaining a copy
28///    of this software and associated documentation files (the "Software"), to deal
29///    in the Software without restriction, including without limitation the rights to
30///    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
31///    the Software, and to permit persons to whom the Software is furnished to do
32///    so, subject to the following conditions:
33///
34///    The above copyright notice and this permission notice shall be included in all
35///    copies or substantial portions of the Software.
36///
37///    =================================================================================
38///   
39
40using System;
41using System.Collections.Generic;
42using System.Text;
43using ILNumerics.Drawing;
44using ILNumerics.Drawing.Shapes;
45
46namespace ILNumerics.Drawing.Graphs {
47
48    /// <summary>
49    /// a scene graph node, holding a single shape
50    /// </summary>
51    public class ILSceneGraphShapedLeaf : ILSceneGraphNode {
52
53        #region attributes
54        ILShape m_shape;
55        #endregion
56
57        /// <summary>
58        /// create a new shaped leaf
59        /// </summary>
60        /// <param name="panel"></param>
61        public ILSceneGraphShapedLeaf(ILPanel panel) : base(panel) { }
62
63        #region properties
64        /// <summary>
65        /// Get / set the shape of the scene graph node
66        /// </summary>
67        public ILShape Shape {
68            get {
69                return m_shape;
70            }
71            set {
72                m_shape = value;
73                if (value != null) {
74                    value.SceneGraphNode = this;
75                }
76            }
77        }
78        #endregion
79        /// <summary>
80        /// the minimum position of contained shape
81        /// </summary>
82        public override ILPoint3Df PositionMin {
83            get {
84                if (m_shape != null)
85                    return m_shape.PositionMin;
86                else {
87                    return ILPoint3Df.Empty;
88                }
89            }
90        }
91        /// <summary>
92        /// the maximum position of contained shape
93        /// </summary>
94        public override ILPoint3Df PositionMax {
95            get {
96                if (m_shape != null)
97                    return m_shape.PositionMax;
98                else {
99                    return ILPoint3Df.Empty;
100                }
101            }
102        }
103        /// <summary>
104        /// the computed center of contained shape
105        /// </summary>
106        public override ILPoint3Df Center {
107            get {
108                if (m_shape != null)
109                    return m_shape.Center;
110                else {
111                    return ILPoint3Df.Empty;
112                }
113            }
114        }
115        /// <summary>
116        /// invalidate this and all nodes up to root
117        /// </summary>
118        public override void Invalidate() {
119            Invalidate(false);         
120        }
121        /// <summary>
122        /// invalidate this node and all nodes up to root
123        /// </summary>
124        /// <param name="invalidateShape">true: invalidate the shape also</param>
125        public void Invalidate(bool invalidateShape) {
126            base.Invalidate();
127            if (invalidateShape && m_shape != null) {
128                m_shape.Invalidate();
129            }
130        }
131        /// <summary>
132        /// recompute the size spanned by this node, may fires Changed() event
133        /// </summary>
134        internal override void Configure() {
135            if (m_invalidated && m_shape != null) {
136                bool sizechanged = false;
137                m_shape.Configure();
138                if (m_shape.PositionMin != m_positionMin) sizechanged = true;
139                if (m_shape.PositionMax != m_positionMax) sizechanged = true;
140                m_positionMax = m_shape.PositionMax;
141                m_positionMin = m_shape.PositionMin;
142                m_invalidated = false;
143                if (sizechanged)
144                    OnSizeChanged();
145            }
146        }
147        /// <summary>
148        /// Draw this shape contained in this node (internal use) 
149        /// </summary>
150        /// <param name="props"></param>
151        internal override void Draw(ILRenderProperties props) {
152            if (m_shape != null) {
153                m_shape.Draw(props);
154            }
155        }
156        /// <summary>
157        /// compute limits of the cube tightly enclosing the branch below this node
158        /// </summary>
159        /// <returns></returns>
160        protected override void ComputeNodeLimits() {
161            if (m_shape != null) {
162                m_positionMin = m_shape.PositionMin;
163                m_positionMax = m_shape.PositionMax;
164            } else {
165                m_positionMax = ILPoint3Df.Empty;
166                m_positionMin = ILPoint3Df.Empty;
167            }
168        }
169
170    }
171}
Note: See TracBrowser for help on using the repository browser.