diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-03-01 15:54:32 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-07 00:28:30 +0200 |
commit | dfefe448c41921f2f1e54d3f69b8b9e89031d055 (patch) | |
tree | 1aace31054b5740e2faffcbc5de66a791be27f7d /include/basegfx | |
parent | Revert "SOSAW080: Added first bunch of basic changes to helpers" (diff) | |
download | core-dfefe448c41921f2f1e54d3f69b8b9e89031d055.tar.gz core-dfefe448c41921f2f1e54d3f69b8b9e89031d055.zip |
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects
Added need for SdrModel& in constructors of SdrModel,
SdrPage, SdrView and SdrObjList. Builds, not finished.
SOSAW080: removed and replaced old SdrModel
Removed and replaced GetModel()/SetModel() in all using
classes (SdrObject, SdrPage, SdrView), added accessors
to new referenced SdrModel, adapted all accessing places.
Refactored/Extended ::Clone and ::operator== for these
classes to allow cloning objects to a target SdrModel.
Adapted places where this is done AFAP. Added quite some
comments (tagged with 'TTTT') where possible further work
is needed. Builds completely, thus checking in. This does
not mean that this change is done yet.
SOSAW080: Adapted SdrPage/SdrModel relationship
Also needed to work on copy-construction of SdrPage and hierarchy,
quite some stuff removed, no copy-constructor anymore, no
MigrateItemPool stuff. Builds well, test stuck, will need
some cleanup/finetunung
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Debugging/Stabilizing/MakeUnitTestWork
SOSAW080: Stabilized for UnitTests, cleanups
SOSAW080: Adapted GetObjGraphic to just take a const SdrObject&
SOSAW080: Removed ChangeModel from classes
Classes SvxTextEditSource and SvxDrawPage (including
TextEditSource stuff) do not need change of SdrModel
anymore.
SOSAW080: Adapted some comments to make more readable
SOSAW080: Corrected constructor
SOSAW080: getSdrModelFromUnoModel added override marks
SOSAW080: Added missing includes
SOSAW080: Corrected SdrPage constructor
SOSAW080: Corrected some SdrObject::Clone scenarios
Especially when cloning to another SdrModel and taking
the sdr::properties into account.
SOSAW080: Added include for Mac-Build
SOSAW080: Added Scale to DefaultProperties
If a SdrModel change happens in DefaultProperties copy
constructor (used from Clone()), potentially a Scale
for the SfxItems has to be done.
SOSAW080: Added missing include for MacBuild
SOSAW080: Corrected CppunitTest_sc_anchor_test
An adaption of a SdrPathObj instantiation was missing,
added that. Seems as if that test is no tpart of the
usual 'make' scenario, but used/executed in gerrit builds
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
SOSAW080: Solve UNO API calls that move SvxShapes to other Model
Due to UNO API tests I got a call to insert an xShape to a
xDrawPage which was constructed in another Model, this has now to
be done by Cloning the SdrObject to the new SdrModel, getting
rid of the old one and getting all the UNO implementation
stuff right (referemces SdrObject <-> xShape).
1cb7d573d323e98a89761fe662c10c4a654fdec0
24617494a0ef79f6e33dfcb02782a833a81c6434
763f39094b6a48b529a6952d01468f8776c97679
242b9e228a9a042c3a5bdd38b1ea6600144276d5
242b9e228a9a042c3a5bdd38b1ea6600144276d5
33a6f3f306b70c223171aef796dd5ee041ad14df
6878b33f8b05738a44c0910e40a60a0f0d1d58ed
0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2
8c4626274a5cc531dad27f27c0c45d4c528fb2fb
446685a49a6d67aedd01cfbbd5e87b07f97a4d7b
c1b5ed3c99bc7219a0061e4ece24ea42afd2889a
22de9a1c8af7c25be5c108671ddc548ba323ed47
4caf6b6fbbe6e8130741d793dffb560fd01d4ed5
488b9601735ec1822433f82f633990063951fe08
c366d60299f239e3df856ddffedb19e743e4be0c
c5137ba8c597c7b5f90318df50e87b93a39a28dc
f9e646242cf89f6fde1315046952252a2c429779
f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410
1694b54903df784385abaa8452e1201e12344238
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
7b5c241faec7488924e5935ae8b19f785846b5e4
bf097ee7467895823fbd158a2a9543da3b5a5078
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
Reviewed-on: https://gerrit.libreoffice.org/52526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'include/basegfx')
-rw-r--r-- | include/basegfx/matrix/b2dhommatrix.hxx | 2 | ||||
-rw-r--r-- | include/basegfx/matrix/b3dhommatrix.hxx | 3 | ||||
-rwxr-xr-x | include/basegfx/matrix/b3dhommatrixtools.hxx | 46 | ||||
-rw-r--r-- | include/basegfx/numeric/ftools.hxx | 19 | ||||
-rw-r--r-- | include/basegfx/range/b1drange.hxx | 5 | ||||
-rw-r--r-- | include/basegfx/range/b2drange.hxx | 25 | ||||
-rw-r--r-- | include/basegfx/range/b2irange.hxx | 7 | ||||
-rw-r--r-- | include/basegfx/range/b3drange.hxx | 25 | ||||
-rw-r--r-- | include/basegfx/range/basicrange.hxx | 22 |
9 files changed, 154 insertions, 0 deletions
diff --git a/include/basegfx/matrix/b2dhommatrix.hxx b/include/basegfx/matrix/b2dhommatrix.hxx index a7ab0c3f5917..9f2c8a338412 100644 --- a/include/basegfx/matrix/b2dhommatrix.hxx +++ b/include/basegfx/matrix/b2dhommatrix.hxx @@ -74,8 +74,10 @@ namespace basegfx void rotate(double fRadiant); void translate(double fX, double fY); + void translate(const B2DTuple& rTuple); void scale(double fX, double fY); + void scale(const B2DTuple& rTuple); // Shearing-Matrices void shearX(double fSx); diff --git a/include/basegfx/matrix/b3dhommatrix.hxx b/include/basegfx/matrix/b3dhommatrix.hxx index 09d700547363..6d5d5c486b9b 100644 --- a/include/basegfx/matrix/b3dhommatrix.hxx +++ b/include/basegfx/matrix/b3dhommatrix.hxx @@ -64,12 +64,15 @@ namespace basegfx /// Rotation void rotate(double fAngleX,double fAngleY,double fAngleZ); + void rotate(const B3DTuple& rRotation); /// Translation void translate(double fX, double fY, double fZ); + void translate(const B3DTuple& rTranslation); /// Scaling void scale(double fX, double fY, double fZ); + void scale(const B3DTuple& rScale); // Shearing-Matrices void shearXY(double fSx, double fSy); diff --git a/include/basegfx/matrix/b3dhommatrixtools.hxx b/include/basegfx/matrix/b3dhommatrixtools.hxx new file mode 100755 index 000000000000..16debfad981b --- /dev/null +++ b/include/basegfx/matrix/b3dhommatrixtools.hxx @@ -0,0 +1,46 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX +#define INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX + +#include <sal/types.h> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <com/sun/star/drawing/HomogenMatrix.hpp> + +namespace basegfx +{ +namespace utils +{ +/* tooling methods for converting API matrices (drawing::HomogenMatrix) to + B3DHomMatrix. drawing::HomogenMatrix4 is not used by OOo + */ +BASEGFX_DLLPUBLIC B3DHomMatrix +UnoHomogenMatrixToB3DHomMatrix(const com::sun::star::drawing::HomogenMatrix& rMatrixIn); + +BASEGFX_DLLPUBLIC void +B3DHomMatrixToUnoHomogenMatrix(const B3DHomMatrix& rMatrixIn, + com::sun::star::drawing::HomogenMatrix& rMatrixOut); + +} // end of namespace tools +} // end of namespace basegfx + +#endif // INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIXTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx index 52909c9cd75b..1ade3bb3a3d6 100644 --- a/include/basegfx/numeric/ftools.hxx +++ b/include/basegfx/numeric/ftools.hxx @@ -153,6 +153,25 @@ namespace basegfx */ BASEGFX_DLLPUBLIC double snapToNearestMultiple(double v, const double fStep); + /** Snap v to the range [0.0 .. fWidth] using modulo + */ + double snapToZeroRange(double v, double fWidth); + + /** Snap v to the range [fLow .. fHigh] using modulo + */ + double snapToRange(double v, double fLow, double fHigh); + + /** return fValue with the sign of fSignCarrier, thus evtl. changed + */ + inline double copySign(double fValue, double fSignCarrier) + { +#ifdef WNT + return _copysign(fValue, fSignCarrier); +#else + return copysign(fValue, fSignCarrier); +#endif + } + /** RotateFlyFrame3: Normalize to range defined by [0.0 ... fRange[, independent if v is positive or negative. diff --git a/include/basegfx/range/b1drange.hxx b/include/basegfx/range/b1drange.hxx index c1e35b13605c..7b0d22869559 100644 --- a/include/basegfx/range/b1drange.hxx +++ b/include/basegfx/range/b1drange.hxx @@ -141,6 +141,11 @@ namespace basegfx maRange.intersect(rRange.maRange); } + /// clamp value on range + double clamp(double fValue) const + { + return maRange.clamp(fValue); + } }; } // end of namespace basegfx diff --git a/include/basegfx/range/b2drange.hxx b/include/basegfx/range/b2drange.hxx index 0de9dba0e783..00eab63d1472 100644 --- a/include/basegfx/range/b2drange.hxx +++ b/include/basegfx/range/b2drange.hxx @@ -274,8 +274,29 @@ namespace basegfx maRangeY.grow(fValue); } + /// clamp value on range + B2DTuple clamp(const B2DTuple& rTuple) const + { + return B2DTuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY())); + } + + /** Transform Range by given transformation matrix. */ BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix& rMatrix); + /** Transform Range by given transformation matrix. + + This operation transforms the Range by transforming all four possible + extrema points (corners) of the given range and building a new one. + This means that the range will grow evtl. when a shear and/or rotation + is part of the transformation. + */ + B2DRange& operator*=( const ::basegfx::B2DHomMatrix& rMat ); + + /** Get a range filled with (0.0, 0.0, 1.0, 1.0) */ + static const B2DRange& getUnitB2DRange(); + private: typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange; @@ -283,6 +304,10 @@ namespace basegfx MyBasicRange maRangeY; }; + /** Transform B2DRange by given transformation matrix (see operator*=()) + */ + B2DRange operator*( const B2DHomMatrix& rMat, const B2DRange& rB2DRange ); + /** Round double to nearest integer for 2D range @return the nearest integer for this range diff --git a/include/basegfx/range/b2irange.hxx b/include/basegfx/range/b2irange.hxx index 3d7d0edba6c9..a8a95d69ceed 100644 --- a/include/basegfx/range/b2irange.hxx +++ b/include/basegfx/range/b2irange.hxx @@ -208,6 +208,13 @@ namespace basegfx maRangeY.intersect(rRange.maRangeY); } + B2ITuple clamp(const B2ITuple& rTuple) const + { + return B2ITuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY())); + } + private: typedef ::basegfx::BasicRange< ValueType, TraitsType > MyBasicRange; diff --git a/include/basegfx/range/b3drange.hxx b/include/basegfx/range/b3drange.hxx index 881dce612297..e1c44393813a 100644 --- a/include/basegfx/range/b3drange.hxx +++ b/include/basegfx/range/b3drange.hxx @@ -195,9 +195,34 @@ namespace basegfx maRangeZ.grow(fValue); } + /// clamp value on range + B3DTuple clamp(const B3DTuple& rTuple) const + { + return B3DTuple( + maRangeX.clamp(rTuple.getX()), + maRangeY.clamp(rTuple.getY()), + maRangeZ.clamp(rTuple.getZ())); + } + BASEGFX_DLLPUBLIC void transform(const B3DHomMatrix& rMatrix); + + /** Transform Range by given transformation matrix. + + This operation transforms the Range by transforming all eight possible + extrema points (corners) of the given range and building a new one. + This means that the range will grow evtl. when a shear and/or rotation + is part of the transformation. + */ + B3DRange& operator*=( const ::basegfx::B3DHomMatrix& rMat ); + + /** Get a range filled with (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) */ + static const B3DRange& getUnitB3DRange(); }; + /** Transform B3DRange by given transformation matrix (see operator*=()) + */ + B3DRange operator*( const B3DHomMatrix& rMat, const B3DRange& rB2DRange ); + } // end of namespace basegfx diff --git a/include/basegfx/range/basicrange.hxx b/include/basegfx/range/basicrange.hxx index bea40dd3ded2..17f31ea42f19 100644 --- a/include/basegfx/range/basicrange.hxx +++ b/include/basegfx/range/basicrange.hxx @@ -248,6 +248,28 @@ namespace basegfx } } + T clamp(T nValue) const + { + if(isEmpty()) + { + return nValue; + } + else + { + if(nValue < mnMinimum) + { + return mnMinimum; + } + + if(nValue > mnMaximum) + { + return mnMaximum; + } + + return nValue; + } + } + typename Traits::DifferenceType getRange() const { if(isEmpty()) |