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