1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <svx/sdr/contact/viewcontactofe3dcube.hxx> 32 #include <svx/cube3d.hxx> 33 #include <drawinglayer/primitive3d/sdrcubeprimitive3d.hxx> 34 #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 35 #include <svx/sdr/primitive3d/sdrattributecreator3d.hxx> 36 #include <basegfx/range/b3drange.hxx> 37 38 ////////////////////////////////////////////////////////////////////////////// 39 40 namespace sdr 41 { 42 namespace contact 43 { 44 ViewContactOfE3dCube::ViewContactOfE3dCube(E3dCubeObj& rCubeObj) 45 : ViewContactOfE3d(rCubeObj) 46 { 47 } 48 49 ViewContactOfE3dCube::~ViewContactOfE3dCube() 50 { 51 } 52 53 drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dCube::createViewIndependentPrimitive3DSequence() const 54 { 55 drawinglayer::primitive3d::Primitive3DSequence xRetval; 56 const SfxItemSet& rItemSet = GetE3dCubeObj().GetMergedItemSet(); 57 const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute( 58 drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false)); 59 60 // get cube geometry and use as traslation and scaling for unit cube 61 basegfx::B3DRange aCubeRange; 62 const basegfx::B3DVector aCubeSize(GetE3dCubeObj().GetCubeSize()); 63 const basegfx::B3DPoint aCubePosition(GetE3dCubeObj().GetCubePos()); 64 basegfx::B3DHomMatrix aWorldTransform; 65 66 if(GetE3dCubeObj().GetPosIsCenter()) 67 { 68 const basegfx::B3DVector aHalfCubeSize(aCubeSize / 2.0); 69 aCubeRange.expand(aCubePosition - aHalfCubeSize); 70 aCubeRange.expand(aCubePosition + aHalfCubeSize); 71 } 72 else 73 { 74 aCubeRange.expand(aCubePosition); 75 aCubeRange.expand(aCubePosition + aCubeSize); 76 } 77 78 // add scale and translate to world transformation 79 const basegfx::B3DVector abjectRange(aCubeRange.getRange()); 80 aWorldTransform.scale(abjectRange.getX(), abjectRange.getY(), abjectRange.getZ()); 81 aWorldTransform.translate(aCubeRange.getMinX(), aCubeRange.getMinY(), aCubeRange.getMinZ()); 82 83 // get 3D Object Attributes 84 drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); 85 86 // calculate texture size to get a perfect mapping for 87 // the front/back sides 88 const basegfx::B2DVector aTextureSize(aCubeSize.getX(), aCubeSize.getY()); 89 90 // create primitive and add 91 const drawinglayer::primitive3d::Primitive3DReference xReference( 92 new drawinglayer::primitive3d::SdrCubePrimitive3D( 93 aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute)); 94 xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); 95 96 // delete 3D Object Attributes 97 delete pSdr3DObjectAttribute; 98 99 return xRetval; 100 } 101 } // end of namespace contact 102 } // end of namespace sdr 103 104 ////////////////////////////////////////////////////////////////////////////// 105 // eof 106