Files
libreoffice/drawinglayer/source/primitive3d/sdrprimitive3d.cxx

126 lines
4.6 KiB
C++
Raw Normal View History

2006-05-12 10:54:47 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2006-05-12 10:54:47 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2006-05-12 10:54:47 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2006-05-12 10:54:47 +00:00
*
* This file is part of OpenOffice.org.
2006-05-12 10:54:47 +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.
2006-05-12 10:54:47 +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).
2006-05-12 10:54:47 +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.
2006-05-12 10:54:47 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_drawinglayer.hxx"
2006-05-12 10:54:47 +00:00
#include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
2006-05-19 08:34:56 +00:00
#include <basegfx/polygon/b3dpolypolygontools.hxx>
2008-05-14 08:22:09 +00:00
#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
#include <drawinglayer/attribute/sdrlineattribute.hxx>
2008-05-14 08:22:09 +00:00
2006-05-12 10:54:47 +00:00
//////////////////////////////////////////////////////////////////////////////
2006-10-19 09:40:02 +00:00
using namespace com::sun::star;
//////////////////////////////////////////////////////////////////////////////
2006-05-12 10:54:47 +00:00
namespace drawinglayer
{
2006-08-09 15:51:16 +00:00
namespace primitive3d
2006-05-12 10:54:47 +00:00
{
2006-10-19 09:40:02 +00:00
basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const
2006-05-12 10:54:47 +00:00
{
2006-08-09 15:51:16 +00:00
basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
2006-05-12 10:54:47 +00:00
aUnitRange.transform(getTransform());
if(!getSdrLFSAttribute().getLine().isDefault())
2006-05-12 10:54:47 +00:00
{
const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
2006-05-12 10:54:47 +00:00
if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
2006-05-12 10:54:47 +00:00
{
// expand by hald LineWidth as tube radius
aUnitRange.grow(rLine.getWidth() / 2.0);
}
}
return aUnitRange;
}
2006-10-19 09:40:02 +00:00
basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const
2006-05-19 08:34:56 +00:00
{
2006-08-09 15:51:16 +00:00
basegfx::B3DRange aRetval;
2006-05-19 08:34:56 +00:00
if(rSlices.size())
{
for(sal_uInt32 a(0L); a < rSlices.size(); a++)
{
2006-08-09 15:51:16 +00:00
aRetval.expand(basegfx::tools::getRange(rSlices[a].getB3DPolyPolygon()));
2006-05-19 08:34:56 +00:00
}
aRetval.transform(getTransform());
if(!getSdrLFSAttribute().getLine().isDefault())
2006-05-19 08:34:56 +00:00
{
const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
2006-05-19 08:34:56 +00:00
if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
2006-05-19 08:34:56 +00:00
{
2008-05-14 08:22:09 +00:00
// expand by half LineWidth as tube radius
2006-05-19 08:34:56 +00:00
aRetval.grow(rLine.getWidth() / 2.0);
}
}
}
return aRetval;
}
2006-10-19 09:40:02 +00:00
SdrPrimitive3D::SdrPrimitive3D(
2006-08-09 15:51:16 +00:00
const basegfx::B3DHomMatrix& rTransform,
const basegfx::B2DVector& rTextureSize,
const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
2006-10-19 09:40:02 +00:00
const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
: BufferedDecompositionPrimitive3D(),
2006-08-09 15:51:16 +00:00
maTransform(rTransform),
2006-05-12 10:54:47 +00:00
maTextureSize(rTextureSize),
maSdrLFSAttribute(rSdrLFSAttribute),
maSdr3DObjectAttribute(rSdr3DObjectAttribute)
{
}
2006-10-19 09:40:02 +00:00
bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
2006-05-12 10:54:47 +00:00
{
if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
2006-05-12 10:54:47 +00:00
{
2006-10-19 09:40:02 +00:00
const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive);
2006-05-12 10:54:47 +00:00
2006-10-19 09:40:02 +00:00
return (getTransform() == rCompare.getTransform()
&& getTextureSize() == rCompare.getTextureSize()
&& getSdrLFSAttribute() == rCompare.getSdrLFSAttribute()
&& getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute());
2006-05-12 10:54:47 +00:00
}
return false;
}
2008-05-14 08:22:09 +00:00
2006-08-09 15:51:16 +00:00
} // end of namespace primitive3d
2006-05-12 10:54:47 +00:00
} // end of namespace drawinglayer
//////////////////////////////////////////////////////////////////////////////
// eof