1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew 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 impInternalSubHierarchyTraveller(const sdr::contact::ViewObjectContact & rVOC)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 { ViewObjectContactOfE3dScene(ObjectContact & rObjectContact,ViewContact & rViewContact)68cdf0e10cSrcweir ViewObjectContactOfE3dScene::ViewObjectContactOfE3dScene(ObjectContact& rObjectContact, ViewContact& rViewContact) 69cdf0e10cSrcweir : ViewObjectContactOfSdrObj(rObjectContact, rViewContact) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir ~ViewObjectContactOfE3dScene()73cdf0e10cSrcweir ViewObjectContactOfE3dScene::~ViewObjectContactOfE3dScene() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir } 76cdf0e10cSrcweir createPrimitive2DSequence(const DisplayInfo & rDisplayInfo) const77cdf0e10cSrcweir 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 { 99025b0597SArmin Le Grand // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description 100025b0597SArmin Le Grand xRetval = rViewContact.embedToObjectSpecificInformation(xRetval); 101025b0597SArmin Le Grand 102025b0597SArmin Le Grand // handle GluePoint 103cdf0e10cSrcweir if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible()) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence()); 106cdf0e10cSrcweir 107cdf0e10cSrcweir if(xGlue.hasElements()) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113*49c58f9bSArmin Le Grand // handle ghosted 114*49c58f9bSArmin Le Grand if(isPrimitiveGhosted(rDisplayInfo)) 115*49c58f9bSArmin Le Grand { 116*49c58f9bSArmin Le Grand const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); 117*49c58f9bSArmin Le Grand const ::basegfx::BColorModifierSharedPtr aBColorModifier( 118*49c58f9bSArmin Le Grand new basegfx::BColorModifier_interpolate( 119*49c58f9bSArmin Le Grand aRGBWhite, 120*49c58f9bSArmin Le Grand 0.5)); 121*49c58f9bSArmin Le Grand const drawinglayer::primitive2d::Primitive2DReference xReference( 122*49c58f9bSArmin Le Grand new drawinglayer::primitive2d::ModifiedColorPrimitive2D( 123*49c58f9bSArmin Le Grand xRetval, 124*49c58f9bSArmin Le Grand aBColorModifier)); 125cdf0e10cSrcweir 126cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 127*49c58f9bSArmin Le Grand } 128*49c58f9bSArmin Le Grand } 129cdf0e10cSrcweir 130cdf0e10cSrcweir if(bIsActiveVC) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir // set back, display ghosted again 133cdf0e10cSrcweir const_cast< DisplayInfo& >(rDisplayInfo).SetGhostedDrawMode(); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir return xRetval; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir getPrimitive2DSequenceHierarchy(DisplayInfo & rDisplayInfo) const139cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const 140cdf0e10cSrcweir { 141cdf0e10cSrcweir // To get the VOCs for the contained 3D objects created to get the correct 142cdf0e10cSrcweir // Draw hierarchy and ActionChanged() working properly, travel the DrawHierarchy 143cdf0e10cSrcweir // using a local tooling method 144cdf0e10cSrcweir impInternalSubHierarchyTraveller(*this); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // call parent 147cdf0e10cSrcweir return ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } // end of namespace contact 150cdf0e10cSrcweir } // end of namespace sdr 151cdf0e10cSrcweir 152cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 153cdf0e10cSrcweir // eof 154