1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 32*cdf0e10cSrcweir #include <svx/svdogrp.hxx> 33*cdf0e10cSrcweir #include <svx/svdopath.hxx> 34*cdf0e10cSrcweir #include <tools/shl.hxx> 35*cdf0e10cSrcweir #include "svx/svditer.hxx" 36*cdf0e10cSrcweir #include <svx/svdpool.hxx> 37*cdf0e10cSrcweir #include <svx/svdorect.hxx> 38*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 39*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 40*cdf0e10cSrcweir #include <svx/svxids.hrc> 41*cdf0e10cSrcweir #include <editeng/colritem.hxx> 42*cdf0e10cSrcweir #include <svx/xtable.hxx> 43*cdf0e10cSrcweir #include <svx/svdview.hxx> 44*cdf0e10cSrcweir #include <svx/dialogs.hrc> 45*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 46*cdf0e10cSrcweir #include "svx/globl3d.hxx" 47*cdf0e10cSrcweir #include <svx/obj3d.hxx> 48*cdf0e10cSrcweir #include <svx/lathe3d.hxx> 49*cdf0e10cSrcweir #include <svx/sphere3d.hxx> 50*cdf0e10cSrcweir #include <svx/extrud3d.hxx> 51*cdf0e10cSrcweir #include <svx/cube3d.hxx> 52*cdf0e10cSrcweir #include <svx/polysc3d.hxx> 53*cdf0e10cSrcweir #include "dragmt3d.hxx" 54*cdf0e10cSrcweir #include <svx/view3d.hxx> 55*cdf0e10cSrcweir #include <svx/svdundo.hxx> 56*cdf0e10cSrcweir #include <svx/xflclit.hxx> 57*cdf0e10cSrcweir #include <svx/xlnclit.hxx> 58*cdf0e10cSrcweir #include <svx/svdograf.hxx> 59*cdf0e10cSrcweir #include <svx/xbtmpit.hxx> 60*cdf0e10cSrcweir #include <svx/xflbmtit.hxx> 61*cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx> 62*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 63*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 64*cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 65*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaypolypolygon.hxx> 66*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx> 67*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx> 68*cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dscene.hxx> 69*cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation3d.hxx> 70*cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx> 71*cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 72*cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx> 73*cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx> 74*cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> 75*cdf0e10cSrcweir #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx> 76*cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx> 77*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 78*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygoncutter.hxx> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir TYPEINIT1(E3dView, SdrView); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 85*cdf0e10cSrcweir // Migrate Marking 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir class Impl3DMirrorConstructOverlay 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir // The OverlayObjects 90*cdf0e10cSrcweir ::sdr::overlay::OverlayObjectList maObjects; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // the view 93*cdf0e10cSrcweir const E3dView& mrView; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir // the object count 96*cdf0e10cSrcweir sal_uInt32 mnCount; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // the unmirrored polygons 99*cdf0e10cSrcweir basegfx::B2DPolyPolygon* mpPolygons; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // the overlay geometry from selected objects 102*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence maFullOverlay; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir public: 105*cdf0e10cSrcweir Impl3DMirrorConstructOverlay(const E3dView& rView); 106*cdf0e10cSrcweir ~Impl3DMirrorConstructOverlay(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void SetMirrorAxis(Point aMirrorAxisA, Point aMirrorAxisB); 109*cdf0e10cSrcweir }; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir Impl3DMirrorConstructOverlay::Impl3DMirrorConstructOverlay(const E3dView& rView) 112*cdf0e10cSrcweir : maObjects(), 113*cdf0e10cSrcweir mrView(rView), 114*cdf0e10cSrcweir mnCount(rView.GetMarkedObjectCount()), 115*cdf0e10cSrcweir mpPolygons(0), 116*cdf0e10cSrcweir maFullOverlay() 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if(mnCount) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir if(mrView.IsSolidDragging()) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir SdrPageView* pPV = rView.GetSdrPageView(); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if(pPV && pPV->PageWindowCount()) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact(); 127*cdf0e10cSrcweir sdr::contact::DisplayInfo aDisplayInfo; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // Do not use the last ViewPort set at the OC at the last ProcessDisplay() 130*cdf0e10cSrcweir rOC.resetViewPort(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir for(sal_uInt32 a(0);a < mnCount;a++) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if(pObject) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir sdr::contact::ViewContact& rVC = pObject->GetViewContact(); 139*cdf0e10cSrcweir sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(rOC); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo)); 142*cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(maFullOverlay, aNewSequence); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir else 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir mpPolygons = new basegfx::B2DPolyPolygon[mnCount]; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir for(sal_uInt32 a(0); a < mnCount; a++) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); 154*cdf0e10cSrcweir mpPolygons[mnCount - (a + 1)] = pObject->TakeXorPoly(); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir Impl3DMirrorConstructOverlay::~Impl3DMirrorConstructOverlay() 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir // The OverlayObjects are cleared using the destructor of OverlayObjectList. 163*cdf0e10cSrcweir // That destructor calls clear() at the list which removes all objects from the 164*cdf0e10cSrcweir // OverlayManager and deletes them. 165*cdf0e10cSrcweir if(!mrView.IsSolidDragging()) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir delete[] mpPolygons; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirrorAxisB) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir // get rid of old overlay objects 174*cdf0e10cSrcweir maObjects.clear(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // create new ones 177*cdf0e10cSrcweir for(sal_uInt32 a(0); a < mrView.PaintWindowCount(); a++) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir SdrPaintWindow* pCandidate = mrView.GetPaintWindow(a); 180*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir if(pTargetOverlay) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir // buld transfoprmation: translate and rotate so that given edge is 185*cdf0e10cSrcweir // on x axis, them mirror in y and translate back 186*cdf0e10cSrcweir const basegfx::B2DVector aEdge(aMirrorAxisB.X() - aMirrorAxisA.X(), aMirrorAxisB.Y() - aMirrorAxisA.Y()); 187*cdf0e10cSrcweir basegfx::B2DHomMatrix aMatrixTransform(basegfx::tools::createTranslateB2DHomMatrix( 188*cdf0e10cSrcweir -aMirrorAxisA.X(), -aMirrorAxisA.Y())); 189*cdf0e10cSrcweir aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); 190*cdf0e10cSrcweir aMatrixTransform.scale(1.0, -1.0); 191*cdf0e10cSrcweir aMatrixTransform.rotate(atan2(aEdge.getY(), aEdge.getX())); 192*cdf0e10cSrcweir aMatrixTransform.translate(aMirrorAxisA.X(), aMirrorAxisA.Y()); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if(mrView.IsSolidDragging()) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir if(maFullOverlay.hasElements()) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence aContent(maFullOverlay); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir if(!aMatrixTransform.isIdentity()) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir // embed in transformation group 203*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DReference aTransformPrimitive2D(new drawinglayer::primitive2d::TransformPrimitive2D(aMatrixTransform, aContent)); 204*cdf0e10cSrcweir aContent = drawinglayer::primitive2d::Primitive2DSequence(&aTransformPrimitive2D, 1); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // if we have full overlay from selected objects, embed with 50% transparence, the 208*cdf0e10cSrcweir // transformation is added to the OverlayPrimitive2DSequenceObject 209*cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparencePrimitive2D(new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aContent, 0.5)); 210*cdf0e10cSrcweir aContent = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparencePrimitive2D, 1); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir sdr::overlay::OverlayPrimitive2DSequenceObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aContent); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir pTargetOverlay->add(*pNew); 215*cdf0e10cSrcweir maObjects.append(*pNew); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir else 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir for(sal_uInt32 b(0); b < mnCount; b++) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir // apply to polygon 223*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon(mpPolygons[b]); 224*cdf0e10cSrcweir aPolyPolygon.transform(aMatrixTransform); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon); 227*cdf0e10cSrcweir pTargetOverlay->add(*pNew); 228*cdf0e10cSrcweir maObjects.append(*pNew); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir /************************************************************************* 236*cdf0e10cSrcweir |* 237*cdf0e10cSrcweir |* Konstruktor 1 238*cdf0e10cSrcweir |* 239*cdf0e10cSrcweir \************************************************************************/ 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir E3dView::E3dView(SdrModel* pModel, OutputDevice* pOut) : 242*cdf0e10cSrcweir SdrView(pModel, pOut) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir InitView (); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir /************************************************************************* 248*cdf0e10cSrcweir |* 249*cdf0e10cSrcweir |* DrawMarkedObj ueberladen, da eventuell nur einzelne 3D-Objekte 250*cdf0e10cSrcweir |* gezeichnet werden sollen 251*cdf0e10cSrcweir |* 252*cdf0e10cSrcweir \************************************************************************/ 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir void E3dView::DrawMarkedObj(OutputDevice& rOut) const 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir // Existieren 3D-Objekte, deren Szenen nicht selektiert sind? 257*cdf0e10cSrcweir sal_Bool bSpecialHandling = sal_False; 258*cdf0e10cSrcweir E3dScene *pScene = NULL; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir long nCnt = GetMarkedObjectCount(); 261*cdf0e10cSrcweir for(long nObjs = 0;nObjs < nCnt;nObjs++) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 264*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dCompoundObject)) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir // zugehoerige Szene 267*cdf0e10cSrcweir pScene = ((E3dCompoundObject*)pObj)->GetScene(); 268*cdf0e10cSrcweir if(pScene && !IsObjMarked(pScene)) 269*cdf0e10cSrcweir bSpecialHandling = sal_True; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir // Alle SelectionFlags zuruecksetzen 272*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject)) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir pScene = ((E3dObject*)pObj)->GetScene(); 275*cdf0e10cSrcweir if(pScene) 276*cdf0e10cSrcweir pScene->SetSelected(sal_False); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir if(bSpecialHandling) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir // SelectionFlag bei allen zu 3D Objekten gehoerigen 283*cdf0e10cSrcweir // Szenen und deren Objekten auf nicht selektiert setzen 284*cdf0e10cSrcweir long nObjs; 285*cdf0e10cSrcweir for(nObjs = 0;nObjs < nCnt;nObjs++) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 288*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dCompoundObject)) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir // zugehoerige Szene 291*cdf0e10cSrcweir pScene = ((E3dCompoundObject*)pObj)->GetScene(); 292*cdf0e10cSrcweir if(pScene) 293*cdf0e10cSrcweir pScene->SetSelected(sal_False); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir // bei allen direkt selektierten Objekten auf selektiert setzen 298*cdf0e10cSrcweir SdrMark* pM = NULL; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir for(nObjs = 0;nObjs < nCnt;nObjs++) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 303*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject)) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir // Objekt markieren 306*cdf0e10cSrcweir E3dObject* p3DObj = (E3dObject*)pObj; 307*cdf0e10cSrcweir p3DObj->SetSelected(sal_True); 308*cdf0e10cSrcweir pScene = p3DObj->GetScene(); 309*cdf0e10cSrcweir pM = GetSdrMarkByIndex(nObjs); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir if(pScene) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir // code from parent 316*cdf0e10cSrcweir SortMarkedObjects(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir pScene->SetDrawOnlySelected(sal_True); 319*cdf0e10cSrcweir pScene->SingleObjectPainter(rOut); // #110094#-17 320*cdf0e10cSrcweir pScene->SetDrawOnlySelected(sal_False); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // SelectionFlag zuruecksetzen 324*cdf0e10cSrcweir for(nObjs = 0;nObjs < nCnt;nObjs++) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 327*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dCompoundObject)) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir // zugehoerige Szene 330*cdf0e10cSrcweir pScene = ((E3dCompoundObject*)pObj)->GetScene(); 331*cdf0e10cSrcweir if(pScene) 332*cdf0e10cSrcweir pScene->SetSelected(sal_False); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir else 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir // call parent 339*cdf0e10cSrcweir SdrExchangeView::DrawMarkedObj(rOut); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir /************************************************************************* 344*cdf0e10cSrcweir |* 345*cdf0e10cSrcweir |* Model holen ueberladen, da bei einzelnen 3D Objekten noch eine Szene 346*cdf0e10cSrcweir |* untergeschoben werden muss 347*cdf0e10cSrcweir |* 348*cdf0e10cSrcweir \************************************************************************/ 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir SdrModel* E3dView::GetMarkedObjModel() const 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir // Existieren 3D-Objekte, deren Szenen nicht selektiert sind? 353*cdf0e10cSrcweir bool bSpecialHandling(false); 354*cdf0e10cSrcweir const sal_uInt32 nCount(GetMarkedObjectCount()); 355*cdf0e10cSrcweir sal_uInt32 nObjs(0); 356*cdf0e10cSrcweir E3dScene *pScene = 0; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir for(nObjs = 0; nObjs < nCount; nObjs++) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir const SdrObject* pObj = GetMarkedObjectByIndex(nObjs); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir if(!bSpecialHandling && pObj && pObj->ISA(E3dCompoundObject)) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir // if the object is selected, but it's scene not, 365*cdf0e10cSrcweir // we need special handling 366*cdf0e10cSrcweir pScene = ((E3dCompoundObject*)pObj)->GetScene(); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if(pScene && !IsObjMarked(pScene)) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir bSpecialHandling = true; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject)) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir // reset all selection flags at 3D objects 377*cdf0e10cSrcweir pScene = ((E3dObject*)pObj)->GetScene(); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir if(pScene) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir pScene->SetSelected(false); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if(!bSpecialHandling) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir // call parent 389*cdf0e10cSrcweir return SdrView::GetMarkedObjModel(); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir SdrModel* pNewModel = 0; 393*cdf0e10cSrcweir Rectangle aSelectedSnapRect; 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir // set 3d selection flags at all directly selected objects 396*cdf0e10cSrcweir // and collect SnapRect of selected objects 397*cdf0e10cSrcweir for(nObjs = 0; nObjs < nCount; nObjs++) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dCompoundObject)) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir // mark object, but not scenes 404*cdf0e10cSrcweir E3dCompoundObject* p3DObj = (E3dCompoundObject*)pObj; 405*cdf0e10cSrcweir p3DObj->SetSelected(true); 406*cdf0e10cSrcweir aSelectedSnapRect.Union(p3DObj->GetSnapRect()); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir // create new mark list which contains all indirectly selected3d 411*cdf0e10cSrcweir // scenes as selected objects 412*cdf0e10cSrcweir SdrMarkList aOldML(GetMarkedObjectList()); 413*cdf0e10cSrcweir SdrMarkList aNewML; 414*cdf0e10cSrcweir SdrMarkList& rCurrentMarkList = ((E3dView*)this)->GetMarkedObjectListWriteAccess(); 415*cdf0e10cSrcweir rCurrentMarkList = aNewML; 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir for(nObjs = 0; nObjs < nCount; nObjs++) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir SdrObject *pObj = aOldML.GetMark(nObjs)->GetMarkedSdrObj(); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject)) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir pScene = ((E3dObject*)pObj)->GetScene(); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir if(pScene && !IsObjMarked(pScene) && GetSdrPageView()) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir ((E3dView*)this)->MarkObj(pScene, GetSdrPageView(), sal_False, sal_True); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir // call parent. This will copy all scenes and the selection flags at the 3d objectss. So 433*cdf0e10cSrcweir // it will be possible to delete all non-selected 3d objects from the cloned 3d scenes 434*cdf0e10cSrcweir pNewModel = SdrView::GetMarkedObjModel(); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir if(pNewModel) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir for(sal_uInt16 nPg(0); nPg < pNewModel->GetPageCount(); nPg++) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir const SdrPage* pSrcPg=pNewModel->GetPage(nPg); 441*cdf0e10cSrcweir const sal_uInt32 nObAnz(pSrcPg->GetObjCount()); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir for(sal_uInt32 nOb(0); nOb < nObAnz; nOb++) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir const SdrObject* pSrcOb=pSrcPg->GetObj(nOb); 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir if(pSrcOb->ISA(E3dScene)) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir pScene = (E3dScene*)pSrcOb; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir // delete all not intentionally cloned 3d objects 452*cdf0e10cSrcweir pScene->removeAllNonSelectedObjects(); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir // reset select flags and set SnapRect of all selected objects 455*cdf0e10cSrcweir pScene->SetSelected(false); 456*cdf0e10cSrcweir pScene->SetSnapRect(aSelectedSnapRect); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir // restore old selection 463*cdf0e10cSrcweir rCurrentMarkList = aOldML; 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir // model zurueckgeben 466*cdf0e10cSrcweir return pNewModel; 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir /************************************************************************* 470*cdf0e10cSrcweir |* 471*cdf0e10cSrcweir |* Bei Paste muss - falls in eine Scene eingefuegt wird - die 472*cdf0e10cSrcweir |* Objekte der Szene eingefuegt werden, die Szene selbst aber nicht 473*cdf0e10cSrcweir |* 474*cdf0e10cSrcweir \************************************************************************/ 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir sal_Bool E3dView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir sal_Bool bRetval = sal_False; 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir // Liste holen 481*cdf0e10cSrcweir Point aPos(rPos); 482*cdf0e10cSrcweir SdrObjList* pDstList = pLst; 483*cdf0e10cSrcweir ImpGetPasteObjList(aPos, pDstList); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir if(!pDstList) 486*cdf0e10cSrcweir return sal_False; 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir // Owner der Liste holen 489*cdf0e10cSrcweir SdrObject* pOwner = pDstList->GetOwnerObj(); 490*cdf0e10cSrcweir if(pOwner && pOwner->ISA(E3dScene)) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir E3dScene* pDstScene = (E3dScene*)pOwner; 493*cdf0e10cSrcweir BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXCHANGE_PASTE)); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir // Alle Objekte aus E3dScenes kopieren und direkt einfuegen 496*cdf0e10cSrcweir for(sal_uInt16 nPg(0); nPg < rMod.GetPageCount(); nPg++) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir const SdrPage* pSrcPg=rMod.GetPage(nPg); 499*cdf0e10cSrcweir sal_uInt32 nObAnz(pSrcPg->GetObjCount()); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir // calculate offset for paste 502*cdf0e10cSrcweir Rectangle aR = pSrcPg->GetAllObjBoundRect(); 503*cdf0e10cSrcweir Point aDist(aPos - aR.Center()); 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir // Unterobjekte von Szenen einfuegen 506*cdf0e10cSrcweir for(sal_uInt32 nOb(0); nOb < nObAnz; nOb++) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir const SdrObject* pSrcOb = pSrcPg->GetObj(nOb); 509*cdf0e10cSrcweir if(pSrcOb->ISA(E3dScene)) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir E3dScene* pSrcScene = (E3dScene*)pSrcOb; 512*cdf0e10cSrcweir ImpCloneAll3DObjectsToDestScene(pSrcScene, pDstScene, aDist); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir EndUndo(); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir else 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir // call parent 521*cdf0e10cSrcweir bRetval = SdrView::Paste(rMod, rPos, pLst, nOptions); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir // und Rueckgabewert liefern 525*cdf0e10cSrcweir return bRetval; 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir // #83403# Service routine used from local Clone() and from SdrCreateView::EndCreateObj(...) 529*cdf0e10cSrcweir sal_Bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene* pSrcScene, E3dScene* pDstScene, Point /*aOffset*/) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir sal_Bool bRetval(sal_False); 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir if(pSrcScene && pDstScene) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCSceneDst = static_cast< sdr::contact::ViewContactOfE3dScene& >(pDstScene->GetViewContact()); 536*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation3D aViewInfo3DDst(rVCSceneDst.getViewInformation3D()); 537*cdf0e10cSrcweir const sdr::contact::ViewContactOfE3dScene& rVCSceneSrc = static_cast< sdr::contact::ViewContactOfE3dScene& >(pSrcScene->GetViewContact()); 538*cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation3D aViewInfo3DSrc(rVCSceneSrc.getViewInformation3D()); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir for(sal_uInt32 i(0); i < pSrcScene->GetSubList()->GetObjCount(); i++) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir E3dCompoundObject* pCompoundObj = dynamic_cast< E3dCompoundObject* >(pSrcScene->GetSubList()->GetObj(i)); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir if(pCompoundObj) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir // #116235# 547*cdf0e10cSrcweir E3dCompoundObject* pNewCompoundObj = dynamic_cast< E3dCompoundObject* >(pCompoundObj->Clone()); 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir if(pNewCompoundObj) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir // get dest scene's current range in 3D world coordinates 552*cdf0e10cSrcweir const basegfx::B3DHomMatrix aSceneToWorldTrans(pDstScene->GetFullTransform()); 553*cdf0e10cSrcweir basegfx::B3DRange aSceneRange(pDstScene->GetBoundVolume()); 554*cdf0e10cSrcweir aSceneRange.transform(aSceneToWorldTrans); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir // get new object's implied object transformation 557*cdf0e10cSrcweir const basegfx::B3DHomMatrix aNewObjectTrans(pNewCompoundObj->GetTransform()); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir // get new object's range in 3D world coordinates in dest scene 560*cdf0e10cSrcweir // as if it were already added 561*cdf0e10cSrcweir const basegfx::B3DHomMatrix aObjectToWorldTrans(aSceneToWorldTrans * aNewObjectTrans); 562*cdf0e10cSrcweir basegfx::B3DRange aObjectRange(pNewCompoundObj->GetBoundVolume()); 563*cdf0e10cSrcweir aObjectRange.transform(aObjectToWorldTrans); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // get scale adaption 566*cdf0e10cSrcweir const basegfx::B3DVector aSceneScale(aSceneRange.getRange()); 567*cdf0e10cSrcweir const basegfx::B3DVector aObjectScale(aObjectRange.getRange()); 568*cdf0e10cSrcweir double fScale(1.0); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir // if new object's size in X,Y or Z is bigger that 80% of dest scene, adapt scale 571*cdf0e10cSrcweir // to not change the scene by the inserted object 572*cdf0e10cSrcweir const double fSizeFactor(0.5); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if(aObjectScale.getX() * fScale > aSceneScale.getX() * fSizeFactor) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir const double fObjSize(aObjectScale.getX() * fScale); 577*cdf0e10cSrcweir const double fFactor((aSceneScale.getX() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize)); 578*cdf0e10cSrcweir fScale *= fFactor; 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir if(aObjectScale.getY() * fScale > aSceneScale.getY() * fSizeFactor) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir const double fObjSize(aObjectScale.getY() * fScale); 584*cdf0e10cSrcweir const double fFactor((aSceneScale.getY() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize)); 585*cdf0e10cSrcweir fScale *= fFactor; 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir if(aObjectScale.getZ() * fScale > aSceneScale.getZ() * fSizeFactor) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir const double fObjSize(aObjectScale.getZ() * fScale); 591*cdf0e10cSrcweir const double fFactor((aSceneScale.getZ() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize)); 592*cdf0e10cSrcweir fScale *= fFactor; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // get translation adaption 596*cdf0e10cSrcweir const basegfx::B3DPoint aSceneCenter(aSceneRange.getCenter()); 597*cdf0e10cSrcweir const basegfx::B3DPoint aObjectCenter(aObjectRange.getCenter()); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir // build full modification transform. The object's transformation 600*cdf0e10cSrcweir // shall be modified, so start at object coordinates; transform to 3d world coor 601*cdf0e10cSrcweir basegfx::B3DHomMatrix aModifyingTransform(aObjectToWorldTrans); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // translate to absolute center in 3d world coor 604*cdf0e10cSrcweir aModifyingTransform.translate(-aObjectCenter.getX(), -aObjectCenter.getY(), -aObjectCenter.getZ()); 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir // scale to dest size in 3d world coor 607*cdf0e10cSrcweir aModifyingTransform.scale(fScale, fScale, fScale); 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir // translate to dest scene center in 3d world coor 610*cdf0e10cSrcweir aModifyingTransform.translate(aSceneCenter.getX(), aSceneCenter.getY(), aSceneCenter.getZ()); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir // transform from 3d world to dest object coordinates 613*cdf0e10cSrcweir basegfx::B3DHomMatrix aWorldToObject(aObjectToWorldTrans); 614*cdf0e10cSrcweir aWorldToObject.invert(); 615*cdf0e10cSrcweir aModifyingTransform = aWorldToObject * aModifyingTransform; 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir // correct implied object transform by applying changing one in object coor 618*cdf0e10cSrcweir pNewCompoundObj->SetTransform(aModifyingTransform * aNewObjectTrans); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir // fill and insert new object 621*cdf0e10cSrcweir pNewCompoundObj->SetModel(pDstScene->GetModel()); 622*cdf0e10cSrcweir pNewCompoundObj->SetPage(pDstScene->GetPage()); 623*cdf0e10cSrcweir pNewCompoundObj->NbcSetLayer(pCompoundObj->GetLayer()); 624*cdf0e10cSrcweir pNewCompoundObj->NbcSetStyleSheet(pCompoundObj->GetStyleSheet(), sal_True); 625*cdf0e10cSrcweir pDstScene->Insert3DObj(pNewCompoundObj); 626*cdf0e10cSrcweir bRetval = sal_True; 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir // Undo anlegen 629*cdf0e10cSrcweir if( GetModel()->IsUndoEnabled() ) 630*cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj)); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir return bRetval; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir /************************************************************************* 640*cdf0e10cSrcweir |* 641*cdf0e10cSrcweir |* 3D-Konvertierung moeglich? 642*cdf0e10cSrcweir |* 643*cdf0e10cSrcweir \************************************************************************/ 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir sal_Bool E3dView::IsConvertTo3DObjPossible() const 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir sal_Bool bAny3D(sal_False); 648*cdf0e10cSrcweir sal_Bool bGroupSelected(sal_False); 649*cdf0e10cSrcweir sal_Bool bRetval(sal_True); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir for(sal_uInt32 a=0;!bAny3D && a<GetMarkedObjectCount();a++) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(a); 654*cdf0e10cSrcweir if(pObj) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir ImpIsConvertTo3DPossible(pObj, bAny3D, bGroupSelected); 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir bRetval = !bAny3D 661*cdf0e10cSrcweir && ( 662*cdf0e10cSrcweir IsConvertToPolyObjPossible(sal_False) 663*cdf0e10cSrcweir || IsConvertToPathObjPossible(sal_False) 664*cdf0e10cSrcweir || IsImportMtfPossible()); 665*cdf0e10cSrcweir return bRetval; 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir void E3dView::ImpIsConvertTo3DPossible(SdrObject* pObj, sal_Bool& rAny3D, 669*cdf0e10cSrcweir sal_Bool& rGroupSelected) const 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir if(pObj) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir if(pObj->ISA(E3dObject)) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir rAny3D = sal_True; 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir else 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir if(pObj->IsGroupObject()) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir SdrObjListIter aIter(*pObj, IM_DEEPNOGROUPS); 682*cdf0e10cSrcweir while(aIter.IsMore()) 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir SdrObject* pNewObj = aIter.Next(); 685*cdf0e10cSrcweir ImpIsConvertTo3DPossible(pNewObj, rAny3D, rGroupSelected); 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir rGroupSelected = sal_True; 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir /************************************************************************* 694*cdf0e10cSrcweir |* 695*cdf0e10cSrcweir |* 3D-Konvertierung zu Extrude ausfuehren 696*cdf0e10cSrcweir |* 697*cdf0e10cSrcweir \************************************************************************/ 698*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir if(pObj->ISA(SdrTextObj)) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir const SfxItemSet& rSet = pObj->GetMergedItemSet(); 705*cdf0e10cSrcweir const SvxColorItem& rTextColorItem = (const SvxColorItem&)rSet.Get(EE_CHAR_COLOR); 706*cdf0e10cSrcweir if(rTextColorItem.GetValue() == RGB_Color(COL_BLACK)) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir // Bei schwarzen Textobjekten wird die Farbe auf grau gesetzt 709*cdf0e10cSrcweir if(pObj->GetPage()) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir // #84864# if black is only default attribute from 712*cdf0e10cSrcweir // pattern set it hard so that it is used in undo. 713*cdf0e10cSrcweir pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_BLACK), EE_CHAR_COLOR)); 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir // add undo now 716*cdf0e10cSrcweir if( GetModel()->IsUndoEnabled() ) 717*cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false)); 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_GRAY), EE_CHAR_COLOR)); 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir void E3dView::ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir if(pObj->ISA(SdrPathObj)) 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir const SfxItemSet& rSet = pObj->GetMergedItemSet(); 730*cdf0e10cSrcweir sal_Int32 nLineWidth = ((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue(); 731*cdf0e10cSrcweir XLineStyle eLineStyle = (XLineStyle)((const XLineStyleItem&)rSet.Get(XATTR_LINESTYLE)).GetValue(); 732*cdf0e10cSrcweir XFillStyle eFillStyle = ITEMVALUE(rSet, XATTR_FILLSTYLE, XFillStyleItem); 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir if(((SdrPathObj*)pObj)->IsClosed() 735*cdf0e10cSrcweir && eLineStyle == XLINE_SOLID 736*cdf0e10cSrcweir && !nLineWidth 737*cdf0e10cSrcweir && eFillStyle != XFILL_NONE) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir if(pObj->GetPage() && GetModel()->IsUndoEnabled() ) 740*cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false)); 741*cdf0e10cSrcweir pObj->SetMergedItem(XLineStyleItem(XLINE_NONE)); 742*cdf0e10cSrcweir pObj->SetMergedItem(XLineWidthItem(0L)); 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, sal_Bool bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir // Einzelnes PathObject, dieses umwanden 750*cdf0e10cSrcweir SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj); 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir if(pPath) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir E3dDefaultAttributes aDefault = Get3DDefaultAttributes(); 755*cdf0e10cSrcweir if(bExtrude) 756*cdf0e10cSrcweir aDefault.SetDefaultExtrudeCharacterMode(sal_True); 757*cdf0e10cSrcweir else 758*cdf0e10cSrcweir aDefault.SetDefaultLatheCharacterMode(sal_True); 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir // ItemSet des Ursprungsobjektes holen 761*cdf0e10cSrcweir SfxItemSet aSet(pObj->GetMergedItemSet()); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir XFillStyle eFillStyle = ITEMVALUE(aSet, XATTR_FILLSTYLE, XFillStyleItem); 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir // Linienstil ausschalten 766*cdf0e10cSrcweir aSet.Put(XLineStyleItem(XLINE_NONE)); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir // Feststellen, ob ein FILL_Attribut gesetzt ist. 769*cdf0e10cSrcweir if(!pPath->IsClosed() || eFillStyle == XFILL_NONE) 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir // Das SdrPathObj ist nicht gefuellt, lasse die 772*cdf0e10cSrcweir // vordere und hintere Flaeche weg. Ausserdem ist 773*cdf0e10cSrcweir // eine beidseitige Darstellung notwendig. 774*cdf0e10cSrcweir aDefault.SetDefaultExtrudeCloseFront(sal_False); 775*cdf0e10cSrcweir aDefault.SetDefaultExtrudeCloseBack(sal_False); 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir aSet.Put(Svx3DDoubleSidedItem(sal_True)); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir // Fuellattribut setzen 780*cdf0e10cSrcweir aSet.Put(XFillStyleItem(XFILL_SOLID)); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir // Fuellfarbe muss auf Linienfarbe, da das Objekt vorher 783*cdf0e10cSrcweir // nur eine Linie war 784*cdf0e10cSrcweir Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue(); 785*cdf0e10cSrcweir aSet.Put(XFillColorItem(String(), aColorLine)); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir // Neues Extrude-Objekt erzeugen 789*cdf0e10cSrcweir E3dObject* p3DObj = NULL; 790*cdf0e10cSrcweir if(bExtrude) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir p3DObj = new E3dExtrudeObj(aDefault, pPath->GetPathPoly(), fDepth); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir else 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPoly2D(pPath->GetPathPoly()); 797*cdf0e10cSrcweir aPolyPoly2D.transform(rLatheMat); 798*cdf0e10cSrcweir p3DObj = new E3dLatheObj(aDefault, aPolyPoly2D); 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir // Attribute setzen 802*cdf0e10cSrcweir if(p3DObj) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir p3DObj->NbcSetLayer(pObj->GetLayer()); 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir p3DObj->SetMergedItemSet(aSet); 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir p3DObj->NbcSetStyleSheet(pObj->GetStyleSheet(), sal_True); 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir // Neues 3D-Objekt einfuegen 811*cdf0e10cSrcweir pScene->Insert3DObj(p3DObj); 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, sal_Bool bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir if(pObj) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir // change text color attribute for not so dark colors 821*cdf0e10cSrcweir if(pObj->IsGroupObject()) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir SdrObjListIter aIter(*pObj, IM_DEEPWITHGROUPS); 824*cdf0e10cSrcweir while(aIter.IsMore()) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir SdrObject* pGroupMember = aIter.Next(); 827*cdf0e10cSrcweir ImpChangeSomeAttributesFor3DConversion(pGroupMember); 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir else 831*cdf0e10cSrcweir ImpChangeSomeAttributesFor3DConversion(pObj); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir // convert completely to path objects 834*cdf0e10cSrcweir SdrObject* pNewObj1 = pObj->ConvertToPolyObj(sal_False, sal_False); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir if(pNewObj1) 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir // change text color attribute for not so dark colors 839*cdf0e10cSrcweir if(pNewObj1->IsGroupObject()) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir SdrObjListIter aIter(*pNewObj1, IM_DEEPWITHGROUPS); 842*cdf0e10cSrcweir while(aIter.IsMore()) 843*cdf0e10cSrcweir { 844*cdf0e10cSrcweir SdrObject* pGroupMember = aIter.Next(); 845*cdf0e10cSrcweir ImpChangeSomeAttributesFor3DConversion2(pGroupMember); 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir else 849*cdf0e10cSrcweir ImpChangeSomeAttributesFor3DConversion2(pNewObj1); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir // convert completely to path objects 852*cdf0e10cSrcweir SdrObject* pNewObj2 = pObj->ConvertToContourObj(pNewObj1, sal_True); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir if(pNewObj2) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir // add all to flat scene 857*cdf0e10cSrcweir if(pNewObj2->IsGroupObject()) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir SdrObjListIter aIter(*pNewObj2, IM_DEEPWITHGROUPS); 860*cdf0e10cSrcweir while(aIter.IsMore()) 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir SdrObject* pGroupMember = aIter.Next(); 863*cdf0e10cSrcweir ImpCreateSingle3DObjectFlat(pScene, pGroupMember, bExtrude, fDepth, rLatheMat); 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir } 866*cdf0e10cSrcweir else 867*cdf0e10cSrcweir ImpCreateSingle3DObjectFlat(pScene, pNewObj2, bExtrude, fDepth, rLatheMat); 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir // delete zwi object 870*cdf0e10cSrcweir if(pNewObj2 != pObj && pNewObj2 != pNewObj1 && pNewObj2) 871*cdf0e10cSrcweir SdrObject::Free( pNewObj2 ); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir // delete zwi object 875*cdf0e10cSrcweir if(pNewObj1 != pObj && pNewObj1) 876*cdf0e10cSrcweir SdrObject::Free( pNewObj1 ); 877*cdf0e10cSrcweir } 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir /************************************************************************* 882*cdf0e10cSrcweir |* 883*cdf0e10cSrcweir |* 3D-Konvertierung zu Extrude steuern 884*cdf0e10cSrcweir |* 885*cdf0e10cSrcweir \************************************************************************/ 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir void E3dView::ConvertMarkedObjTo3D(sal_Bool bExtrude, basegfx::B2DPoint aPnt1, basegfx::B2DPoint aPnt2) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir if(AreObjectsMarked()) 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir // Undo anlegen 892*cdf0e10cSrcweir if(bExtrude) 893*cdf0e10cSrcweir BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE)); 894*cdf0e10cSrcweir else 895*cdf0e10cSrcweir BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_LATHE)); 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir // Neue Szene fuer zu erzeugende 3D-Objekte anlegen 898*cdf0e10cSrcweir E3dScene* pScene = new E3dPolyScene(Get3DDefaultAttributes()); 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir // Rechteck bestimmen und evtl. korrigieren 901*cdf0e10cSrcweir Rectangle aRect = GetAllMarkedRect(); 902*cdf0e10cSrcweir if(aRect.GetWidth() <= 1) 903*cdf0e10cSrcweir aRect.SetSize(Size(500, aRect.GetHeight())); 904*cdf0e10cSrcweir if(aRect.GetHeight() <= 1) 905*cdf0e10cSrcweir aRect.SetSize(Size(aRect.GetWidth(), 500)); 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir // Tiefe relativ zur Groesse der Selektion bestimmen 908*cdf0e10cSrcweir double fDepth = 0.0; 909*cdf0e10cSrcweir double fRot3D = 0.0; 910*cdf0e10cSrcweir basegfx::B2DHomMatrix aLatheMat; 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir if(bExtrude) 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir double fW = (double)aRect.GetWidth(); 915*cdf0e10cSrcweir double fH = (double)aRect.GetHeight(); 916*cdf0e10cSrcweir fDepth = sqrt(fW*fW + fH*fH) / 6.0; 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir if(!bExtrude) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir // Transformation fuer Polygone Rotationskoerper erstellen 921*cdf0e10cSrcweir if(aPnt1 != aPnt2) 922*cdf0e10cSrcweir { 923*cdf0e10cSrcweir // Rotation um Kontrollpunkt1 mit eigestelltem Winkel 924*cdf0e10cSrcweir // fuer 3D Koordinaten 925*cdf0e10cSrcweir basegfx::B2DPoint aDiff(aPnt1 - aPnt2); 926*cdf0e10cSrcweir fRot3D = atan2(aDiff.getY(), aDiff.getX()) - F_PI2; 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir if(basegfx::fTools::equalZero(fabs(fRot3D))) 929*cdf0e10cSrcweir fRot3D = 0.0; 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir if(fRot3D != 0.0) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir aLatheMat = basegfx::tools::createRotateAroundPoint(aPnt2, -fRot3D) 934*cdf0e10cSrcweir * aLatheMat; 935*cdf0e10cSrcweir } 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir if(aPnt2.getX() != 0.0) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir // Translation auf Y=0 - Achse 941*cdf0e10cSrcweir aLatheMat.translate(-aPnt2.getX(), 0.0); 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir else 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir aLatheMat.translate((double)-aRect.Left(), 0.0); 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir // Inverse Matrix bilden, um die Zielausdehnung zu bestimmen 949*cdf0e10cSrcweir basegfx::B2DHomMatrix aInvLatheMat(aLatheMat); 950*cdf0e10cSrcweir aInvLatheMat.invert(); 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir // SnapRect Ausdehnung mittels Spiegelung an der Rotationsachse 953*cdf0e10cSrcweir // erweitern 954*cdf0e10cSrcweir for(sal_uInt32 a=0;a<GetMarkedObjectCount();a++) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir SdrMark* pMark = GetSdrMarkByIndex(a); 957*cdf0e10cSrcweir SdrObject* pObj = pMark->GetMarkedSdrObj(); 958*cdf0e10cSrcweir Rectangle aTurnRect = pObj->GetSnapRect(); 959*cdf0e10cSrcweir basegfx::B2DPoint aRot; 960*cdf0e10cSrcweir Point aRotPnt; 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir aRot = basegfx::B2DPoint(aTurnRect.Left(), -aTurnRect.Top()); 963*cdf0e10cSrcweir aRot *= aLatheMat; 964*cdf0e10cSrcweir aRot.setX(-aRot.getX()); 965*cdf0e10cSrcweir aRot *= aInvLatheMat; 966*cdf0e10cSrcweir aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5)); 967*cdf0e10cSrcweir aRect.Union(Rectangle(aRotPnt, aRotPnt)); 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir aRot = basegfx::B2DPoint(aTurnRect.Left(), -aTurnRect.Bottom()); 970*cdf0e10cSrcweir aRot *= aLatheMat; 971*cdf0e10cSrcweir aRot.setX(-aRot.getX()); 972*cdf0e10cSrcweir aRot *= aInvLatheMat; 973*cdf0e10cSrcweir aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5)); 974*cdf0e10cSrcweir aRect.Union(Rectangle(aRotPnt, aRotPnt)); 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir aRot = basegfx::B2DPoint(aTurnRect.Right(), -aTurnRect.Top()); 977*cdf0e10cSrcweir aRot *= aLatheMat; 978*cdf0e10cSrcweir aRot.setX(-aRot.getX()); 979*cdf0e10cSrcweir aRot *= aInvLatheMat; 980*cdf0e10cSrcweir aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5)); 981*cdf0e10cSrcweir aRect.Union(Rectangle(aRotPnt, aRotPnt)); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir aRot = basegfx::B2DPoint(aTurnRect.Right(), -aTurnRect.Bottom()); 984*cdf0e10cSrcweir aRot *= aLatheMat; 985*cdf0e10cSrcweir aRot.setX(-aRot.getX()); 986*cdf0e10cSrcweir aRot *= aInvLatheMat; 987*cdf0e10cSrcweir aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5)); 988*cdf0e10cSrcweir aRect.Union(Rectangle(aRotPnt, aRotPnt)); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir // Ueber die Selektion gehen und in 3D wandeln, komplett mit 993*cdf0e10cSrcweir // Umwandeln in SdrPathObject, auch Schriften 994*cdf0e10cSrcweir for(sal_uInt32 a=0;a<GetMarkedObjectCount();a++) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir SdrMark* pMark = GetSdrMarkByIndex(a); 997*cdf0e10cSrcweir SdrObject* pObj = pMark->GetMarkedSdrObj(); 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir ImpCreate3DObject(pScene, pObj, bExtrude, fDepth, aLatheMat); 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir if(pScene->GetSubList() && pScene->GetSubList()->GetObjCount() != 0) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir // Alle angelegten Objekte Tiefenarrangieren 1005*cdf0e10cSrcweir if(bExtrude) 1006*cdf0e10cSrcweir DoDepthArrange(pScene, fDepth); 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir // 3D-Objekte auf die Mitte des Gesamtrechtecks zentrieren 1009*cdf0e10cSrcweir basegfx::B3DPoint aCenter(pScene->GetBoundVolume().getCenter()); 1010*cdf0e10cSrcweir basegfx::B3DHomMatrix aMatrix; 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir aMatrix.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ()); 1013*cdf0e10cSrcweir pScene->SetTransform(aMatrix * pScene->GetTransform()); // #112587# 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir // Szene initialisieren 1016*cdf0e10cSrcweir pScene->NbcSetSnapRect(aRect); 1017*cdf0e10cSrcweir basegfx::B3DRange aBoundVol = pScene->GetBoundVolume(); 1018*cdf0e10cSrcweir InitScene(pScene, (double)aRect.GetWidth(), (double)aRect.GetHeight(), aBoundVol.getDepth()); 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir // Szene anstelle des ersten selektierten Objektes einfuegen 1021*cdf0e10cSrcweir // und alle alten Objekte weghauen 1022*cdf0e10cSrcweir SdrObject* pRepObj = GetMarkedObjectByIndex(0); 1023*cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageViewOfMarkedByIndex(0); 1024*cdf0e10cSrcweir MarkObj(pRepObj, pPV, sal_True); 1025*cdf0e10cSrcweir ReplaceObjectAtView(pRepObj, *pPV, pScene, sal_False); 1026*cdf0e10cSrcweir DeleteMarked(); 1027*cdf0e10cSrcweir MarkObj(pScene, pPV); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir // Rotationskoerper um Rotationsachse drehen 1030*cdf0e10cSrcweir basegfx::B3DHomMatrix aRotate; 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir if(!bExtrude && fRot3D != 0.0) 1033*cdf0e10cSrcweir { 1034*cdf0e10cSrcweir aRotate.rotate(0.0, 0.0, fRot3D); 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir // Default-Rotation setzen 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir double XRotateDefault = 20; 1040*cdf0e10cSrcweir aRotate.rotate(DEG2RAD(XRotateDefault), 0.0, 0.0); 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir if(!aRotate.isIdentity()) 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir pScene->SetTransform(aRotate * pScene->GetTransform()); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir // SnapRects der Objekte ungueltig 1049*cdf0e10cSrcweir pScene->SetSnapRect(aRect); 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir else 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir // Es wurden keine 3D Objekte erzeugt, schmeiss alles weg 1054*cdf0e10cSrcweir delete pScene; 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir 1057*cdf0e10cSrcweir // Undo abschliessen 1058*cdf0e10cSrcweir EndUndo(); 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir /************************************************************************* 1063*cdf0e10cSrcweir |* 1064*cdf0e10cSrcweir |* Alle enthaltenen Extrude-Objekte Tiefenarrangieren 1065*cdf0e10cSrcweir |* 1066*cdf0e10cSrcweir \************************************************************************/ 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir struct E3dDepthNeighbour 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir E3dDepthNeighbour* mpNext; 1071*cdf0e10cSrcweir E3dExtrudeObj* mpObj; 1072*cdf0e10cSrcweir basegfx::B2DPolyPolygon maPreparedPolyPolygon; 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir E3dDepthNeighbour() 1075*cdf0e10cSrcweir : mpNext(0), 1076*cdf0e10cSrcweir mpObj(0), 1077*cdf0e10cSrcweir maPreparedPolyPolygon() 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir } 1080*cdf0e10cSrcweir }; 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir struct E3dDepthLayer 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir E3dDepthLayer* mpDown; 1085*cdf0e10cSrcweir E3dDepthNeighbour* mpNext; 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir E3dDepthLayer() 1088*cdf0e10cSrcweir : mpDown(0), 1089*cdf0e10cSrcweir mpNext(0) 1090*cdf0e10cSrcweir { 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir ~E3dDepthLayer() 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir while(mpNext) 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir E3dDepthNeighbour* pSucc = mpNext->mpNext; 1098*cdf0e10cSrcweir delete mpNext; 1099*cdf0e10cSrcweir mpNext = pSucc; 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir }; 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir void E3dView::DoDepthArrange(E3dScene* pScene, double fDepth) 1105*cdf0e10cSrcweir { 1106*cdf0e10cSrcweir if(pScene && pScene->GetSubList() && pScene->GetSubList()->GetObjCount() > 1) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir SdrObjList* pSubList = pScene->GetSubList(); 1109*cdf0e10cSrcweir SdrObjListIter aIter(*pSubList, IM_FLAT); 1110*cdf0e10cSrcweir E3dDepthLayer* pBaseLayer = NULL; 1111*cdf0e10cSrcweir E3dDepthLayer* pLayer = NULL; 1112*cdf0e10cSrcweir sal_Int32 nNumLayers = 0; 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir while(aIter.IsMore()) 1115*cdf0e10cSrcweir { 1116*cdf0e10cSrcweir E3dExtrudeObj* pExtrudeObj = dynamic_cast< E3dExtrudeObj* >(aIter.Next()); 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir if(pExtrudeObj) 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir const basegfx::B2DPolyPolygon aExtrudePoly( 1121*cdf0e10cSrcweir basegfx::tools::prepareForPolygonOperation(pExtrudeObj->GetExtrudePolygon())); 1122*cdf0e10cSrcweir const SfxItemSet& rLocalSet = pExtrudeObj->GetMergedItemSet(); 1123*cdf0e10cSrcweir const XFillStyle eLocalFillStyle = ITEMVALUE(rLocalSet, XATTR_FILLSTYLE, XFillStyleItem); 1124*cdf0e10cSrcweir const Color aLocalColor = ((const XFillColorItem&)(rLocalSet.Get(XATTR_FILLCOLOR))).GetColorValue(); 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir // sort in ExtrudeObj 1127*cdf0e10cSrcweir if(pLayer) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir // do we have overlap with an object of this layer? 1130*cdf0e10cSrcweir bool bOverlap(false); 1131*cdf0e10cSrcweir E3dDepthNeighbour* pAct = pLayer->mpNext; 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir while(!bOverlap && pAct) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir // do pAct->mpObj and pExtrudeObj overlap? Check by 1136*cdf0e10cSrcweir // using logical AND clipping 1137*cdf0e10cSrcweir const basegfx::B2DPolyPolygon aAndPolyPolygon( 1138*cdf0e10cSrcweir basegfx::tools::solvePolygonOperationAnd( 1139*cdf0e10cSrcweir aExtrudePoly, 1140*cdf0e10cSrcweir pAct->maPreparedPolyPolygon)); 1141*cdf0e10cSrcweir 1142*cdf0e10cSrcweir bOverlap = (0 != aAndPolyPolygon.count()); 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir if(bOverlap) 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir // second ciriteria: is another fillstyle or color used? 1147*cdf0e10cSrcweir const SfxItemSet& rCompareSet = pAct->mpObj->GetMergedItemSet(); 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir XFillStyle eCompareFillStyle = ITEMVALUE(rCompareSet, XATTR_FILLSTYLE, XFillStyleItem); 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir if(eLocalFillStyle == eCompareFillStyle) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir if(eLocalFillStyle == XFILL_SOLID) 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir Color aCompareColor = ((const XFillColorItem&)(rCompareSet.Get(XATTR_FILLCOLOR))).GetColorValue(); 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir if(aCompareColor == aLocalColor) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir bOverlap = sal_False; 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir else if(eLocalFillStyle == XFILL_NONE) 1163*cdf0e10cSrcweir { 1164*cdf0e10cSrcweir bOverlap = sal_False; 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir } 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir pAct = pAct->mpNext; 1170*cdf0e10cSrcweir } 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir if(bOverlap) 1173*cdf0e10cSrcweir { 1174*cdf0e10cSrcweir // yes, start a new layer 1175*cdf0e10cSrcweir pLayer->mpDown = new E3dDepthLayer; 1176*cdf0e10cSrcweir pLayer = pLayer->mpDown; 1177*cdf0e10cSrcweir nNumLayers++; 1178*cdf0e10cSrcweir pLayer->mpNext = new E3dDepthNeighbour; 1179*cdf0e10cSrcweir pLayer->mpNext->mpObj = pExtrudeObj; 1180*cdf0e10cSrcweir pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly; 1181*cdf0e10cSrcweir } 1182*cdf0e10cSrcweir else 1183*cdf0e10cSrcweir { 1184*cdf0e10cSrcweir // no, add to current layer 1185*cdf0e10cSrcweir E3dDepthNeighbour* pNewNext = new E3dDepthNeighbour; 1186*cdf0e10cSrcweir pNewNext->mpObj = pExtrudeObj; 1187*cdf0e10cSrcweir pNewNext->maPreparedPolyPolygon = aExtrudePoly; 1188*cdf0e10cSrcweir pNewNext->mpNext = pLayer->mpNext; 1189*cdf0e10cSrcweir pLayer->mpNext = pNewNext; 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir else 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir // first layer ever 1195*cdf0e10cSrcweir pBaseLayer = new E3dDepthLayer; 1196*cdf0e10cSrcweir pLayer = pBaseLayer; 1197*cdf0e10cSrcweir nNumLayers++; 1198*cdf0e10cSrcweir pLayer->mpNext = new E3dDepthNeighbour; 1199*cdf0e10cSrcweir pLayer->mpNext->mpObj = pExtrudeObj; 1200*cdf0e10cSrcweir pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly; 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir } 1203*cdf0e10cSrcweir } 1204*cdf0e10cSrcweir 1205*cdf0e10cSrcweir // number of layers is done 1206*cdf0e10cSrcweir if(nNumLayers > 1) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir // need to be arranged 1209*cdf0e10cSrcweir double fMinDepth = fDepth * 0.8; 1210*cdf0e10cSrcweir double fStep = (fDepth - fMinDepth) / (double)nNumLayers; 1211*cdf0e10cSrcweir pLayer = pBaseLayer; 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir while(pLayer) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir // move along layer 1216*cdf0e10cSrcweir E3dDepthNeighbour* pAct = pLayer->mpNext; 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir while(pAct) 1219*cdf0e10cSrcweir { 1220*cdf0e10cSrcweir // adapt extrude value 1221*cdf0e10cSrcweir pAct->mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5))); 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir // next 1224*cdf0e10cSrcweir pAct = pAct->mpNext; 1225*cdf0e10cSrcweir } 1226*cdf0e10cSrcweir 1227*cdf0e10cSrcweir // next layer 1228*cdf0e10cSrcweir pLayer = pLayer->mpDown; 1229*cdf0e10cSrcweir fMinDepth += fStep; 1230*cdf0e10cSrcweir } 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir // cleanup 1234*cdf0e10cSrcweir while(pBaseLayer) 1235*cdf0e10cSrcweir { 1236*cdf0e10cSrcweir pLayer = pBaseLayer->mpDown; 1237*cdf0e10cSrcweir delete pBaseLayer; 1238*cdf0e10cSrcweir pBaseLayer = pLayer; 1239*cdf0e10cSrcweir } 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir /************************************************************************* 1244*cdf0e10cSrcweir |* 1245*cdf0e10cSrcweir |* Drag beginnen, vorher ggf. Drag-Methode fuer 3D-Objekte erzeugen 1246*cdf0e10cSrcweir |* 1247*cdf0e10cSrcweir \************************************************************************/ 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir sal_Bool E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut, 1250*cdf0e10cSrcweir SdrHdl* pHdl, short nMinMov, 1251*cdf0e10cSrcweir SdrDragMethod* pForcedMeth) 1252*cdf0e10cSrcweir { 1253*cdf0e10cSrcweir if(Is3DRotationCreationActive() && GetMarkedObjectCount()) 1254*cdf0e10cSrcweir { 1255*cdf0e10cSrcweir // bestimme alle selektierten Polygone und gebe die gespiegelte Hilfsfigur aus 1256*cdf0e10cSrcweir mpMirrorOverlay->SetMirrorAxis(aRef1, aRef2); 1257*cdf0e10cSrcweir } 1258*cdf0e10cSrcweir else 1259*cdf0e10cSrcweir { 1260*cdf0e10cSrcweir sal_Bool bOwnActionNecessary; 1261*cdf0e10cSrcweir if (pHdl == NULL) 1262*cdf0e10cSrcweir { 1263*cdf0e10cSrcweir bOwnActionNecessary = sal_True; 1264*cdf0e10cSrcweir } 1265*cdf0e10cSrcweir else if (pHdl->IsVertexHdl() || pHdl->IsCornerHdl()) 1266*cdf0e10cSrcweir { 1267*cdf0e10cSrcweir bOwnActionNecessary = sal_True; 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir else 1270*cdf0e10cSrcweir { 1271*cdf0e10cSrcweir bOwnActionNecessary = sal_False; 1272*cdf0e10cSrcweir } 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir if(bOwnActionNecessary && GetMarkedObjectCount() >= 1) 1275*cdf0e10cSrcweir { 1276*cdf0e10cSrcweir E3dDragConstraint eConstraint = E3DDRAG_CONSTR_XYZ; 1277*cdf0e10cSrcweir sal_Bool bThereAreRootScenes = sal_False; 1278*cdf0e10cSrcweir sal_Bool bThereAre3DObjects = sal_False; 1279*cdf0e10cSrcweir long nCnt = GetMarkedObjectCount(); 1280*cdf0e10cSrcweir for(long nObjs = 0;nObjs < nCnt;nObjs++) 1281*cdf0e10cSrcweir { 1282*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 1283*cdf0e10cSrcweir if(pObj) 1284*cdf0e10cSrcweir { 1285*cdf0e10cSrcweir if(pObj->ISA(E3dScene) && ((E3dScene*)pObj)->GetScene() == pObj) 1286*cdf0e10cSrcweir bThereAreRootScenes = sal_True; 1287*cdf0e10cSrcweir if(pObj->ISA(E3dObject)) 1288*cdf0e10cSrcweir bThereAre3DObjects = sal_True; 1289*cdf0e10cSrcweir } 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir if( bThereAre3DObjects ) 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir eDragHdl = ( pHdl == NULL ? HDL_MOVE : pHdl->GetKind() ); 1294*cdf0e10cSrcweir switch ( eDragMode ) 1295*cdf0e10cSrcweir { 1296*cdf0e10cSrcweir case SDRDRAG_ROTATE: 1297*cdf0e10cSrcweir case SDRDRAG_SHEAR: 1298*cdf0e10cSrcweir { 1299*cdf0e10cSrcweir switch ( eDragHdl ) 1300*cdf0e10cSrcweir { 1301*cdf0e10cSrcweir case HDL_LEFT: 1302*cdf0e10cSrcweir case HDL_RIGHT: 1303*cdf0e10cSrcweir { 1304*cdf0e10cSrcweir eConstraint = E3DDRAG_CONSTR_X; 1305*cdf0e10cSrcweir } 1306*cdf0e10cSrcweir break; 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir case HDL_UPPER: 1309*cdf0e10cSrcweir case HDL_LOWER: 1310*cdf0e10cSrcweir { 1311*cdf0e10cSrcweir eConstraint = E3DDRAG_CONSTR_Y; 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir break; 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir case HDL_UPLFT: 1316*cdf0e10cSrcweir case HDL_UPRGT: 1317*cdf0e10cSrcweir case HDL_LWLFT: 1318*cdf0e10cSrcweir case HDL_LWRGT: 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir eConstraint = E3DDRAG_CONSTR_Z; 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir break; 1323*cdf0e10cSrcweir default: break; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir // die nicht erlaubten Rotationen ausmaskieren 1327*cdf0e10cSrcweir eConstraint = E3dDragConstraint(eConstraint& eDragConstraint); 1328*cdf0e10cSrcweir pForcedMeth = new E3dDragRotate(*this, GetMarkedObjectList(), eConstraint, IsSolidDragging()); 1329*cdf0e10cSrcweir } 1330*cdf0e10cSrcweir break; 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir case SDRDRAG_MOVE: 1333*cdf0e10cSrcweir { 1334*cdf0e10cSrcweir if(!bThereAreRootScenes) 1335*cdf0e10cSrcweir { 1336*cdf0e10cSrcweir pForcedMeth = new E3dDragMove(*this, GetMarkedObjectList(), eDragHdl, eConstraint, IsSolidDragging()); 1337*cdf0e10cSrcweir } 1338*cdf0e10cSrcweir } 1339*cdf0e10cSrcweir break; 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir // spaeter mal 1342*cdf0e10cSrcweir case SDRDRAG_MIRROR: 1343*cdf0e10cSrcweir case SDRDRAG_CROOK: 1344*cdf0e10cSrcweir case SDRDRAG_DISTORT: 1345*cdf0e10cSrcweir case SDRDRAG_TRANSPARENCE: 1346*cdf0e10cSrcweir case SDRDRAG_GRADIENT: 1347*cdf0e10cSrcweir default: 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir } 1350*cdf0e10cSrcweir break; 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir } 1353*cdf0e10cSrcweir } 1354*cdf0e10cSrcweir } 1355*cdf0e10cSrcweir return SdrView::BegDragObj(rPnt, pOut, pHdl, nMinMov, pForcedMeth); 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir /************************************************************************* 1359*cdf0e10cSrcweir |* 1360*cdf0e10cSrcweir |* Pruefen, obj 3D-Szene markiert ist 1361*cdf0e10cSrcweir |* 1362*cdf0e10cSrcweir \************************************************************************/ 1363*cdf0e10cSrcweir 1364*cdf0e10cSrcweir sal_Bool E3dView::HasMarkedScene() 1365*cdf0e10cSrcweir { 1366*cdf0e10cSrcweir return (GetMarkedScene() != NULL); 1367*cdf0e10cSrcweir } 1368*cdf0e10cSrcweir 1369*cdf0e10cSrcweir /************************************************************************* 1370*cdf0e10cSrcweir |* 1371*cdf0e10cSrcweir |* Pruefen, obj 3D-Szene markiert ist 1372*cdf0e10cSrcweir |* 1373*cdf0e10cSrcweir \************************************************************************/ 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir E3dScene* E3dView::GetMarkedScene() 1376*cdf0e10cSrcweir { 1377*cdf0e10cSrcweir sal_uIntPtr nCnt = GetMarkedObjectCount(); 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir for ( sal_uIntPtr i = 0; i < nCnt; i++ ) 1380*cdf0e10cSrcweir if ( GetMarkedObjectByIndex(i)->ISA(E3dScene) ) 1381*cdf0e10cSrcweir return (E3dScene*) GetMarkedObjectByIndex(i); 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir return NULL; 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir 1386*cdf0e10cSrcweir /************************************************************************* 1387*cdf0e10cSrcweir |* 1388*cdf0e10cSrcweir |* aktuelles 3D-Zeichenobjekt setzen, dafuer Szene erzeugen 1389*cdf0e10cSrcweir |* 1390*cdf0e10cSrcweir \************************************************************************/ 1391*cdf0e10cSrcweir 1392*cdf0e10cSrcweir E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj) 1393*cdf0e10cSrcweir { 1394*cdf0e10cSrcweir DBG_ASSERT(p3DObj != NULL, "Nana, wer steckt denn hier 'nen NULL-Zeiger rein?"); 1395*cdf0e10cSrcweir E3dScene* pScene = NULL; 1396*cdf0e10cSrcweir 1397*cdf0e10cSrcweir // get transformed BoundVolume of the object 1398*cdf0e10cSrcweir basegfx::B3DRange aVolume(p3DObj->GetBoundVolume()); 1399*cdf0e10cSrcweir aVolume.transform(p3DObj->GetTransform()); 1400*cdf0e10cSrcweir double fW(aVolume.getWidth()); 1401*cdf0e10cSrcweir double fH(aVolume.getHeight()); 1402*cdf0e10cSrcweir 1403*cdf0e10cSrcweir Rectangle aRect(0,0, (long) fW, (long) fH); 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir pScene = new E3dPolyScene(Get3DDefaultAttributes()); 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir InitScene(pScene, fW, fH, aVolume.getMaxZ() + ((fW + fH) / 4.0)); 1408*cdf0e10cSrcweir 1409*cdf0e10cSrcweir pScene->Insert3DObj(p3DObj); 1410*cdf0e10cSrcweir pScene->NbcSetSnapRect(aRect); 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir return pScene; 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir /************************************************************************* 1416*cdf0e10cSrcweir |* 1417*cdf0e10cSrcweir |* neu erzeugte Szene initialisieren 1418*cdf0e10cSrcweir |* 1419*cdf0e10cSrcweir \************************************************************************/ 1420*cdf0e10cSrcweir 1421*cdf0e10cSrcweir void E3dView::InitScene(E3dScene* pScene, double fW, double fH, double fCamZ) 1422*cdf0e10cSrcweir { 1423*cdf0e10cSrcweir Camera3D aCam(pScene->GetCamera()); 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir aCam.SetAutoAdjustProjection(sal_False); 1426*cdf0e10cSrcweir aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); 1427*cdf0e10cSrcweir basegfx::B3DPoint aLookAt; 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir double fDefaultCamPosZ = GetDefaultCamPosZ(); 1430*cdf0e10cSrcweir basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ); 1431*cdf0e10cSrcweir 1432*cdf0e10cSrcweir aCam.SetPosAndLookAt(aCamPos, aLookAt); 1433*cdf0e10cSrcweir aCam.SetFocalLength(GetDefaultCamFocal()); 1434*cdf0e10cSrcweir aCam.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, GetDefaultCamFocal()); 1435*cdf0e10cSrcweir pScene->SetCamera(aCam); 1436*cdf0e10cSrcweir } 1437*cdf0e10cSrcweir 1438*cdf0e10cSrcweir /************************************************************************* 1439*cdf0e10cSrcweir |* 1440*cdf0e10cSrcweir |* startsequenz fuer die erstellung eines 3D-Rotationskoerpers 1441*cdf0e10cSrcweir |* 1442*cdf0e10cSrcweir \************************************************************************/ 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir void E3dView::Start3DCreation() 1445*cdf0e10cSrcweir { 1446*cdf0e10cSrcweir if (GetMarkedObjectCount()) 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir // irgendwelche Markierungen ermitteln und ausschalten 1449*cdf0e10cSrcweir //HMHBOOL bVis = IsMarkHdlShown(); 1450*cdf0e10cSrcweir 1451*cdf0e10cSrcweir //HMHif (bVis) HideMarkHdl(); 1452*cdf0e10cSrcweir 1453*cdf0e10cSrcweir // bestimme die koordinaten fuer JOEs Mirrorachse 1454*cdf0e10cSrcweir // entgegen der normalen Achse wird diese an die linke Seite des Objektes 1455*cdf0e10cSrcweir // positioniert 1456*cdf0e10cSrcweir long nOutMin = 0; 1457*cdf0e10cSrcweir long nOutMax = 0; 1458*cdf0e10cSrcweir long nMinLen = 0; 1459*cdf0e10cSrcweir long nObjDst = 0; 1460*cdf0e10cSrcweir long nOutHgt = 0; 1461*cdf0e10cSrcweir OutputDevice* pOut = GetFirstOutputDevice(); //GetWin(0); 1462*cdf0e10cSrcweir 1463*cdf0e10cSrcweir // erstmal Darstellungsgrenzen bestimmen 1464*cdf0e10cSrcweir if (pOut != NULL) 1465*cdf0e10cSrcweir { 1466*cdf0e10cSrcweir nMinLen = pOut->PixelToLogic(Size(0,50)).Height(); 1467*cdf0e10cSrcweir nObjDst = pOut->PixelToLogic(Size(0,20)).Height(); 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir long nDst = pOut->PixelToLogic(Size(0,10)).Height(); 1470*cdf0e10cSrcweir 1471*cdf0e10cSrcweir nOutMin = -pOut->GetMapMode().GetOrigin().Y(); 1472*cdf0e10cSrcweir nOutMax = pOut->GetOutputSize().Height() - 1 + nOutMin; 1473*cdf0e10cSrcweir nOutMin += nDst; 1474*cdf0e10cSrcweir nOutMax -= nDst; 1475*cdf0e10cSrcweir 1476*cdf0e10cSrcweir if (nOutMax - nOutMin < nDst) 1477*cdf0e10cSrcweir { 1478*cdf0e10cSrcweir nOutMin += nOutMax + 1; 1479*cdf0e10cSrcweir nOutMin /= 2; 1480*cdf0e10cSrcweir nOutMin -= (nDst + 1) / 2; 1481*cdf0e10cSrcweir nOutMax = nOutMin + nDst; 1482*cdf0e10cSrcweir } 1483*cdf0e10cSrcweir 1484*cdf0e10cSrcweir nOutHgt = nOutMax - nOutMin; 1485*cdf0e10cSrcweir 1486*cdf0e10cSrcweir long nTemp = nOutHgt / 4; 1487*cdf0e10cSrcweir if (nTemp > nMinLen) nMinLen = nTemp; 1488*cdf0e10cSrcweir } 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir // und dann die Markierungen oben und unten an das Objekt heften 1491*cdf0e10cSrcweir basegfx::B2DRange aR; 1492*cdf0e10cSrcweir for(sal_uInt32 nMark(0L); nMark < GetMarkedObjectCount(); nMark++) 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir SdrObject* pMark = GetMarkedObjectByIndex(nMark); 1495*cdf0e10cSrcweir basegfx::B2DPolyPolygon aXPP(pMark->TakeXorPoly()); 1496*cdf0e10cSrcweir aR.expand(basegfx::tools::getRange(aXPP)); 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir 1499*cdf0e10cSrcweir basegfx::B2DPoint aCenter(aR.getCenter()); 1500*cdf0e10cSrcweir long nMarkHgt = basegfx::fround(aR.getHeight()) - 1; 1501*cdf0e10cSrcweir long nHgt = nMarkHgt + nObjDst * 2; 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir if (nHgt < nMinLen) nHgt = nMinLen; 1504*cdf0e10cSrcweir 1505*cdf0e10cSrcweir long nY1 = basegfx::fround(aCenter.getY()) - (nHgt + 1) / 2; 1506*cdf0e10cSrcweir long nY2 = nY1 + nHgt; 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir if (pOut && (nMinLen > nOutHgt)) nMinLen = nOutHgt; 1509*cdf0e10cSrcweir if (pOut) 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir if (nY1 < nOutMin) 1512*cdf0e10cSrcweir { 1513*cdf0e10cSrcweir nY1 = nOutMin; 1514*cdf0e10cSrcweir if (nY2 < nY1 + nMinLen) nY2 = nY1 + nMinLen; 1515*cdf0e10cSrcweir } 1516*cdf0e10cSrcweir if (nY2 > nOutMax) 1517*cdf0e10cSrcweir { 1518*cdf0e10cSrcweir nY2 = nOutMax; 1519*cdf0e10cSrcweir if (nY1 > nY2 - nMinLen) nY1 = nY2 - nMinLen; 1520*cdf0e10cSrcweir } 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir aRef1.X() = basegfx::fround(aR.getMinX()); // Initial Achse um 2/100mm nach links 1524*cdf0e10cSrcweir aRef1.Y() = nY1; 1525*cdf0e10cSrcweir aRef2.X() = aRef1.X(); 1526*cdf0e10cSrcweir aRef2.Y() = nY2; 1527*cdf0e10cSrcweir 1528*cdf0e10cSrcweir // Markierungen einschalten 1529*cdf0e10cSrcweir SetMarkHandles(); 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir //HMHif (bVis) ShowMarkHdl(); 1532*cdf0e10cSrcweir if (AreObjectsMarked()) MarkListHasChanged(); 1533*cdf0e10cSrcweir 1534*cdf0e10cSrcweir // SpiegelPolygone SOFORT zeigen 1535*cdf0e10cSrcweir const SdrHdlList &aHdlList = GetHdlList(); 1536*cdf0e10cSrcweir mpMirrorOverlay = new Impl3DMirrorConstructOverlay(*this); 1537*cdf0e10cSrcweir mpMirrorOverlay->SetMirrorAxis(aHdlList.GetHdl(HDL_REF1)->GetPos(), aHdlList.GetHdl(HDL_REF2)->GetPos()); 1538*cdf0e10cSrcweir //CreateMirrorPolygons (); 1539*cdf0e10cSrcweir //ShowMirrorPolygons (aHdlList.GetHdl (HDL_REF1)->GetPos (), 1540*cdf0e10cSrcweir // aHdlList.GetHdl (HDL_REF2)->GetPos ()); 1541*cdf0e10cSrcweir } 1542*cdf0e10cSrcweir } 1543*cdf0e10cSrcweir 1544*cdf0e10cSrcweir /************************************************************************* 1545*cdf0e10cSrcweir |* 1546*cdf0e10cSrcweir |* was passiert bei einer Mausbewegung, wenn das Objekt erstellt wird ? 1547*cdf0e10cSrcweir |* 1548*cdf0e10cSrcweir \************************************************************************/ 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir void E3dView::MovAction(const Point& rPnt) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir if(Is3DRotationCreationActive()) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir SdrHdl* pHdl = GetDragHdl(); 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir if (pHdl) 1557*cdf0e10cSrcweir { 1558*cdf0e10cSrcweir SdrHdlKind eHdlKind = pHdl->GetKind(); 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir // reagiere nur bei einer spiegelachse 1561*cdf0e10cSrcweir if ((eHdlKind == HDL_REF1) || 1562*cdf0e10cSrcweir (eHdlKind == HDL_REF2) || 1563*cdf0e10cSrcweir (eHdlKind == HDL_MIRX)) 1564*cdf0e10cSrcweir { 1565*cdf0e10cSrcweir const SdrHdlList &aHdlList = GetHdlList (); 1566*cdf0e10cSrcweir 1567*cdf0e10cSrcweir // loesche das gespiegelte Polygon, spiegele das Original und zeichne es neu 1568*cdf0e10cSrcweir //ShowMirrored (); 1569*cdf0e10cSrcweir SdrView::MovAction (rPnt); 1570*cdf0e10cSrcweir mpMirrorOverlay->SetMirrorAxis( 1571*cdf0e10cSrcweir aHdlList.GetHdl (HDL_REF1)->GetPos(), 1572*cdf0e10cSrcweir aHdlList.GetHdl (HDL_REF2)->GetPos()); 1573*cdf0e10cSrcweir } 1574*cdf0e10cSrcweir } 1575*cdf0e10cSrcweir else 1576*cdf0e10cSrcweir { 1577*cdf0e10cSrcweir SdrView::MovAction (rPnt); 1578*cdf0e10cSrcweir } 1579*cdf0e10cSrcweir } 1580*cdf0e10cSrcweir else 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir SdrView::MovAction (rPnt); 1583*cdf0e10cSrcweir } 1584*cdf0e10cSrcweir } 1585*cdf0e10cSrcweir 1586*cdf0e10cSrcweir /************************************************************************* 1587*cdf0e10cSrcweir |* 1588*cdf0e10cSrcweir |* Schluss. Objekt und evtl. Unterobjekte ueber ImpCreate3DLathe erstellen 1589*cdf0e10cSrcweir |* [FG] Mit dem Parameterwert sal_True (SDefault: sal_False) wird einfach ein 1590*cdf0e10cSrcweir |* Rotationskoerper erzeugt, ohne den Benutzer die Lage der 1591*cdf0e10cSrcweir |* Achse fetlegen zu lassen. Es reicht dieser Aufruf, falls 1592*cdf0e10cSrcweir |* ein Objekt selektiert ist. (keine Initialisierung noetig) 1593*cdf0e10cSrcweir |* 1594*cdf0e10cSrcweir \************************************************************************/ 1595*cdf0e10cSrcweir 1596*cdf0e10cSrcweir void E3dView::End3DCreation(sal_Bool bUseDefaultValuesForMirrorAxes) 1597*cdf0e10cSrcweir { 1598*cdf0e10cSrcweir ResetCreationActive(); 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir if(AreObjectsMarked()) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir if(bUseDefaultValuesForMirrorAxes) 1603*cdf0e10cSrcweir { 1604*cdf0e10cSrcweir Rectangle aRect = GetAllMarkedRect(); 1605*cdf0e10cSrcweir if(aRect.GetWidth() <= 1) 1606*cdf0e10cSrcweir aRect.SetSize(Size(500, aRect.GetHeight())); 1607*cdf0e10cSrcweir if(aRect.GetHeight() <= 1) 1608*cdf0e10cSrcweir aRect.SetSize(Size(aRect.GetWidth(), 500)); 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir basegfx::B2DPoint aPnt1(aRect.Left(), -aRect.Top()); 1611*cdf0e10cSrcweir basegfx::B2DPoint aPnt2(aRect.Left(), -aRect.Bottom()); 1612*cdf0e10cSrcweir 1613*cdf0e10cSrcweir ConvertMarkedObjTo3D(sal_False, aPnt1, aPnt2); 1614*cdf0e10cSrcweir } 1615*cdf0e10cSrcweir else 1616*cdf0e10cSrcweir { 1617*cdf0e10cSrcweir // Hilfsfigur ausschalten 1618*cdf0e10cSrcweir // bestimme aus den Handlepositionen und den Versatz der Punkte 1619*cdf0e10cSrcweir const SdrHdlList &aHdlList = GetHdlList(); 1620*cdf0e10cSrcweir Point aMirrorRef1 = aHdlList.GetHdl(HDL_REF1)->GetPos(); 1621*cdf0e10cSrcweir Point aMirrorRef2 = aHdlList.GetHdl(HDL_REF2)->GetPos(); 1622*cdf0e10cSrcweir 1623*cdf0e10cSrcweir basegfx::B2DPoint aPnt1(aMirrorRef1.X(), -aMirrorRef1.Y()); 1624*cdf0e10cSrcweir basegfx::B2DPoint aPnt2(aMirrorRef2.X(), -aMirrorRef2.Y()); 1625*cdf0e10cSrcweir 1626*cdf0e10cSrcweir ConvertMarkedObjTo3D(sal_False, aPnt1, aPnt2); 1627*cdf0e10cSrcweir } 1628*cdf0e10cSrcweir } 1629*cdf0e10cSrcweir } 1630*cdf0e10cSrcweir 1631*cdf0e10cSrcweir /************************************************************************* 1632*cdf0e10cSrcweir |* 1633*cdf0e10cSrcweir |* Destruktor 1634*cdf0e10cSrcweir |* 1635*cdf0e10cSrcweir \************************************************************************/ 1636*cdf0e10cSrcweir 1637*cdf0e10cSrcweir E3dView::~E3dView () 1638*cdf0e10cSrcweir { 1639*cdf0e10cSrcweir } 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir /************************************************************************* 1642*cdf0e10cSrcweir |* 1643*cdf0e10cSrcweir |* beende das erzeugen und loesche die polygone 1644*cdf0e10cSrcweir |* 1645*cdf0e10cSrcweir \************************************************************************/ 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir void E3dView::ResetCreationActive () 1648*cdf0e10cSrcweir { 1649*cdf0e10cSrcweir if(mpMirrorOverlay) 1650*cdf0e10cSrcweir { 1651*cdf0e10cSrcweir delete mpMirrorOverlay; 1652*cdf0e10cSrcweir mpMirrorOverlay = 0L; 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir } 1655*cdf0e10cSrcweir 1656*cdf0e10cSrcweir /************************************************************************* 1657*cdf0e10cSrcweir |* 1658*cdf0e10cSrcweir |* Klasse initialisieren 1659*cdf0e10cSrcweir |* 1660*cdf0e10cSrcweir \************************************************************************/ 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir void E3dView::InitView () 1663*cdf0e10cSrcweir { 1664*cdf0e10cSrcweir eDragConstraint = E3DDRAG_CONSTR_XYZ; 1665*cdf0e10cSrcweir fDefaultScaleX = 1666*cdf0e10cSrcweir fDefaultScaleY = 1667*cdf0e10cSrcweir fDefaultScaleZ = 1.0; 1668*cdf0e10cSrcweir fDefaultRotateX = 1669*cdf0e10cSrcweir fDefaultRotateY = 1670*cdf0e10cSrcweir fDefaultRotateZ = 0.0; 1671*cdf0e10cSrcweir fDefaultExtrusionDeepth = 1000; // old: 2000; 1672*cdf0e10cSrcweir fDefaultLightIntensity = 0.8; // old: 0.6; 1673*cdf0e10cSrcweir fDefaultAmbientIntensity = 0.4; 1674*cdf0e10cSrcweir nHDefaultSegments = 12; 1675*cdf0e10cSrcweir nVDefaultSegments = 12; 1676*cdf0e10cSrcweir aDefaultLightColor = RGB_Color(COL_WHITE); 1677*cdf0e10cSrcweir aDefaultAmbientColor = RGB_Color(COL_BLACK); 1678*cdf0e10cSrcweir bDoubleSided = sal_False; 1679*cdf0e10cSrcweir mpMirrorOverlay = 0L; 1680*cdf0e10cSrcweir } 1681*cdf0e10cSrcweir 1682*cdf0e10cSrcweir /************************************************************************* 1683*cdf0e10cSrcweir |* 1684*cdf0e10cSrcweir |* Koennen die selektierten Objekte aufgebrochen werden? 1685*cdf0e10cSrcweir |* 1686*cdf0e10cSrcweir \************************************************************************/ 1687*cdf0e10cSrcweir 1688*cdf0e10cSrcweir sal_Bool E3dView::IsBreak3DObjPossible() const 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir sal_uIntPtr nCount = GetMarkedObjectCount(); 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir if (nCount > 0) 1693*cdf0e10cSrcweir { 1694*cdf0e10cSrcweir sal_uIntPtr i = 0; 1695*cdf0e10cSrcweir 1696*cdf0e10cSrcweir while (i < nCount) 1697*cdf0e10cSrcweir { 1698*cdf0e10cSrcweir SdrObject* pObj = GetMarkedObjectByIndex(i); 1699*cdf0e10cSrcweir 1700*cdf0e10cSrcweir if (pObj && pObj->ISA(E3dObject)) 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir if(!(((E3dObject*)pObj)->IsBreakObjPossible())) 1703*cdf0e10cSrcweir return sal_False; 1704*cdf0e10cSrcweir } 1705*cdf0e10cSrcweir else 1706*cdf0e10cSrcweir { 1707*cdf0e10cSrcweir return sal_False; 1708*cdf0e10cSrcweir } 1709*cdf0e10cSrcweir 1710*cdf0e10cSrcweir i++; 1711*cdf0e10cSrcweir } 1712*cdf0e10cSrcweir } 1713*cdf0e10cSrcweir else 1714*cdf0e10cSrcweir { 1715*cdf0e10cSrcweir return sal_False; 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir return sal_True; 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir 1721*cdf0e10cSrcweir /************************************************************************* 1722*cdf0e10cSrcweir |* 1723*cdf0e10cSrcweir |* Selektierte Lathe-Objekte aufbrechen 1724*cdf0e10cSrcweir |* 1725*cdf0e10cSrcweir \************************************************************************/ 1726*cdf0e10cSrcweir 1727*cdf0e10cSrcweir void E3dView::Break3DObj() 1728*cdf0e10cSrcweir { 1729*cdf0e10cSrcweir if(IsBreak3DObjPossible()) 1730*cdf0e10cSrcweir { 1731*cdf0e10cSrcweir // ALLE selektierten Objekte werden gewandelt 1732*cdf0e10cSrcweir sal_uInt32 nCount = GetMarkedObjectCount(); 1733*cdf0e10cSrcweir 1734*cdf0e10cSrcweir BegUndo(String(SVX_RESSTR(RID_SVX_3D_UNDO_BREAK_LATHE))); 1735*cdf0e10cSrcweir for(sal_uInt32 a=0;a<nCount;a++) 1736*cdf0e10cSrcweir { 1737*cdf0e10cSrcweir E3dObject* pObj = (E3dObject*)GetMarkedObjectByIndex(a); 1738*cdf0e10cSrcweir BreakSingle3DObj(pObj); 1739*cdf0e10cSrcweir } 1740*cdf0e10cSrcweir DeleteMarked(); 1741*cdf0e10cSrcweir EndUndo(); 1742*cdf0e10cSrcweir } 1743*cdf0e10cSrcweir } 1744*cdf0e10cSrcweir 1745*cdf0e10cSrcweir void E3dView::BreakSingle3DObj(E3dObject* pObj) 1746*cdf0e10cSrcweir { 1747*cdf0e10cSrcweir if(pObj->ISA(E3dScene)) 1748*cdf0e10cSrcweir { 1749*cdf0e10cSrcweir SdrObjList* pSubList = pObj->GetSubList(); 1750*cdf0e10cSrcweir SdrObjListIter aIter(*pSubList, IM_FLAT); 1751*cdf0e10cSrcweir 1752*cdf0e10cSrcweir while(aIter.IsMore()) 1753*cdf0e10cSrcweir { 1754*cdf0e10cSrcweir E3dObject* pSubObj = (E3dObject*)aIter.Next(); 1755*cdf0e10cSrcweir BreakSingle3DObj(pSubObj); 1756*cdf0e10cSrcweir } 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir else 1759*cdf0e10cSrcweir { 1760*cdf0e10cSrcweir SdrAttrObj* pNewObj = pObj->GetBreakObj(); 1761*cdf0e10cSrcweir if(pNewObj) 1762*cdf0e10cSrcweir { 1763*cdf0e10cSrcweir InsertObjectAtView(pNewObj, *GetSdrPageView(), SDRINSERT_DONTMARK); 1764*cdf0e10cSrcweir pNewObj->SetChanged(); 1765*cdf0e10cSrcweir pNewObj->BroadcastObjectChange(); 1766*cdf0e10cSrcweir } 1767*cdf0e10cSrcweir } 1768*cdf0e10cSrcweir } 1769*cdf0e10cSrcweir 1770*cdf0e10cSrcweir /************************************************************************* 1771*cdf0e10cSrcweir |* 1772*cdf0e10cSrcweir |* Szenen mischen 1773*cdf0e10cSrcweir |* 1774*cdf0e10cSrcweir \************************************************************************/ 1775*cdf0e10cSrcweir 1776*cdf0e10cSrcweir void E3dView::MergeScenes () 1777*cdf0e10cSrcweir { 1778*cdf0e10cSrcweir sal_uIntPtr nCount = GetMarkedObjectCount(); 1779*cdf0e10cSrcweir 1780*cdf0e10cSrcweir if (nCount > 0) 1781*cdf0e10cSrcweir { 1782*cdf0e10cSrcweir sal_uIntPtr nObj = 0; 1783*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObj); 1784*cdf0e10cSrcweir E3dScene *pScene = new E3dPolyScene(Get3DDefaultAttributes()); 1785*cdf0e10cSrcweir basegfx::B3DRange aBoundVol; 1786*cdf0e10cSrcweir Rectangle aAllBoundRect (GetMarkedObjBoundRect ()); 1787*cdf0e10cSrcweir Point aCenter (aAllBoundRect.Center()); 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir while (pObj) 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir if (pObj->ISA(E3dScene)) 1792*cdf0e10cSrcweir { 1793*cdf0e10cSrcweir /********************************************************** 1794*cdf0e10cSrcweir * Es ist eine 3D-Scene oder 3D-PolyScene 1795*cdf0e10cSrcweir **********************************************************/ 1796*cdf0e10cSrcweir SdrObjList* pSubList = ((E3dObject*) pObj)->GetSubList(); 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir SdrObjListIter aIter(*pSubList, IM_FLAT); 1799*cdf0e10cSrcweir 1800*cdf0e10cSrcweir while (aIter.IsMore()) 1801*cdf0e10cSrcweir { 1802*cdf0e10cSrcweir /****************************************************** 1803*cdf0e10cSrcweir * LatheObjekte suchen 1804*cdf0e10cSrcweir ******************************************************/ 1805*cdf0e10cSrcweir SdrObject* pSubObj = aIter.Next(); 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir E3dObject *pNewObj = 0; 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir switch (pSubObj->GetObjIdentifier()) 1810*cdf0e10cSrcweir { 1811*cdf0e10cSrcweir case E3D_CUBEOBJ_ID : 1812*cdf0e10cSrcweir pNewObj = new E3dCubeObj; 1813*cdf0e10cSrcweir *(E3dCubeObj*)pNewObj = *(E3dCubeObj*)pSubObj; 1814*cdf0e10cSrcweir break; 1815*cdf0e10cSrcweir 1816*cdf0e10cSrcweir case E3D_SPHEREOBJ_ID: 1817*cdf0e10cSrcweir pNewObj = new E3dSphereObj; 1818*cdf0e10cSrcweir *(E3dSphereObj*)pNewObj = *(E3dSphereObj*)pSubObj; 1819*cdf0e10cSrcweir break; 1820*cdf0e10cSrcweir 1821*cdf0e10cSrcweir case E3D_EXTRUDEOBJ_ID: 1822*cdf0e10cSrcweir pNewObj = new E3dExtrudeObj; 1823*cdf0e10cSrcweir *(E3dExtrudeObj*)pNewObj = *(E3dExtrudeObj*)pSubObj; 1824*cdf0e10cSrcweir break; 1825*cdf0e10cSrcweir 1826*cdf0e10cSrcweir case E3D_LATHEOBJ_ID: 1827*cdf0e10cSrcweir pNewObj = new E3dLatheObj; 1828*cdf0e10cSrcweir *(E3dLatheObj*)pNewObj = *(E3dLatheObj*)pSubObj; 1829*cdf0e10cSrcweir break; 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir case E3D_COMPOUNDOBJ_ID: 1832*cdf0e10cSrcweir pNewObj = new E3dCompoundObject; 1833*cdf0e10cSrcweir *(E3dCompoundObject*)pNewObj = *(E3dCompoundObject*)pSubObj; 1834*cdf0e10cSrcweir break; 1835*cdf0e10cSrcweir } 1836*cdf0e10cSrcweir 1837*cdf0e10cSrcweir Rectangle aBoundRect = pSubObj->GetCurrentBoundRect(); 1838*cdf0e10cSrcweir 1839*cdf0e10cSrcweir basegfx::B3DHomMatrix aMatrix; 1840*cdf0e10cSrcweir aMatrix.translate(aBoundRect.Left() - aCenter.getX(), aCenter.getY(), 0.0); 1841*cdf0e10cSrcweir pNewObj->SetTransform(aMatrix * pNewObj->GetTransform()); // #112587# 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir if (pNewObj) aBoundVol.expand(pNewObj->GetBoundVolume()); 1844*cdf0e10cSrcweir pScene->Insert3DObj (pNewObj); 1845*cdf0e10cSrcweir } 1846*cdf0e10cSrcweir } 1847*cdf0e10cSrcweir 1848*cdf0e10cSrcweir nObj++; 1849*cdf0e10cSrcweir 1850*cdf0e10cSrcweir if (nObj < nCount) 1851*cdf0e10cSrcweir { 1852*cdf0e10cSrcweir pObj = GetMarkedObjectByIndex(nObj); 1853*cdf0e10cSrcweir } 1854*cdf0e10cSrcweir else 1855*cdf0e10cSrcweir { 1856*cdf0e10cSrcweir pObj = NULL; 1857*cdf0e10cSrcweir } 1858*cdf0e10cSrcweir } 1859*cdf0e10cSrcweir 1860*cdf0e10cSrcweir double fW = aAllBoundRect.GetWidth(); 1861*cdf0e10cSrcweir double fH = aAllBoundRect.GetHeight(); 1862*cdf0e10cSrcweir Rectangle aRect(0,0, (long) fW, (long) fH); 1863*cdf0e10cSrcweir 1864*cdf0e10cSrcweir InitScene(pScene, fW, fH, aBoundVol.getMaxZ() + + ((fW + fH) / 4.0)); 1865*cdf0e10cSrcweir pScene->NbcSetSnapRect(aRect); 1866*cdf0e10cSrcweir 1867*cdf0e10cSrcweir Camera3D &aCamera = (Camera3D&) pScene->GetCamera (); 1868*cdf0e10cSrcweir basegfx::B3DPoint aMinVec(aBoundVol.getMinimum()); 1869*cdf0e10cSrcweir basegfx::B3DPoint aMaxVec(aBoundVol.getMaximum()); 1870*cdf0e10cSrcweir double fDeepth(fabs(aMaxVec.getZ() - aMinVec.getZ())); 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir aCamera.SetPRP(basegfx::B3DPoint(0.0, 0.0, 1000.0)); 1873*cdf0e10cSrcweir double fDefaultCamPosZ(GetDefaultCamPosZ()); 1874*cdf0e10cSrcweir aCamera.SetPosition(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ + fDeepth / 2.0)); 1875*cdf0e10cSrcweir aCamera.SetFocalLength(GetDefaultCamFocal()); 1876*cdf0e10cSrcweir pScene->SetCamera (aCamera); 1877*cdf0e10cSrcweir 1878*cdf0e10cSrcweir // SnapRects der Objekte ungueltig 1879*cdf0e10cSrcweir pScene->SetRectsDirty(); 1880*cdf0e10cSrcweir 1881*cdf0e10cSrcweir InsertObjectAtView(pScene, *(GetSdrPageViewOfMarkedByIndex(0))); 1882*cdf0e10cSrcweir 1883*cdf0e10cSrcweir // SnapRects der Objekte ungueltig 1884*cdf0e10cSrcweir pScene->SetRectsDirty(); 1885*cdf0e10cSrcweir } 1886*cdf0e10cSrcweir } 1887*cdf0e10cSrcweir 1888*cdf0e10cSrcweir /************************************************************************* 1889*cdf0e10cSrcweir |* 1890*cdf0e10cSrcweir |* Possibilities, hauptsaechlich gruppieren/ungruppieren 1891*cdf0e10cSrcweir |* 1892*cdf0e10cSrcweir \************************************************************************/ 1893*cdf0e10cSrcweir void E3dView::CheckPossibilities() 1894*cdf0e10cSrcweir { 1895*cdf0e10cSrcweir // call parent 1896*cdf0e10cSrcweir SdrView::CheckPossibilities(); 1897*cdf0e10cSrcweir 1898*cdf0e10cSrcweir // Weitere Flags bewerten 1899*cdf0e10cSrcweir if(bGroupPossible || bUnGroupPossible || bGrpEnterPossible) 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir sal_Int32 nMarkCnt = GetMarkedObjectCount(); 1902*cdf0e10cSrcweir sal_Bool bCoumpound = sal_False; 1903*cdf0e10cSrcweir sal_Bool b3DObject = sal_False; 1904*cdf0e10cSrcweir for(sal_Int32 nObjs = 0L; (nObjs < nMarkCnt) && !bCoumpound; nObjs++) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir SdrObject *pObj = GetMarkedObjectByIndex(nObjs); 1907*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dCompoundObject)) 1908*cdf0e10cSrcweir bCoumpound = sal_True; 1909*cdf0e10cSrcweir if(pObj && pObj->ISA(E3dObject)) 1910*cdf0e10cSrcweir b3DObject = sal_True; 1911*cdf0e10cSrcweir } 1912*cdf0e10cSrcweir 1913*cdf0e10cSrcweir // Bisher: Es sind ZWEI oder mehr beliebiger Objekte selektiert. 1914*cdf0e10cSrcweir // Nachsehen, ob CompoundObjects beteiligt sind. Falls ja, 1915*cdf0e10cSrcweir // das Gruppieren verbieten. 1916*cdf0e10cSrcweir if(bGroupPossible && bCoumpound) 1917*cdf0e10cSrcweir bGroupPossible = sal_False; 1918*cdf0e10cSrcweir 1919*cdf0e10cSrcweir if(bUnGroupPossible && b3DObject) 1920*cdf0e10cSrcweir bUnGroupPossible = sal_False; 1921*cdf0e10cSrcweir 1922*cdf0e10cSrcweir if(bGrpEnterPossible && bCoumpound) 1923*cdf0e10cSrcweir bGrpEnterPossible = sal_False; 1924*cdf0e10cSrcweir } 1925*cdf0e10cSrcweir } 1926*cdf0e10cSrcweir 1927*cdf0e10cSrcweir // eof 1928