merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / contact / viewobjectcontactofe3dscene.cxx
blob21f7a9d3e2133972ec3e1e2aefdb8627cac7155e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewobjectcontactofe3dscene.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
36 #include <svx/sdr/contact/displayinfo.hxx>
37 #include <svx/sdr/contact/objectcontact.hxx>
38 #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
39 #include <basegfx/matrix/b3dhommatrix.hxx>
40 #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
41 #include <basegfx/color/bcolormodifier.hxx>
42 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
43 #include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
44 #include <basegfx/tools/canvastools.hxx>
46 //////////////////////////////////////////////////////////////////////////////
48 using namespace com::sun::star;
50 //////////////////////////////////////////////////////////////////////////////
52 namespace
54 // Helper method to recursively travel the DrawHierarchy for 3D objects contained in
55 // the 2D Scene. This will chreate all VOCs for the currenbt OC which are needed
56 // for ActionChanged() functionality
57 void impInternalSubHierarchyTraveller(const sdr::contact::ViewObjectContact& rVOC)
59 const sdr::contact::ViewContact& rVC = rVOC.GetViewContact();
60 const sal_uInt32 nSubHierarchyCount(rVC.GetObjectCount());
62 for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
64 const sdr::contact::ViewObjectContact& rCandidate(rVC.GetViewContact(a).GetViewObjectContact(rVOC.GetObjectContact()));
65 impInternalSubHierarchyTraveller(rCandidate);
68 } // end of anonymous namespace
70 //////////////////////////////////////////////////////////////////////////////
72 namespace sdr
74 namespace contact
76 ViewObjectContactOfE3dScene::ViewObjectContactOfE3dScene(ObjectContact& rObjectContact, ViewContact& rViewContact)
77 : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
81 ViewObjectContactOfE3dScene::~ViewObjectContactOfE3dScene()
85 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
87 // handle ghosted, else the whole 3d group will be encapsulated to a ghosted primitive set (see below)
88 const bool bHandleGhostedDisplay(GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive());
89 const bool bIsActiveVC(bHandleGhostedDisplay && GetObjectContact().getActiveViewContact() == &GetViewContact());
91 if(bIsActiveVC)
93 // switch off ghosted, display contents normal
94 const_cast< DisplayInfo& >(rDisplayInfo).ClearGhostedDrawMode();
97 // create 2d primitive with content, use layer visibility test
98 // this uses no ghosted mode, so scenes in scenes and entering them will not
99 // support ghosted for now. This is no problem currently but would need to be
100 // added when sub-groups in 3d will be added one day.
101 const ViewContactOfE3dScene& rViewContact = dynamic_cast< ViewContactOfE3dScene& >(GetViewContact());
102 const SetOfByte& rVisibleLayers = rDisplayInfo.GetProcessLayers();
103 drawinglayer::primitive2d::Primitive2DSequence xRetval(rViewContact.createScenePrimitive2DSequence(&rVisibleLayers));
105 if(xRetval.hasElements())
107 // handle GluePoint
108 if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible())
110 const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence());
112 if(xGlue.hasElements())
114 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue);
118 // handle ghosted
119 if(isPrimitiveGhosted(rDisplayInfo))
121 const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
122 const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE);
123 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier));
125 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
128 else
130 // do neither print nor PDF export the fallback visualisation
131 if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
133 // empty group, fallback to parent method which will create the default
134 // grayed frame for empty 3d scenes by using model data and
135 // createViewIndependentPrimitive2DSequence::ViewContactOfE3dScene
136 xRetval = ViewObjectContactOfSdrObj::createPrimitive2DSequence(rDisplayInfo);
140 if(bIsActiveVC)
142 // set back, display ghosted again
143 const_cast< DisplayInfo& >(rDisplayInfo).SetGhostedDrawMode();
146 return xRetval;
149 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
151 // To get the VOCs for the contained 3D objects created to get the correct
152 // Draw hierarchy and ActionChanged() working properly, travel the DrawHierarchy
153 // using a local tooling method
154 impInternalSubHierarchyTraveller(*this);
156 // call parent
157 return ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
159 } // end of namespace contact
160 } // end of namespace sdr
162 //////////////////////////////////////////////////////////////////////////////
163 // eof