/* -*- 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 .
*/
// rObject is an E3dCompoundObject, so it cannot be a scene (which is an E3dObject) const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact()); const drawinglayer::primitive3d::Primitive3DContainer aPrimitives(rVCObject.getViewIndependentPrimitive3DContainer());
if(aPrimitives.empty()) return;
// make BoundVolume empty and overlapping test for speedup const basegfx::B3DRange aObjectRange(aPrimitives.getB3DRange(rObjectViewInformation3D));
E3dScene* fillViewInformation3DForCompoundObject(drawinglayer::geometry::ViewInformation3D& o_rViewInformation3D, const E3dCompoundObject& rCandidate)
{ // Search for root scene (outmost scene) of the 3d object since e.g. in chart, multiple scenes may // be placed between object and outmost scene. On that search, remember the in-between scene's // transformation for the correct complete ObjectTransformation. For historical reasons, the // root scene's own object transformation is part of the scene's ViewTransformation, o do not // add it. For more details, see ViewContactOfE3dScene::createViewInformation3D.
E3dScene* pParentScene(rCandidate.getParentE3dSceneFromE3dObject());
E3dScene* pRootScene(nullptr);
basegfx::B3DHomMatrix aInBetweenSceneMatrix;
if(pParentParentScene)
{ // pParentScene is an in-between scene
aInBetweenSceneMatrix = pParentScene->GetTransform() * aInBetweenSceneMatrix;
} else
{ // pParentScene is the root scene
pRootScene = pParentScene;
}
// prepare relative HitPoint. To do so, get the VC of the 3DScene and from there // the Scene's 2D transformation. Multiplying with the inverse transformation // will create a point relative to the 3D scene as unit-2d-object const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rScene.GetViewContact());
basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
aInverseSceneTransform.invert(); const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint);
// check if test point is inside scene's area at all if(!(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0)) return;
// create HitPoint Front and Back, transform to object coordinates
basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView());
aViewToObject.invert(); const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0)); const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0));
if(!aFront.equal(aBack))
{ // get all hit points with object
::std::vector< basegfx::B3DPoint > aHitsWithObject;
getAllHit3DObjectWithRelativePoint(aFront, aBack, *pCandidate, aViewInfo3D, aHitsWithObject, false);
if(pRootScene)
{ // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there // the Scene's 2D transformation. Multiplying with the inverse transformation // will create a point relative to the 3D scene as unit-2d-object const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
aInverseSceneTransform.invert(); const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint);
// check if test point is inside scene's area at all if(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0)
{ // create HitPoint Front and Back, transform to object coordinates
basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView());
aViewToObject.invert(); const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0)); const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0));
if(!aFront.equal(aBack))
{ // get all hit points with object
::std::vector< basegfx::B3DPoint > aHitsWithObject;
getAllHit3DObjectWithRelativePoint(aFront, aBack, rCandidate, aViewInfo3D, aHitsWithObject, true);
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.