Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
97fa4faa
Kaydet (Commit)
97fa4faa
authored
Agu 23, 2012
tarafından
Armin Le Grand
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#120596# Optimized grid primitive, added some tooling to basegfx
üst
dd39ad42
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
0 deletions
+107
-0
ftools.hxx
basegfx/inc/basegfx/numeric/ftools.hxx
+30
-0
ftools.cxx
basegfx/source/numeric/ftools.cxx
+77
-0
gridprimitive2d.cxx
drawinglayer/source/primitive2d/gridprimitive2d.cxx
+0
-0
No files found.
basegfx/inc/basegfx/numeric/ftools.hxx
Dosyayı görüntüle @
97fa4faa
...
...
@@ -139,6 +139,36 @@ namespace basegfx
return
v
/
M_PI_2
*
90.0
;
}
/** Snap v to nearest multiple of fStep, from negative and
positive side.
Examples:
snapToNearestMultiple(-0.1, 0.5) = 0.0
snapToNearestMultiple(0.1, 0.5) = 0.0
snapToNearestMultiple(0.25, 0.5) = 0.0
snapToNearestMultiple(0.26, 0.5) = 0.5
*/
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
}
class
fTools
{
...
...
basegfx/source/numeric/ftools.cxx
Dosyayı görüntüle @
97fa4faa
...
...
@@ -24,11 +24,88 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_basegfx.hxx"
#include <basegfx/numeric/ftools.hxx>
#include <algorithm>
namespace
basegfx
{
// init static member of class fTools
double
::
basegfx
::
fTools
::
mfSmallValue
=
0.000000001
;
double
snapToNearestMultiple
(
double
v
,
const
double
fStep
)
{
if
(
fTools
::
equalZero
(
fStep
))
{
// with a zero step, all snaps to 0.0
return
0.0
;
}
else
{
const
double
fHalfStep
(
fStep
*
0.5
);
const
double
fChange
(
fHalfStep
-
fmod
(
v
+
fHalfStep
,
fStep
));
if
(
basegfx
::
fTools
::
equal
(
fabs
(
v
),
fabs
(
fChange
)))
{
return
0.0
;
}
else
{
return
v
+
fChange
;
}
}
}
double
snapToZeroRange
(
double
v
,
double
fWidth
)
{
if
(
fTools
::
equalZero
(
fWidth
))
{
// with no range all snaps to range bound
return
0.0
;
}
else
{
if
(
v
<
0.0
||
v
>
fWidth
)
{
double
fRetval
(
fmod
(
v
,
fWidth
));
if
(
fRetval
<
0.0
)
{
fRetval
+=
fWidth
;
}
return
fRetval
;
}
else
{
return
v
;
}
}
}
double
snapToRange
(
double
v
,
double
fLow
,
double
fHigh
)
{
if
(
fTools
::
equal
(
fLow
,
fHigh
))
{
// with no range all snaps to range bound
return
0.0
;
}
else
{
if
(
fLow
>
fHigh
)
{
// correct range order. Evtl. assert this (?)
std
::
swap
(
fLow
,
fHigh
);
}
if
(
v
<
fLow
||
v
>
fHigh
)
{
return
snapToZeroRange
(
v
-
fLow
,
fHigh
-
fLow
)
+
fLow
;
}
else
{
return
v
;
}
}
}
}
// end of namespace basegfx
// eof
drawinglayer/source/primitive2d/gridprimitive2d.cxx
Dosyayı görüntüle @
97fa4faa
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment