1*4bfbcde8SAndrew Rist /**************************************************************
2*4bfbcde8SAndrew Rist  *
3*4bfbcde8SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*4bfbcde8SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*4bfbcde8SAndrew Rist  * distributed with this work for additional information
6*4bfbcde8SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*4bfbcde8SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*4bfbcde8SAndrew Rist  * "License"); you may not use this file except in compliance
9*4bfbcde8SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*4bfbcde8SAndrew Rist  *
11*4bfbcde8SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*4bfbcde8SAndrew Rist  *
13*4bfbcde8SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*4bfbcde8SAndrew Rist  * software distributed under the License is distributed on an
15*4bfbcde8SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*4bfbcde8SAndrew Rist  * KIND, either express or implied.  See the License for the
17*4bfbcde8SAndrew Rist  * specific language governing permissions and limitations
18*4bfbcde8SAndrew Rist  * under the License.
19*4bfbcde8SAndrew Rist  *
20*4bfbcde8SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
26cdf0e10cSrcweir #include <drawinglayer/attribute/materialattribute3d.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace drawinglayer
31cdf0e10cSrcweir {
32cdf0e10cSrcweir 	namespace attribute
33cdf0e10cSrcweir 	{
34cdf0e10cSrcweir 		class ImpSdr3DObjectAttribute
35cdf0e10cSrcweir 		{
36cdf0e10cSrcweir 		public:
37cdf0e10cSrcweir 			// refcounter
38cdf0e10cSrcweir 			sal_uInt32								mnRefCount;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 			// 3D object attribute definitions
41cdf0e10cSrcweir 			::com::sun::star::drawing::NormalsKind				maNormalsKind;				// normals type (0..2)
42cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode	maTextureProjectionX;		// texture projection type X (0..2)
43cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode	maTextureProjectionY;		// texture projection type Y (0..2)
44cdf0e10cSrcweir 			::com::sun::star::drawing::TextureKind2				maTextureKind;				// texture kind (see uno API)
45cdf0e10cSrcweir 			::com::sun::star::drawing::TextureMode				maTextureMode;				// texture kind (see uno API)
46cdf0e10cSrcweir 			MaterialAttribute3D									maMaterial;					// object, specular and emissive colors, SpecularIntensity
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 			// bitfield
49cdf0e10cSrcweir 			unsigned											mbNormalsInvert : 1;		// invert normals
50cdf0e10cSrcweir 			unsigned											mbDoubleSided : 1;			// surfaces are double sided
51cdf0e10cSrcweir 			unsigned											mbShadow3D : 1;				// display shadow in 3D (if on), params for that are at scene
52cdf0e10cSrcweir 			unsigned											mbTextureFilter : 1;		// filter texture to make more smooth
53cdf0e10cSrcweir 			unsigned											mbReducedLineGeometry : 1;	// use reduced line geometry (object specific)
54cdf0e10cSrcweir 
ImpSdr3DObjectAttribute(::com::sun::star::drawing::NormalsKind aNormalsKind,::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,::com::sun::star::drawing::TextureKind2 aTextureKind,::com::sun::star::drawing::TextureMode aTextureMode,const MaterialAttribute3D & rMaterial,bool bNormalsInvert,bool bDoubleSided,bool bShadow3D,bool bTextureFilter,bool bReducedLineGeometry)55cdf0e10cSrcweir 			ImpSdr3DObjectAttribute(
56cdf0e10cSrcweir 				::com::sun::star::drawing::NormalsKind	aNormalsKind,
57cdf0e10cSrcweir 				::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
58cdf0e10cSrcweir 				::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
59cdf0e10cSrcweir 				::com::sun::star::drawing::TextureKind2 aTextureKind,
60cdf0e10cSrcweir 				::com::sun::star::drawing::TextureMode aTextureMode,
61cdf0e10cSrcweir 				const MaterialAttribute3D& rMaterial,
62cdf0e10cSrcweir 				bool bNormalsInvert,
63cdf0e10cSrcweir 				bool bDoubleSided,
64cdf0e10cSrcweir 				bool bShadow3D,
65cdf0e10cSrcweir 				bool bTextureFilter,
66cdf0e10cSrcweir 				bool bReducedLineGeometry)
67cdf0e10cSrcweir 			:	mnRefCount(0),
68cdf0e10cSrcweir 		    	maNormalsKind(aNormalsKind),
69cdf0e10cSrcweir 			    maTextureProjectionX(aTextureProjectionX),
70cdf0e10cSrcweir 			    maTextureProjectionY(aTextureProjectionY),
71cdf0e10cSrcweir 			    maTextureKind(aTextureKind),
72cdf0e10cSrcweir 			    maTextureMode(aTextureMode),
73cdf0e10cSrcweir 			    maMaterial(rMaterial),
74cdf0e10cSrcweir 			    mbNormalsInvert(bNormalsInvert),
75cdf0e10cSrcweir 			    mbDoubleSided(bDoubleSided),
76cdf0e10cSrcweir 			    mbShadow3D(bShadow3D),
77cdf0e10cSrcweir 			    mbTextureFilter(bTextureFilter),
78cdf0e10cSrcweir 			    mbReducedLineGeometry(bReducedLineGeometry)
79cdf0e10cSrcweir 		    {
80cdf0e10cSrcweir 		    }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 			// data read access
getNormalsKind() const83cdf0e10cSrcweir 			::com::sun::star::drawing::NormalsKind getNormalsKind() const { return maNormalsKind; }
getTextureProjectionX() const84cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode getTextureProjectionX() const { return maTextureProjectionX; }
getTextureProjectionY() const85cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode getTextureProjectionY() const { return maTextureProjectionY; }
getTextureKind() const86cdf0e10cSrcweir 			::com::sun::star::drawing::TextureKind2 getTextureKind() const { return maTextureKind; }
getTextureMode() const87cdf0e10cSrcweir 			::com::sun::star::drawing::TextureMode getTextureMode() const { return maTextureMode; }
getMaterial() const88cdf0e10cSrcweir 			const MaterialAttribute3D& getMaterial() const { return maMaterial; }
getNormalsInvert() const89cdf0e10cSrcweir 			bool getNormalsInvert() const { return mbNormalsInvert; }
getDoubleSided() const90cdf0e10cSrcweir 			bool getDoubleSided() const { return mbDoubleSided; }
getShadow3D() const91cdf0e10cSrcweir 			bool getShadow3D() const { return mbShadow3D; }
getTextureFilter() const92cdf0e10cSrcweir 			bool getTextureFilter() const { return mbTextureFilter; }
getReducedLineGeometry() const93cdf0e10cSrcweir 			bool getReducedLineGeometry() const { return mbReducedLineGeometry; }
94cdf0e10cSrcweir 
operator ==(const ImpSdr3DObjectAttribute & rCandidate) const95cdf0e10cSrcweir             bool operator==(const ImpSdr3DObjectAttribute& rCandidate) const
96cdf0e10cSrcweir 	        {
97cdf0e10cSrcweir 		        return (getNormalsKind() == rCandidate.getNormalsKind()
98cdf0e10cSrcweir 			        && getTextureProjectionX() == rCandidate.getTextureProjectionX()
99cdf0e10cSrcweir 			        && getTextureProjectionY() == rCandidate.getTextureProjectionY()
100cdf0e10cSrcweir 			        && getTextureKind() == rCandidate.getTextureKind()
101cdf0e10cSrcweir 			        && getTextureMode() == rCandidate.getTextureMode()
102cdf0e10cSrcweir 			        && getMaterial() == rCandidate.getMaterial()
103cdf0e10cSrcweir 			        && getNormalsInvert() == rCandidate.getNormalsInvert()
104cdf0e10cSrcweir 			        && getDoubleSided() == rCandidate.getDoubleSided()
105cdf0e10cSrcweir 			        && getShadow3D() == rCandidate.getShadow3D()
106cdf0e10cSrcweir 			        && getTextureFilter() == rCandidate.getTextureFilter()
107cdf0e10cSrcweir 			        && getReducedLineGeometry() == rCandidate.getReducedLineGeometry());
108cdf0e10cSrcweir 	        }
109cdf0e10cSrcweir 
get_global_default()110cdf0e10cSrcweir             static ImpSdr3DObjectAttribute* get_global_default()
111cdf0e10cSrcweir             {
112cdf0e10cSrcweir                 static ImpSdr3DObjectAttribute* pDefault = 0;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir                 if(!pDefault)
115cdf0e10cSrcweir                 {
116cdf0e10cSrcweir                     pDefault = new ImpSdr3DObjectAttribute(
117cdf0e10cSrcweir 			            ::com::sun::star::drawing::NormalsKind_SPECIFIC,
118cdf0e10cSrcweir 			            ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
119cdf0e10cSrcweir 			            ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
120cdf0e10cSrcweir 			            ::com::sun::star::drawing::TextureKind2_LUMINANCE,
121cdf0e10cSrcweir 			            ::com::sun::star::drawing::TextureMode_REPLACE,
122cdf0e10cSrcweir 			            MaterialAttribute3D(),
123cdf0e10cSrcweir 			            false,
124cdf0e10cSrcweir 			            false,
125cdf0e10cSrcweir 			            false,
126cdf0e10cSrcweir 			            false,
127cdf0e10cSrcweir 			            false);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir                     // never delete; start with RefCount 1, not 0
130cdf0e10cSrcweir     			    pDefault->mnRefCount++;
131cdf0e10cSrcweir                 }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir                 return pDefault;
134cdf0e10cSrcweir             }
135cdf0e10cSrcweir 		};
136cdf0e10cSrcweir 
Sdr3DObjectAttribute(::com::sun::star::drawing::NormalsKind aNormalsKind,::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,::com::sun::star::drawing::TextureKind2 aTextureKind,::com::sun::star::drawing::TextureMode aTextureMode,const MaterialAttribute3D & rMaterial,bool bNormalsInvert,bool bDoubleSided,bool bShadow3D,bool bTextureFilter,bool bReducedLineGeometry)137cdf0e10cSrcweir         Sdr3DObjectAttribute::Sdr3DObjectAttribute(
138cdf0e10cSrcweir 			::com::sun::star::drawing::NormalsKind	aNormalsKind,
139cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
140cdf0e10cSrcweir 			::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY,
141cdf0e10cSrcweir 			::com::sun::star::drawing::TextureKind2 aTextureKind,
142cdf0e10cSrcweir 			::com::sun::star::drawing::TextureMode aTextureMode,
143cdf0e10cSrcweir 			const MaterialAttribute3D& rMaterial,
144cdf0e10cSrcweir 			bool bNormalsInvert,
145cdf0e10cSrcweir 			bool bDoubleSided,
146cdf0e10cSrcweir 			bool bShadow3D,
147cdf0e10cSrcweir 			bool bTextureFilter,
148cdf0e10cSrcweir 			bool bReducedLineGeometry)
149cdf0e10cSrcweir 		:	mpSdr3DObjectAttribute(new ImpSdr3DObjectAttribute(
150cdf0e10cSrcweir                 aNormalsKind, aTextureProjectionX, aTextureProjectionY, aTextureKind, aTextureMode,
151cdf0e10cSrcweir 			    rMaterial, bNormalsInvert, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry))
152cdf0e10cSrcweir 		{
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 
Sdr3DObjectAttribute()155cdf0e10cSrcweir 		Sdr3DObjectAttribute::Sdr3DObjectAttribute()
156cdf0e10cSrcweir         :	mpSdr3DObjectAttribute(ImpSdr3DObjectAttribute::get_global_default())
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir 			mpSdr3DObjectAttribute->mnRefCount++;
159cdf0e10cSrcweir 		}
160cdf0e10cSrcweir 
Sdr3DObjectAttribute(const Sdr3DObjectAttribute & rCandidate)161cdf0e10cSrcweir         Sdr3DObjectAttribute::Sdr3DObjectAttribute(const Sdr3DObjectAttribute& rCandidate)
162cdf0e10cSrcweir 		:	mpSdr3DObjectAttribute(rCandidate.mpSdr3DObjectAttribute)
163cdf0e10cSrcweir 		{
164cdf0e10cSrcweir 			mpSdr3DObjectAttribute->mnRefCount++;
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir 
~Sdr3DObjectAttribute()167cdf0e10cSrcweir 		Sdr3DObjectAttribute::~Sdr3DObjectAttribute()
168cdf0e10cSrcweir 		{
169cdf0e10cSrcweir 			if(mpSdr3DObjectAttribute->mnRefCount)
170cdf0e10cSrcweir 			{
171cdf0e10cSrcweir 				mpSdr3DObjectAttribute->mnRefCount--;
172cdf0e10cSrcweir 			}
173cdf0e10cSrcweir 			else
174cdf0e10cSrcweir 			{
175cdf0e10cSrcweir 				delete mpSdr3DObjectAttribute;
176cdf0e10cSrcweir 			}
177cdf0e10cSrcweir 		}
178cdf0e10cSrcweir 
isDefault() const179cdf0e10cSrcweir         bool Sdr3DObjectAttribute::isDefault() const
180cdf0e10cSrcweir         {
181cdf0e10cSrcweir             return mpSdr3DObjectAttribute == ImpSdr3DObjectAttribute::get_global_default();
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir 
operator =(const Sdr3DObjectAttribute & rCandidate)184cdf0e10cSrcweir         Sdr3DObjectAttribute& Sdr3DObjectAttribute::operator=(const Sdr3DObjectAttribute& rCandidate)
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 			if(rCandidate.mpSdr3DObjectAttribute != mpSdr3DObjectAttribute)
187cdf0e10cSrcweir 			{
188cdf0e10cSrcweir 				if(mpSdr3DObjectAttribute->mnRefCount)
189cdf0e10cSrcweir 				{
190cdf0e10cSrcweir 					mpSdr3DObjectAttribute->mnRefCount--;
191cdf0e10cSrcweir 				}
192cdf0e10cSrcweir 				else
193cdf0e10cSrcweir 				{
194cdf0e10cSrcweir 					delete mpSdr3DObjectAttribute;
195cdf0e10cSrcweir 				}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 				mpSdr3DObjectAttribute = rCandidate.mpSdr3DObjectAttribute;
198cdf0e10cSrcweir 				mpSdr3DObjectAttribute->mnRefCount++;
199cdf0e10cSrcweir 			}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 			return *this;
202cdf0e10cSrcweir 		}
203cdf0e10cSrcweir 
operator ==(const Sdr3DObjectAttribute & rCandidate) const204cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::operator==(const Sdr3DObjectAttribute& rCandidate) const
205cdf0e10cSrcweir 		{
206cdf0e10cSrcweir 			if(rCandidate.mpSdr3DObjectAttribute == mpSdr3DObjectAttribute)
207cdf0e10cSrcweir 			{
208cdf0e10cSrcweir 				return true;
209cdf0e10cSrcweir 			}
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 			if(rCandidate.isDefault() != isDefault())
212cdf0e10cSrcweir 			{
213cdf0e10cSrcweir 				return false;
214cdf0e10cSrcweir 			}
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 			return (*rCandidate.mpSdr3DObjectAttribute == *mpSdr3DObjectAttribute);
217cdf0e10cSrcweir 		}
218cdf0e10cSrcweir 
getNormalsKind() const219cdf0e10cSrcweir 		::com::sun::star::drawing::NormalsKind Sdr3DObjectAttribute::getNormalsKind() const
220cdf0e10cSrcweir         {
221cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getNormalsKind();
222cdf0e10cSrcweir         }
223cdf0e10cSrcweir 
getTextureProjectionX() const224cdf0e10cSrcweir 		::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionX() const
225cdf0e10cSrcweir         {
226cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getTextureProjectionX();
227cdf0e10cSrcweir         }
228cdf0e10cSrcweir 
getTextureProjectionY() const229cdf0e10cSrcweir 		::com::sun::star::drawing::TextureProjectionMode Sdr3DObjectAttribute::getTextureProjectionY() const
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getTextureProjectionY();
232cdf0e10cSrcweir         }
233cdf0e10cSrcweir 
getTextureKind() const234cdf0e10cSrcweir 		::com::sun::star::drawing::TextureKind2 Sdr3DObjectAttribute::getTextureKind() const
235cdf0e10cSrcweir         {
236cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getTextureKind();
237cdf0e10cSrcweir         }
238cdf0e10cSrcweir 
getTextureMode() const239cdf0e10cSrcweir 		::com::sun::star::drawing::TextureMode Sdr3DObjectAttribute::getTextureMode() const
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getTextureMode();
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir 
getMaterial() const244cdf0e10cSrcweir 		const MaterialAttribute3D& Sdr3DObjectAttribute::getMaterial() const
245cdf0e10cSrcweir         {
246cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getMaterial();
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir 
getNormalsInvert() const249cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::getNormalsInvert() const
250cdf0e10cSrcweir         {
251cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getNormalsInvert();
252cdf0e10cSrcweir         }
253cdf0e10cSrcweir 
getDoubleSided() const254cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::getDoubleSided() const
255cdf0e10cSrcweir         {
256cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getDoubleSided();
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir 
getShadow3D() const259cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::getShadow3D() const
260cdf0e10cSrcweir         {
261cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getShadow3D();
262cdf0e10cSrcweir         }
263cdf0e10cSrcweir 
getTextureFilter() const264cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::getTextureFilter() const
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getTextureFilter();
267cdf0e10cSrcweir         }
268cdf0e10cSrcweir 
getReducedLineGeometry() const269cdf0e10cSrcweir 		bool Sdr3DObjectAttribute::getReducedLineGeometry() const
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             return mpSdr3DObjectAttribute->getReducedLineGeometry();
272cdf0e10cSrcweir         }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     } // end of namespace attribute
275cdf0e10cSrcweir } // end of namespace drawinglayer
276cdf0e10cSrcweir 
277cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
278cdf0e10cSrcweir // eof
279