1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
28cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
29cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx>
30cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
31cdf0e10cSrcweir #include <basegfx/matrix/b3dhommatrix.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
33cdf0e10cSrcweir #include <basegfx/color/bcolormodifier.hxx>
34cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
35cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
36cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace com::sun::star;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	// Helper method to recursively travel the DrawHierarchy for 3D objects contained in
47cdf0e10cSrcweir 	// the 2D Scene. This will chreate all VOCs for the currenbt OC which are needed
48cdf0e10cSrcweir 	// for ActionChanged() functionality
49cdf0e10cSrcweir 	void impInternalSubHierarchyTraveller(const sdr::contact::ViewObjectContact& rVOC)
50cdf0e10cSrcweir 	{
51cdf0e10cSrcweir 		const sdr::contact::ViewContact& rVC = rVOC.GetViewContact();
52cdf0e10cSrcweir 		const sal_uInt32 nSubHierarchyCount(rVC.GetObjectCount());
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 		for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
55cdf0e10cSrcweir 		{
56cdf0e10cSrcweir 			const sdr::contact::ViewObjectContact& rCandidate(rVC.GetViewContact(a).GetViewObjectContact(rVOC.GetObjectContact()));
57cdf0e10cSrcweir 			impInternalSubHierarchyTraveller(rCandidate);
58cdf0e10cSrcweir 		}
59cdf0e10cSrcweir 	}
60cdf0e10cSrcweir } // end of anonymous namespace
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace sdr
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	namespace contact
67cdf0e10cSrcweir 	{
68cdf0e10cSrcweir 		ViewObjectContactOfE3dScene::ViewObjectContactOfE3dScene(ObjectContact& rObjectContact, ViewContact& rViewContact)
69cdf0e10cSrcweir 		:	ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
70cdf0e10cSrcweir 		{
71cdf0e10cSrcweir 		}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 		ViewObjectContactOfE3dScene::~ViewObjectContactOfE3dScene()
74cdf0e10cSrcweir 		{
75cdf0e10cSrcweir 		}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
78cdf0e10cSrcweir 		{
79cdf0e10cSrcweir 			// handle ghosted, else the whole 3d group will be encapsulated to a ghosted primitive set (see below)
80cdf0e10cSrcweir 			const bool bHandleGhostedDisplay(GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive());
81cdf0e10cSrcweir 			const bool bIsActiveVC(bHandleGhostedDisplay && GetObjectContact().getActiveViewContact() == &GetViewContact());
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 			if(bIsActiveVC)
84cdf0e10cSrcweir 			{
85cdf0e10cSrcweir 				// switch off ghosted, display contents normal
86cdf0e10cSrcweir 				const_cast< DisplayInfo& >(rDisplayInfo).ClearGhostedDrawMode();
87cdf0e10cSrcweir 			}
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 			// create 2d primitive with content, use layer visibility test
90cdf0e10cSrcweir 			// this uses no ghosted mode, so scenes in scenes and entering them will not
91cdf0e10cSrcweir 			// support ghosted for now. This is no problem currently but would need to be
92cdf0e10cSrcweir 			// added when sub-groups in 3d will be added one day.
93cdf0e10cSrcweir 			const ViewContactOfE3dScene& rViewContact = dynamic_cast< ViewContactOfE3dScene& >(GetViewContact());
94cdf0e10cSrcweir 			const SetOfByte& rVisibleLayers = rDisplayInfo.GetProcessLayers();
95cdf0e10cSrcweir 			drawinglayer::primitive2d::Primitive2DSequence xRetval(rViewContact.createScenePrimitive2DSequence(&rVisibleLayers));
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			if(xRetval.hasElements())
98cdf0e10cSrcweir 			{
99cdf0e10cSrcweir 				// handle GluePoint
100cdf0e10cSrcweir 				if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible())
101cdf0e10cSrcweir 				{
102cdf0e10cSrcweir 					const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence());
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 					if(xGlue.hasElements())
105cdf0e10cSrcweir 					{
106cdf0e10cSrcweir                         drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue);
107cdf0e10cSrcweir 					}
108cdf0e10cSrcweir 				}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 				// handle ghosted
111cdf0e10cSrcweir 				if(isPrimitiveGhosted(rDisplayInfo))
112cdf0e10cSrcweir 				{
113cdf0e10cSrcweir 					const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
114cdf0e10cSrcweir 					const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE);
115cdf0e10cSrcweir                     const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier));
116cdf0e10cSrcweir 
117cdf0e10cSrcweir                     xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
118cdf0e10cSrcweir 				}
119cdf0e10cSrcweir 			}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 			if(bIsActiveVC)
122cdf0e10cSrcweir 			{
123cdf0e10cSrcweir 				// set back, display ghosted again
124cdf0e10cSrcweir 				const_cast< DisplayInfo& >(rDisplayInfo).SetGhostedDrawMode();
125cdf0e10cSrcweir 			}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 			return xRetval;
128cdf0e10cSrcweir 		}
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
131cdf0e10cSrcweir 		{
132cdf0e10cSrcweir 			// To get the VOCs for the contained 3D objects created to get the correct
133cdf0e10cSrcweir 			// Draw hierarchy and ActionChanged() working properly, travel the DrawHierarchy
134cdf0e10cSrcweir 			// using a local tooling method
135cdf0e10cSrcweir 			impInternalSubHierarchyTraveller(*this);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 			// call parent
138cdf0e10cSrcweir 			return ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
139cdf0e10cSrcweir 		}
140cdf0e10cSrcweir 	} // end of namespace contact
141cdf0e10cSrcweir } // end of namespace sdr
142cdf0e10cSrcweir 
143cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
144cdf0e10cSrcweir // eof
145