Files
libreoffice/svx/source/engine3d/scene3d.cxx

748 lines
21 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
#include "svx/svdstr.hrc"
#include "svx/svdglob.hxx"
#include "svx/svditer.hxx"
2000-09-18 16:07:07 +00:00
#if defined( UNX ) || defined( ICC )
#include <stdlib.h>
#endif
#include "svx/globl3d.hxx"
#include <svx/svdpage.hxx>
#include <svl/style.hxx>
#include <svx/scene3d.hxx>
#include <svx/e3dundo.hxx>
#include <svx/svdtrans.hxx>
#include <svx/svxids.hrc>
#include <editeng/colritem.hxx>
#include <svx/e3ditem.hxx>
#include <svx/xlntrit.hxx>
#include <svx/xfltrit.hxx>
#include <svx/svx3ditems.hxx>
#include <svl/whiter.hxx>
#include <svx/xflftrit.hxx>
#include <svx/sdr/properties/e3dsceneproperties.hxx>
#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
#include <svx/svddrag.hxx>
2008-10-17 08:40:10 +00:00
#include <helperminimaldepth3d.hxx>
#include <algorithm>
2008-10-17 08:40:10 +00:00
#include <drawinglayer/geometry/viewinformation3d.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <svx/e3dsceneupdater.hxx>
2000-09-18 16:07:07 +00:00
#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
//////////////////////////////////////////////////////////////////////////////
class ImpRemap3DDepth
{
sal_uInt32 mnOrdNum;
double mfMinimalDepth;
2011-04-07 15:47:21 +03:00
// bit field
unsigned mbIsScene : 1;
public:
ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth);
ImpRemap3DDepth(sal_uInt32 nOrdNum);
~ImpRemap3DDepth();
// for ::std::sort
bool operator<(const ImpRemap3DDepth& rComp) const;
sal_uInt32 GetOrdNum() const { return mnOrdNum; }
sal_Bool IsScene() const { return mbIsScene; }
};
ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth)
: mnOrdNum(nOrdNum),
mfMinimalDepth(fMinimalDepth),
mbIsScene(sal_False)
{
}
ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum)
: mnOrdNum(nOrdNum),
2010-12-23 12:51:59 +00:00
mfMinimalDepth(0.0),
mbIsScene(sal_True)
{
}
ImpRemap3DDepth::~ImpRemap3DDepth()
{
}
bool ImpRemap3DDepth::operator<(const ImpRemap3DDepth& rComp) const
{
if(IsScene())
{
return sal_False;
}
else
{
if(rComp.IsScene())
{
return sal_True;
}
else
{
return mfMinimalDepth < rComp.mfMinimalDepth;
}
}
}
// typedefs for a vector of ImpRemap3DDepths
typedef ::std::vector< ImpRemap3DDepth > ImpRemap3DDepthVector;
//////////////////////////////////////////////////////////////////////////////
class Imp3DDepthRemapper
{
ImpRemap3DDepthVector maVector;
public:
Imp3DDepthRemapper(E3dScene& rScene);
~Imp3DDepthRemapper();
sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
};
Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene& rScene)
{
// only called when rScene.GetSubList() and nObjCount > 1L
SdrObjList* pList = rScene.GetSubList();
const sal_uInt32 nObjCount(pList->GetObjCount());
for(sal_uInt32 a(0L); a < nObjCount; a++)
{
SdrObject* pCandidate = pList->GetObj(a);
if(pCandidate)
{
if(pCandidate->ISA(E3dCompoundObject))
{
// single 3d object, calc depth
2008-10-17 08:40:10 +00:00
const double fMinimalDepth(getMinimalDepthInViewCoordinates(static_cast< const E3dCompoundObject& >(*pCandidate)));
ImpRemap3DDepth aEntry(a, fMinimalDepth);
maVector.push_back(aEntry);
}
else
{
// scene, use standard entry for scene
ImpRemap3DDepth aEntry(a);
maVector.push_back(aEntry);
}
}
}
// now, we need to sort the maVector by it's members minimal depth. The
// smaller, the nearer to the viewer.
::std::sort(maVector.begin(), maVector.end());
}
Imp3DDepthRemapper::~Imp3DDepthRemapper()
{
}
sal_uInt32 Imp3DDepthRemapper::RemapOrdNum(sal_uInt32 nOrdNum) const
{
if(nOrdNum < maVector.size())
{
nOrdNum = maVector[(maVector.size() - 1) - nOrdNum].GetOrdNum();
}
return nOrdNum;
}
//////////////////////////////////////////////////////////////////////////////
// BaseProperties section
sdr::properties::BaseProperties* E3dScene::CreateObjectSpecificProperties()
{
return new sdr::properties::E3dSceneProperties(*this);
}
//////////////////////////////////////////////////////////////////////////////
2011-04-07 15:47:21 +03:00
// DrawContact section
sdr::contact::ViewContact* E3dScene::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfE3dScene(*this);
}
2011-04-07 15:47:21 +03:00
//////////////////////////////////////////////////////////////////////////////
2000-09-18 16:07:07 +00:00
TYPEINIT1(E3dScene, E3dObject);
E3dScene::E3dScene()
: E3dObject(),
aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
mp3DDepthRemapper(0L),
2008-10-17 08:40:10 +00:00
bDrawOnlySelected(false)
2000-09-18 16:07:07 +00:00
{
2011-04-07 15:47:21 +03:00
// Set defaults
2000-09-18 16:07:07 +00:00
E3dDefaultAttributes aDefault;
SetDefaultAttributes(aDefault);
}
E3dScene::E3dScene(E3dDefaultAttributes& rDefault)
: E3dObject(),
aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
mp3DDepthRemapper(0L),
2008-10-17 08:40:10 +00:00
bDrawOnlySelected(false)
2000-09-18 16:07:07 +00:00
{
2011-04-07 15:47:21 +03:00
// Set defaults
2000-09-18 16:07:07 +00:00
SetDefaultAttributes(rDefault);
}
2008-10-17 08:40:10 +00:00
void E3dScene::SetDefaultAttributes(E3dDefaultAttributes& /*rDefault*/)
2000-09-18 16:07:07 +00:00
{
2011-04-07 15:47:21 +03:00
// For WIN95/NT turn off the FP-Exceptions
#if defined(WNT)
2000-09-18 16:07:07 +00:00
#define SC_FPEXCEPTIONS_ON() _control87( _MCW_EM, 0 )
#define SC_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
SC_FPEXCEPTIONS_OFF();
#endif
2011-04-07 15:47:21 +03:00
// Set defaults
2000-09-18 16:07:07 +00:00
aCamera.SetViewWindow(-2, -2, 4, 4);
aCameraSet.SetDeviceRectangle(-2, 2, -2, 2);
aCamera.SetDeviceWindow(Rectangle(0, 0, 10, 10));
Rectangle aRect(0, 0, 10, 10);
aCameraSet.SetViewportRectangle(aRect);
// set defaults for Camera from ItemPool
aCamera.SetProjection(GetPerspective());
basegfx::B3DPoint aActualPosition(aCamera.GetPosition());
double fNew = GetDistance();
if(fabs(fNew - aActualPosition.getZ()) > 1.0)
{
aCamera.SetPosition( basegfx::B3DPoint( aActualPosition.getX(), aActualPosition.getY(), fNew) );
}
fNew = GetFocalLength() / 100.0;
aCamera.SetFocalLength(fNew);
2000-09-18 16:07:07 +00:00
}
E3dScene::~E3dScene()
{
ImpCleanup3DDepthMapper();
}
2008-10-17 08:40:10 +00:00
basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const
{
const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact());
const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
basegfx::B2DPolyPolygon aRetval(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
aViewInfo3D.getObjectToView()));
aRetval.transform(rVCScene.getObjectTransformation());
return aRetval;
}
void E3dScene::ImpCleanup3DDepthMapper()
{
if(mp3DDepthRemapper)
{
delete mp3DDepthRemapper;
mp3DDepthRemapper = 0L;
}
}
sal_uInt32 E3dScene::RemapOrdNum(sal_uInt32 nNewOrdNum) const
{
if(!mp3DDepthRemapper)
{
const sal_uInt32 nObjCount(GetSubList() ? GetSubList()->GetObjCount() : 0L);
if(nObjCount > 1L)
{
((E3dScene*)this)->mp3DDepthRemapper = new Imp3DDepthRemapper((E3dScene&)(*this));
}
}
if(mp3DDepthRemapper)
{
return mp3DDepthRemapper->RemapOrdNum(nNewOrdNum);
}
return nNewOrdNum;
2000-09-18 16:07:07 +00:00
}
sal_uInt16 E3dScene::GetObjIdentifier() const
2000-09-18 16:07:07 +00:00
{
return E3D_SCENE_ID;
}
void E3dScene::SetBoundRectDirty()
{
E3dScene* pScene = GetScene();
if(pScene == this)
{
// avoid resetting aOutRect which in case of a 3D scene used as 2d object
// is model data,not re-creatable view data
}
else
{
// if not the outmost scene it is used as group in 3d, call parent
E3dObject::SetBoundRectDirty();
}
}
2000-09-18 16:07:07 +00:00
void E3dScene::NbcSetSnapRect(const Rectangle& rRect)
{
SetRectsDirty();
E3dObject::NbcSetSnapRect(rRect);
aCamera.SetDeviceWindow(rRect);
aCameraSet.SetViewportRectangle((Rectangle&)rRect);
ImpCleanup3DDepthMapper();
2000-09-18 16:07:07 +00:00
}
void E3dScene::NbcMove(const Size& rSize)
{
Rectangle aNewSnapRect = GetSnapRect();
MoveRect(aNewSnapRect, rSize);
NbcSetSnapRect(aNewSnapRect);
}
void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact,
const Fraction& rYFact)
{
Rectangle aNewSnapRect = GetSnapRect();
ResizeRect(aNewSnapRect, rRef, rXFact, rYFact);
NbcSetSnapRect(aNewSnapRect);
}
2011-04-07 15:47:21 +03:00
// Set new camera, and thus mark the scene and if possible the bound volume
// as changed
2000-09-18 16:07:07 +00:00
void E3dScene::SetCamera(const Camera3D& rNewCamera)
{
2011-04-07 15:47:21 +03:00
// Set old camera
2000-09-18 16:07:07 +00:00
aCamera = rNewCamera;
((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
2000-09-18 16:07:07 +00:00
SetRectsDirty();
2011-04-07 15:47:21 +03:00
// Fill new camera from old
2000-09-18 16:07:07 +00:00
Camera3D& rCam = (Camera3D&)GetCamera();
2011-04-07 15:47:21 +03:00
// Turn off ratio
2000-09-18 16:07:07 +00:00
if(rCam.GetAspectMapping() == AS_NO_MAPPING)
GetCameraSet().SetRatio(0.0);
2011-04-07 15:47:21 +03:00
// Set Imaging geometry
basegfx::B3DPoint aVRP(rCam.GetViewPoint());
basegfx::B3DVector aVPN(aVRP - rCam.GetVRP());
basegfx::B3DVector aVUV(rCam.GetVUV());
2011-04-07 15:47:21 +03:00
// use SetViewportValues() to set VRP, VPN and VUV as vectors, too.
// Else these values would not be exported/imported correctly.
GetCameraSet().SetViewportValues(aVRP, aVPN, aVUV);
2000-09-18 16:07:07 +00:00
2011-04-07 15:47:21 +03:00
// Set perspective
2000-09-18 16:07:07 +00:00
GetCameraSet().SetPerspective(rCam.GetProjection() == PR_PERSPECTIVE);
GetCameraSet().SetViewportRectangle((Rectangle&)rCam.GetDeviceWindow());
ImpCleanup3DDepthMapper();
2000-09-18 16:07:07 +00:00
}
void E3dScene::NewObjectInserted(const E3dObject* p3DObj)
{
E3dObject::NewObjectInserted(p3DObj);
if ( p3DObj == this )
return;
ImpCleanup3DDepthMapper();
2000-09-18 16:07:07 +00:00
}
2011-04-07 15:47:21 +03:00
// Inform parent of changes of a child
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
void E3dScene::StructureChanged()
2000-09-18 16:07:07 +00:00
{
2008-10-17 08:40:10 +00:00
E3dObject::StructureChanged();
2000-09-18 16:07:07 +00:00
SetRectsDirty();
ImpCleanup3DDepthMapper();
2000-09-18 16:07:07 +00:00
}
2011-04-07 15:47:21 +03:00
// Determine the overall scene object
2000-09-18 16:07:07 +00:00
E3dScene* E3dScene::GetScene() const
{
if(GetParentObj())
return GetParentObj()->GetScene();
else
return (E3dScene*)this;
}
2008-10-17 08:40:10 +00:00
void E3dScene::removeAllNonSelectedObjects()
2000-09-18 16:07:07 +00:00
{
2008-10-17 08:40:10 +00:00
E3DModifySceneSnapRectUpdater aUpdater(this);
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
2000-09-18 16:07:07 +00:00
{
2008-10-17 08:40:10 +00:00
SdrObject* pObj = maSubList.GetObj(a);
2008-10-17 08:40:10 +00:00
if(pObj)
{
bool bRemoveObject(false);
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
if(pObj->ISA(E3dScene))
{
E3dScene* pScene = (E3dScene*)pObj;
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
// iterate over this sub-scene
pScene->removeAllNonSelectedObjects();
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
// check object count. Empty scenes can be deleted
const sal_uInt32 nObjCount(pScene->GetSubList() ? pScene->GetSubList()->GetObjCount() : 0);
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
if(!nObjCount)
{
// all objects removed, scene can be removed, too
bRemoveObject = true;
}
}
else if(pObj->ISA(E3dCompoundObject))
{
E3dCompoundObject* pCompound = (E3dCompoundObject*)pObj;
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
if(!pCompound->GetSelected())
{
bRemoveObject = true;
}
}
2008-10-17 08:40:10 +00:00
if(bRemoveObject)
{
maSubList.NbcRemoveObject(pObj->GetOrdNum());
a--;
SdrObject::Free(pObj);
}
}
}
2000-09-18 16:07:07 +00:00
}
E3dScene* E3dScene::Clone() const
{
return CloneHelper< E3dScene >();
}
E3dScene& E3dScene::operator=(const E3dScene& rObj)
2000-09-18 16:07:07 +00:00
{
if( this == &rObj )
return *this;
2000-09-18 16:07:07 +00:00
E3dObject::operator=(rObj);
const E3dScene& r3DObj = (const E3dScene&) rObj;
aCamera = r3DObj.aCamera;
aCameraSet = r3DObj.aCameraSet;
((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
InvalidateBoundVolume();
2000-09-18 16:07:07 +00:00
RebuildLists();
SetRectsDirty();
ImpCleanup3DDepthMapper();
CWS-TOOLING: integrate CWS aw073 2009-07-16 11:21:19 +0200 aw r274036 : corrections after resync 2009-07-15 13:34:18 +0200 aw r274009 : CWS-TOOLING: rebase CWS aw073 to trunk@273858 (milestone: DEV300:m52) 2009-07-01 20:04:27 +0200 aw r273613 : CWS-TOOLING: rebase CWS aw073 to trunk@273468 (milestone: DEV300:m51) 2009-06-24 11:51:03 +0200 aw r273324 : #i102062# added using statement for solaris compiler 2009-06-23 12:53:50 +0200 aw r273278 : #i100158# force filled polygons to closed state 2009-06-23 12:28:33 +0200 aw r273276 : #i100158#, #i102371# corrected all (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) shortcuts to support line/fill and to be not used when FillMode is not overpaint 2009-06-23 12:15:14 +0200 aw r273274 : #i100158# added PolyPolygon support for snapPointsOfHorizontalOrVerticalEdges helper 2009-06-22 17:28:33 +0200 aw r273244 : #i101508# added taking care of cell's distance-to-border values for cell text primitive creation 2009-06-22 12:59:10 +0200 aw r273218 : #i102253# applied patch from OD (see task) 2009-06-18 17:00:52 +0200 aw r273125 : #i102251# added EE_CNTRL_ONLINESPELLING switch off at DrawOutliner during GraphicExporter::GetGraphic 2009-06-18 14:35:57 +0200 aw r273120 : #i102241# added mergeToSinglePolyPolygon usage to SdrObject::ImpConvertToContourObj 2009-06-18 14:35:20 +0200 aw r273119 : #i102241# improved PolygonStrokePrimitive2D::createLocalDecomposition 2009-06-18 14:34:49 +0200 aw r273118 : #i102241# Made B2DCubicBezier::testAndSolveTrivialBezier() numerically more stable 2009-06-17 16:11:21 +0200 aw r273078 : #i102062# added compare support for OutlireParaObject's WrongList in an extra method; using in primitive comparators 2009-06-16 19:10:18 +0200 aw r273037 : #i101957# corrected: offset needs to be added before rotation and shear 2009-06-16 18:58:43 +0200 aw r273035 : #i101957# added needed offset by object width to SdrTextObj::impDecomposeStretchTextPrimitive for vertical texts 2009-06-16 18:35:55 +0200 aw r273034 : #i101941# corrected object initialisation for 3D Scenes on Clone operator 2009-06-16 16:07:30 +0200 aw r273024 : #i101811# extended renderChartPrimitive2D to create a correct embedding in a new MapMode 2009-06-12 19:38:07 +0200 aw r272940 : #i101734# added test code to experiment on demand with more complex transformations for virtual objects than only translations 2009-06-12 19:37:07 +0200 aw r272939 : #i101734# corrected SvtGraphicStroke preparation in MetaFile renderer (AFAP) 2009-06-12 16:31:55 +0200 aw r272931 : #i101648# re-enabled object creation with objecttype OBJ_NONE for SW Frame creation 2009-06-12 13:59:05 +0200 aw r272917 : #i101598# supported AAed single line paint in VCL 2009-06-12 11:34:25 +0200 aw r272907 : #i101598# adapted Graphic::GetBitmap() usage 2009-06-10 16:34:19 +0200 aw r272830 : #i101598# added VCL_DLLPUBLIC to parameter class 2009-06-10 16:30:27 +0200 aw r272829 : #i101598# extended calls to Graphic::GetBitmap/Ex where conversions to Bitmap objects is needed to user defined parameters like AntiAlisasing 2009-06-10 16:28:44 +0200 aw r272828 : #i101598# extended Graphic::GetBitmap/Ex interfaces to transport raster conversion parameters since these calls potentially need to rasterconvert a contained MetaFile 2009-06-09 16:26:40 +0200 aw r272781 : #i100945# checked in proposed patch for now 2009-06-08 18:01:42 +0200 aw r272742 : #i101239# teached BinTextObject to register at EditEngineItemPool sub-pool, not on given pool directly
2009-07-27 16:24:52 +00:00
// #i101941#
// After a Scene as model object is cloned, the used
// ViewContactOfE3dScene is created and partially used
// to calculate Bound/SnapRects, but - since quite some
// values are buffered at the VC - not really well
// initialized. It would be possible to always watch for
// preconditions of buffered data, but this would be expensive
// and would create a lot of short living data structures.
// It is currently better to flush that data, e.g. by using
// ActionChanged at the VC which will for this class
// flush that cached data and initalize it's valid reconstruction
GetViewContact().ActionChanged();
return *this;
2000-09-18 16:07:07 +00:00
}
2011-04-07 15:47:21 +03:00
// Rebuild Light- and label- object lists rebuild (after loading, allocation)
2000-09-18 16:07:07 +00:00
void E3dScene::RebuildLists()
{
2011-04-07 15:47:21 +03:00
// first delete
SdrLayerID nCurrLayerID = GetLayer();
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
SdrObjListIter a3DIterator(maSubList, IM_FLAT);
2000-09-18 16:07:07 +00:00
2011-04-07 15:47:21 +03:00
// then examine all the objects in the scene
2000-09-18 16:07:07 +00:00
while ( a3DIterator.IsMore() )
{
E3dObject* p3DObj = (E3dObject*) a3DIterator.Next();
p3DObj->NbcSetLayer(nCurrLayerID);
2000-09-18 16:07:07 +00:00
NewObjectInserted(p3DObj);
}
}
SdrObjGeoData *E3dScene::NewGeoData() const
{
return new E3DSceneGeoData;
}
void E3dScene::SaveGeoData(SdrObjGeoData& rGeo) const
{
E3dObject::SaveGeoData (rGeo);
2008-10-17 08:40:10 +00:00
((E3DSceneGeoData &) rGeo).aCamera = aCamera;
2000-09-18 16:07:07 +00:00
}
void E3dScene::RestGeoData(const SdrObjGeoData& rGeo)
{
CWS-TOOLING: integrate CWS aw061 2009-01-13 19:18:08 +0100 aw r266250 : #i96669# changed initialisation order in Embedded3DPrimitive2D::Embedded3DPrimitive2D due to TinderBox 2009-01-13 19:15:37 +0100 aw r266249 : #i96669# changed initialisation order in Embedded3DPrimitive2D::Embedded3DPrimitive2D due to TinderBox 2009-01-12 11:53:37 +0100 aw r266141 : #i97874# corrected include for TinderBox build 2009-01-08 17:48:23 +0100 aw r266029 : #i97874# extended SdrTextObj::ImpConvertAddText to copy needed attributes from original object 2009-01-08 14:59:08 +0100 aw r266015 : #i96350# added fallback to solid fill in shadow TabPage when no fill is defined to get a reasonable shadow preview 2009-01-08 12:40:49 +0100 aw r265995 : #i94832# remuved not needed E3DModifySceneSnapRectUpdater usages 2009-01-08 01:53:46 +0100 thb r265982 : #i94860# Blacklisting another ATI card/driver that causes blank screens 2009-01-08 01:46:38 +0100 thb r265981 : #i97853# Changed all gradient texture methods to use basegfx gradienttools. consolidated quite some code 2009-01-08 01:45:09 +0100 thb r265980 : #i97853# Added lerp methods, slight changes to have everything necessary contained in the ODFGradientInfo struct 2009-01-08 00:01:54 +0100 thb r265979 : #i97853# First part of the move - duplicated the stuff to basegfx 2009-01-06 16:23:09 +0100 aw r265930 : #i97197# Changed SwDrawVirtObj to work well with changed aOutRect and bBoundRectValid functionality 2009-01-06 12:41:24 +0100 aw r265909 : #i97784# corrected regression with connectors 2009-01-05 17:30:31 +0100 aw r265881 : #i97772# added missing usage of reduce factor for BitmapPrimitive creation 2009-01-05 12:24:01 +0100 aw r265863 : #i97321# added direct handling of HatchTexturePrimitive3D to not use it's decomposition for HitTest 2008-12-23 13:57:27 +0100 aw r265782 : #i96669# changed SW's FlyFrame paint fallback with primitives to use createLocalDecomposition since get2Decomposition does not have to stay virtual on the long run 2008-12-23 13:47:59 +0100 aw r265781 : #i96669# optimized impCreateTextPortionPrimitive to only create TextDecoratedPortionPrimitive2D when needed 2008-12-23 13:44:45 +0100 aw r265780 : #i96669# added B2DRange buffering to some primitive implementations where it is most necessary 2008-12-19 15:45:45 +0100 aw r265729 : #i96669# prepared TextPrimitives to work without DXarray, too. Had to rework impSplitSingleWords which gets active when a text portion has some word-wise decorations. Tested before committing 2008-12-19 15:44:16 +0100 aw r265728 : #i96669# corrected error in createPolygonFromUnitEllipseSegment which popped up when investigating 2008-12-18 17:45:58 +0100 aw r265708 : #i97149# added ActionChanged() call when visualisation object is modified 2008-12-18 15:34:42 +0100 aw r265695 : #i96598# corrected SdrPageObj's usage of aOutRect 2008-12-17 16:59:37 +0100 aw r265647 : #i96537# exchanged the marker for point number in string with correct one 2008-12-16 17:50:33 +0100 aw r265566 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:50:17 +0100 aw r265565 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:50:00 +0100 aw r265564 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:49:48 +0100 aw r265563 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:49:35 +0100 aw r265562 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer
2009-01-20 09:49:16 +00:00
// #i94832# removed E3DModifySceneSnapRectUpdater here.
// It should not be needed, is already part of E3dObject::RestGeoData
2000-09-18 16:07:07 +00:00
E3dObject::RestGeoData (rGeo);
SetCamera (((E3DSceneGeoData &) rGeo).aCamera);
}
2011-04-07 15:47:21 +03:00
// Something was changed in the style sheet, so change scene
2000-09-18 16:07:07 +00:00
void E3dScene::Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
2000-09-18 16:07:07 +00:00
{
SetRectsDirty();
E3dObject::Notify(rBC, rHint);
2000-09-18 16:07:07 +00:00
}
void E3dScene::RotateScene (const Point& rRef, long /*nWink*/, double sn, double cs)
2000-09-18 16:07:07 +00:00
{
Point UpperLeft, LowerRight, Center, NewCenter;
UpperLeft = aOutRect.TopLeft();
LowerRight = aOutRect.BottomRight();
long dxOutRectHalf = labs(UpperLeft.X() - LowerRight.X());
dxOutRectHalf /= 2;
long dyOutRectHalf = labs(UpperLeft.Y() - LowerRight.Y());
dyOutRectHalf /= 2;
Rectangle RectQuelle(aOutRect), RectZiel(aOutRect);
2011-04-07 15:47:21 +03:00
// Only the center is moved. The corners are moved by NbcMove. For the
// rotation a cartesian coordinate system is used in which the pivot
// point is the origin, and the y-axis increases upward, the X-axis to
// the right. This must be especially noted for the Y-values.
// (When considering a flat piece of paper the Y-axis pointing downwards
2000-09-18 16:07:07 +00:00
Center.X() = (UpperLeft.X() + dxOutRectHalf) - rRef.X();
Center.Y() = -((UpperLeft.Y() + dyOutRectHalf) - rRef.Y());
2011-04-07 15:47:21 +03:00
// A few special cases has to be dealt with first (n * 90 degrees n integer)
if (sn==1.0 && cs==0.0) { // 90deg
2000-09-18 16:07:07 +00:00
NewCenter.X() = -Center.Y();
NewCenter.Y() = -Center.X();
} else if (sn==0.0 && cs==-1.0) { // 180deg
2000-09-18 16:07:07 +00:00
NewCenter.X() = -Center.X();
NewCenter.Y() = -Center.Y();
} else if (sn==-1.0 && cs==0.0) { // 270deg
2000-09-18 16:07:07 +00:00
NewCenter.X() = Center.Y();
NewCenter.Y() = -Center.X();
}
2011-04-07 15:47:21 +03:00
else // Here it is rotated to any angle in the mathematically
// positive direction!
{ // xnew = x * cos(alpha) - y * sin(alpha)
// ynew = x * sin(alpha) + y * cos(alpha)
// Bottom Right is not rotated: the pages of RectQuelle must
// remain parallel to the coordinate axes.
2000-09-18 16:07:07 +00:00
NewCenter.X() = (long) (Center.X() * cs - Center.Y() * sn);
NewCenter.Y() = (long) (Center.X() * sn + Center.Y() * cs);
}
Size Differenz;
Point DiffPoint = (NewCenter - Center);
Differenz.Width() = DiffPoint.X();
2011-04-07 15:47:21 +03:00
Differenz.Height() = -DiffPoint.Y(); // Note that the Y-axis is counted ad positive downward.
NbcMove (Differenz); // Actually executes the coordinate transformation.
2000-09-18 16:07:07 +00:00
}
void E3dScene::TakeObjNameSingul(XubString& rName) const
{
rName=ImpGetResStr(STR_ObjNameSingulScene3d);
2002-06-07 11:08:48 +00:00
String aName( GetName() );
if(aName.Len())
{
rName += sal_Unicode(' ');
rName += sal_Unicode('\'');
rName += aName;
rName += sal_Unicode('\'');
}
2000-09-18 16:07:07 +00:00
}
void E3dScene::TakeObjNamePlural(XubString& rName) const
{
rName=ImpGetResStr(STR_ObjNamePluralScene3d);
}
2011-04-07 15:47:21 +03:00
// The NbcRotate routine overloads the one of the SdrObject. The idea is
// to be able to rotate the scene relative to the position of the scene
// and then the objects in the scene
2000-09-18 16:07:07 +00:00
2008-10-17 08:40:10 +00:00
void E3dScene::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
{
if(maTransformation != rMatrix)
{
// call parent
E3dObject::NbcSetTransform(rMatrix);
}
}
void E3dScene::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
{
if(rMatrix != maTransformation)
{
// call parent
E3dObject::SetTransform(rMatrix);
}
}
2000-09-18 16:07:07 +00:00
void E3dScene::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
{
2011-04-07 15:47:21 +03:00
// So currently the glue points are defined relative to the scene aOutRect.
// Before turning the glue points are defined relative to the page. They
// take no part in the rotation of the scene. To ensure this, there is the
// SetGlueReallyAbsolute(sal_True);
2000-09-18 16:07:07 +00:00
2011-04-07 15:47:21 +03:00
// So that was the scene, now the objects used in the scene
// 3D objects, if there is only one it can still have multiple surfaces but
// the surfaces do not hve to be connected. This allows you to access child
// objects. So going through the entire list and rotate around the Z axis
// through the enter of aOutRect's (Steiner's theorem), so RotateZ
2000-09-18 16:07:07 +00:00
2011-04-07 15:47:21 +03:00
RotateScene (rRef, nWink, sn, cs); // Rotates the scene
2000-09-18 16:07:07 +00:00
double fWinkelInRad = nWink/100 * F_PI180;
2008-10-17 08:40:10 +00:00
basegfx::B3DHomMatrix aRotation;
aRotation.rotate(0.0, 0.0, fWinkelInRad);
NbcSetTransform(aRotation * GetTransform());
2011-04-07 15:47:21 +03:00
SetRectsDirty(); // This forces a recalculation of all BoundRects
NbcRotateGluePoints(rRef,nWink,sn,cs); // Rotate the glue points (who still
// have coordinates relative to the
// original page)
SetGlueReallyAbsolute(sal_False); // from now they are again relative to BoundRect (that is defined as aOutRect)
2000-09-18 16:07:07 +00:00
SetRectsDirty();
}
void E3dScene::RecalcSnapRect()
{
E3dScene* pScene = GetScene();
2008-10-17 08:40:10 +00:00
2000-09-18 16:07:07 +00:00
if(pScene == this)
{
2011-04-07 15:47:21 +03:00
// The Scene is used as a 2D-Objekt, take the SnapRect from the
// 2D Display settings
2000-09-18 16:07:07 +00:00
Camera3D& rCam = (Camera3D&)pScene->GetCamera();
maSnapRect = rCam.GetDeviceWindow();
2000-09-18 16:07:07 +00:00
}
else
{
2011-04-07 15:47:21 +03:00
// The Scene itself is a member of another scene, get the SnapRect
// as a composite object
2000-09-18 16:07:07 +00:00
E3dObject::RecalcSnapRect();
}
}
sal_Bool E3dScene::IsBreakObjPossible()
2000-09-18 16:07:07 +00:00
{
2011-04-07 15:47:21 +03:00
// Break scene, if all members are able to break
2008-10-17 08:40:10 +00:00
SdrObjListIter a3DIterator(maSubList, IM_DEEPWITHGROUPS);
while ( a3DIterator.IsMore() )
2000-09-18 16:07:07 +00:00
{
2008-10-17 08:40:10 +00:00
E3dObject* pObj = (E3dObject*) a3DIterator.Next();
2011-04-07 15:47:21 +03:00
DBG_ASSERT(pObj->ISA(E3dObject), "only 3D objects are allowed in scenes!");
2008-10-17 08:40:10 +00:00
if(!pObj->IsBreakObjPossible())
return sal_False;
2000-09-18 16:07:07 +00:00
}
2008-10-17 08:40:10 +00:00
return sal_True;
2000-09-18 16:07:07 +00:00
}
basegfx::B2DPolyPolygon E3dScene::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
{
2008-10-17 08:40:10 +00:00
return TakeXorPoly();
}
2010-10-05 07:57:54 -05:00
bool E3dScene::BegCreate(SdrDragStat& rStat)
{
rStat.SetOrtho4Possible();
Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
aRect1.Justify();
rStat.SetActionRect(aRect1);
NbcSetSnapRect(aRect1);
return sal_True;
}
2010-10-05 07:57:54 -05:00
bool E3dScene::MovCreate(SdrDragStat& rStat)
{
Rectangle aRect1;
rStat.TakeCreateRect(aRect1);
aRect1.Justify();
rStat.SetActionRect(aRect1);
NbcSetSnapRect(aRect1);
SetBoundRectDirty();
bSnapRectDirty=sal_True;
return sal_True;
}
2010-10-05 07:57:54 -05:00
bool E3dScene::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
{
Rectangle aRect1;
rStat.TakeCreateRect(aRect1);
aRect1.Justify();
NbcSetSnapRect(aRect1);
SetRectsDirty();
return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
}
2010-10-05 07:57:54 -05:00
bool E3dScene::BckCreate(SdrDragStat& /*rStat*/)
{
return sal_False;
}
void E3dScene::BrkCreate(SdrDragStat& /*rStat*/)
{
}
// eof
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */