1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_BASEPROCESSOR3D_HXX
25 #define INCLUDED_DRAWINGLAYER_PROCESSOR3D_BASEPROCESSOR3D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive3d/baseprimitive3d.hxx>
29 #include <drawinglayer/geometry/viewinformation3d.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 namespace drawinglayer
34 {
35 	namespace processor3d
36 	{
37         /** BaseProcessor3D class
38 
39             Baseclass for all C++ implementations of instances which process
40             primitives.
41 
42             Please have a look at baseprocessor2d.hxx for more comments.
43          */
44 		class DRAWINGLAYER_DLLPUBLIC BaseProcessor3D
45 		{
46 		private:
47 			geometry::ViewInformation3D						maViewInformation3D;
48 
49 		protected:
updateViewInformation(const geometry::ViewInformation3D & rViewInformation3D)50 			void updateViewInformation(const geometry::ViewInformation3D& rViewInformation3D)
51 			{
52 				maViewInformation3D = rViewInformation3D;
53 			}
54 
55 			/*  as tooling, the process() implementation takes over API handling and calls this
56 			    virtual render method when the primitive implementation is BasePrimitive3D-based.
57 			    Default implementation does nothing
58              */
59 			virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate);
60 
61 		public:
62 			BaseProcessor3D(const geometry::ViewInformation3D& rViewInformation);
63 			virtual ~BaseProcessor3D();
64 
65 			// the central processing method
66 			virtual void process(const primitive3d::Primitive3DSequence& rSource);
67 
68 			// data access
getViewInformation3D() const69 			const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; }
70 		};
71 	} // end of namespace processor3d
72 } // end of namespace drawinglayer
73 
74 //////////////////////////////////////////////////////////////////////////////
75 
76 namespace drawinglayer
77 {
78 	namespace processor3d
79 	{
80         /** CollectingProcessor3D class
81 
82             A processor which just collects all primitives given to it in
83             process(..) calls to maPrimitive3DSequence. This can e.g. be used to
84             hand around as instance over various methods where every called
85             method can add graphic content to it.
86          */
87 		class DRAWINGLAYER_DLLPUBLIC CollectingProcessor3D : public BaseProcessor3D
88 		{
89 		private:
90 			primitive3d::Primitive3DSequence						maPrimitive3DSequence;
91 
92 		public:
93 			CollectingProcessor3D(const geometry::ViewInformation3D& rViewInformation);
94 			virtual ~CollectingProcessor3D();
95 
96 			/// the central processing method
97 			virtual void process(const primitive3d::Primitive3DSequence& rSource);
98 
99 			/// helpers for adding to local sequence
appendPrimitive3DReference(const primitive3d::Primitive3DReference & rSource)100 			void appendPrimitive3DReference(const primitive3d::Primitive3DReference& rSource)
101 			{
102 				primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(maPrimitive3DSequence, rSource);
103 			}
104 
105 			/// data access and reset
getPrimitive3DSequence() const106 			const primitive3d::Primitive3DSequence& getPrimitive3DSequence() const { return maPrimitive3DSequence; }
reset()107 			void reset() { maPrimitive3DSequence = primitive3d::Primitive3DSequence(); }
108 		};
109 	} // end of namespace processor3d
110 } // end of namespace drawinglayer
111 
112 //////////////////////////////////////////////////////////////////////////////
113 
114 #endif //_DRAWINGLAYER_PROCESSOR3D_BASEPROCESSOR3D_HXX
115 
116 // eof
117