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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
28 #include <svx/sdr/contact/viewcontactofe3d.hxx>
29 #include <basegfx/color/bcolor.hxx>
30 #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
31 #include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
32 #include <drawinglayer/primitive2d/embedded3dprimitive2d.hxx>
33 #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
34 
35 //////////////////////////////////////////////////////////////////////////////
36 // predeclarations
37 
38 //////////////////////////////////////////////////////////////////////////////
39 
40 namespace sdr
41 {
42 	namespace contact
43 	{
44 		ViewObjectContactOfE3d::ViewObjectContactOfE3d(ObjectContact& rObjectContact, ViewContact& rViewContact)
45 		:	ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
46 		{
47 		}
48 
49 		ViewObjectContactOfE3d::~ViewObjectContactOfE3d()
50 		{
51 		}
52 
53 		drawinglayer::primitive3d::Primitive3DSequence ViewObjectContactOfE3d::createPrimitive3DSequence(const DisplayInfo& rDisplayInfo) const
54 		{
55 			// get the view-independent Primitive from the viewContact
56 			const ViewContactOfE3d& rViewContactOfE3d(dynamic_cast< const ViewContactOfE3d& >(GetViewContact()));
57 			drawinglayer::primitive3d::Primitive3DSequence xRetval(rViewContactOfE3d.getViewIndependentPrimitive3DSequence());
58 
59 			// handle ghosted
60 			if(isPrimitiveGhosted(rDisplayInfo))
61 			{
62 				const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
63 				const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE);
64 				const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::ModifiedColorPrimitive3D(xRetval, aBColorModifier));
65                 xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
66 			}
67 
68 			return xRetval;
69 		}
70 
71 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3d::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
72 		{
73     		const ViewContactOfE3d& rViewContact = static_cast< const ViewContactOfE3d& >(GetViewContact());
74 
75 			// get 3d primitive vector, isPrimitiveVisible() is done in 3d creator
76     		return rViewContact.impCreateWithGivenPrimitive3DSequence(getPrimitive3DSequence(rDisplayInfo));
77 		}
78 
79 		drawinglayer::primitive3d::Primitive3DSequence ViewObjectContactOfE3d::getPrimitive3DSequence(const DisplayInfo& rDisplayInfo) const
80 		{
81 			drawinglayer::primitive3d::Primitive3DSequence xNewPrimitive3DSeq(createPrimitive3DSequence(rDisplayInfo));
82 
83 			// local up-to-date checks. New list different from local one?
84 			if(!drawinglayer::primitive3d::arePrimitive3DSequencesEqual(mxPrimitive3DSequence, xNewPrimitive3DSeq))
85 			{
86 				// has changed, copy content
87 				const_cast< ViewObjectContactOfE3d* >(this)->mxPrimitive3DSequence = xNewPrimitive3DSeq;
88 			}
89 
90 			// return current Primitive2DSequence
91 			return mxPrimitive3DSequence;
92 		}
93 	} // end of namespace contact
94 } // end of namespace sdr
95 
96 //////////////////////////////////////////////////////////////////////////////
97 // eof
98