/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene const & rScene)
{ // only called when rScene.GetSubList() and nObjCount > 1
SdrObjList* pList = rScene.GetSubList(); const size_t nObjCount(pList->GetObjCount());
for(size_t a = 0; a < nObjCount; ++a)
{
SdrObject* pCandidate = pList->GetObj(a);
if(pCandidate)
{ if(auto pCompoundObj = dynamic_cast< const E3dCompoundObject*>(pCandidate))
{ // single 3d object, calc depth constdouble fMinimalDepth(getMinimalDepthInViewCoordinates(*pCompoundObj));
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 its members minimal depth. The // smaller, the nearer to the viewer.
::std::sort(maVector.begin(), maVector.end());
}
// copy child SdrObjects if (rSource.GetSubList())
{
CopyObjects(*rSource.GetSubList());
// tdf#116979: needed here, we need bSnapRectDirty to be true // which it is after using SdrObject::operator= (see above), // but set to false again using CopyObjects
SetBoundAndSnapRectsDirty();
}
// copy local data
m_aCamera = rSource.m_aCamera;
m_aCameraSet = rSource.m_aCameraSet; static_cast<sdr::properties::E3dSceneProperties&>(GetProperties()).SetSceneItemsFromCamera();
InvalidateBoundVolume();
RebuildLists();
ImpCleanup3DDepthMapper();
GetViewContact().ActionChanged();
}
// set defaults for Camera from ItemPool
m_aCamera.SetProjection(GetPerspective());
basegfx::B3DPoint aActualPosition(m_aCamera.GetPosition()); double fNew = GetDistance();
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();
}
}
// 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);
// Set perspective
GetCameraSet().SetPerspective(m_aCamera.GetProjection() == ProjectionType::Perspective);
GetCameraSet().SetViewportRectangle(m_aCamera.GetDeviceWindow());
// then examine all the objects in the scene while(a3DIterator.IsMore())
{
E3dObject* p3DObj(static_cast< E3dObject* >(a3DIterator.Next()));
p3DObj->NbcSetLayer(nCurrLayerID);
}
void E3dScene::RestoreGeoData(const SdrObjGeoData& rGeo)
{ // #i94832# removed E3DModifySceneSnapRectUpdater here. // It should not be needed, is already part of E3dObject::RestoreGeoData
E3dObject::RestoreGeoData (rGeo);
SetCamera (static_cast<const E3DSceneGeoData &>(rGeo).aCamera);
}
// Something was changed in the style sheet, so change scene
autoconst& rRectangle = getOutRectangle();
Point Center = rRectangle.Center();
// 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
Center.setX(Center.X() - rRef.X());
Center.setY(rRef.Y() - Center.Y()); // A few special cases has to be dealt with first (n * 90 degrees n integer) if (sn==1.0 && cs==0.0) { // 90deg
NewCenter.setX( -Center.Y() );
NewCenter.setY( -Center.X() );
} elseif (sn==0.0 && cs==-1.0) { // 180deg
NewCenter.setX( -Center.X() );
NewCenter.setY( -Center.Y() );
} elseif (sn==-1.0 && cs==0.0) { // 270deg
NewCenter.setX( Center.Y() );
NewCenter.setY( -Center.X() );
} 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 aOutRect must // remain parallel to the coordinate axes.
NewCenter.setX( static_cast<tools::Long>(Center.X() * cs - Center.Y() * sn) );
NewCenter.setY( static_cast<tools::Long>(Center.X() * sn + Center.Y() * cs) );
}
Size Differenz;
Point DiffPoint = NewCenter - Center;
Differenz.setWidth( DiffPoint.X() );
Differenz.setHeight( -DiffPoint.Y() ); // Note that the Y-axis is counted ad positive downward.
NbcMove (Differenz); // Actually executes the coordinate transformation.
}
// The NbcRotate routine overrides 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
void E3dScene::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
{ // So currently the gluepoints are defined relative to the scene aOutRect. // Before turning the gluepoints 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);
// 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 have 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
RotateScene (rRef, sn, cs); // Rotates the scene double fAngleInRad = toRadians(nAngle);
SetBoundAndSnapRectsDirty(); // This forces a recalculation of all BoundRects
NbcRotateGluePoints(rRef,nAngle,sn,cs); // Rotate the gluepoints (who still // have coordinates relative to the // original page)
SetGlueReallyAbsolute(false); // from now they are again relative to BoundRect (that is defined as aOutRect)
SetBoundAndSnapRectsDirty();
}
if(pScene == this)
{ // The Scene is used as a 2D-Object, take the SnapRect from the // 2D Display settings
maSnapRect = pScene->m_aCamera.GetDeviceWindow();
} else
{ // The Scene itself is a member of another scene, get the SnapRect // as a composite object // call parent
E3dObject::RecalcSnapRect();
for (const rtl::Reference<SdrObject>& pObj : *this)
{
E3dObject* pCandidate(DynCastE3dObject(pObj.get()));
bool E3dScene::IsBreakObjPossible()
{ // Break scene, if all members are able to break
SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::DeepWithGroups);
void E3dScene::NbcInsertObject(SdrObject* pObj, size_t nPos)
{ // Is it even a 3D object? if(DynCastE3dObject(pObj))
{ // Normal 3D object, insert means call parent
SdrObjList::NbcInsertObject(pObj, nPos);
// local needed stuff
InvalidateBoundVolume();
StructureChanged();
} else
{ // No 3D object, inserted a page in place in a scene ... if (SdrPage* pPage = getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject())
pPage->InsertObject(pObj, nPos);
}
}
void E3dScene::InsertObject(SdrObject* pObj, size_t nPos)
{ // Is it even a 3D object? if(DynCastE3dObject(pObj))
{ // call parent
SdrObjList::InsertObject(pObj, nPos);
// local needed stuff
InvalidateBoundVolume();
StructureChanged();
} else
{ // No 3D object, inserted a page in place in a scene ... if (SdrPage* pPage = getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject())
pPage->InsertObject(pObj, nPos);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.