22#include <osl/thread.h>
23#include <rtl/math.hxx>
25#include <bitmaps.hlst>
96 static constexpr auto npos = std::numeric_limits<Handles::size_type>::max();
116 static void computeChunk(
double fMin,
double fMax,
double& fChunkOut,
double& fMinChunkOut );
118 static double interpolate(
double x,
double const * pNodeX,
double const * pNodeY,
int nNodes );
124 virtual void Resize()
override;
129 void Init(
double* pXValues,
double* pYValues,
int nValues,
bool bCutValues,
const BitmapEx &rMarkerBitmap);
132 void setBoundings(
double fMinX,
double fMinY,
double fMaxX,
double fMaxY );
142 : m_aGridArea(50, 15, 100, 100)
151 , m_pXValues(nullptr)
152 , m_pOrigYValues(nullptr)
156 , m_bCutValues(false)
203 CustomWidgetController::SetDrawingArea(pDrawingArea);
208 : GenericDialogController(pParent,
"modules/scanner/ui/griddialog.ui",
"GridDialog")
209 , m_xResetTypeBox(m_xBuilder->weld_combo_box(
"resetTypeCombobox"))
210 , m_xResetButton(m_xBuilder->weld_button(
"resetButton"))
212 , m_xGridWindowWND(new
weld::CustomWeld(*m_xBuilder,
"gridwindow", *m_xGridWindow))
315 if (!nWidth || !nHeight)
329 fChunkOut = ( fMax - fMin ) / 6.0;
330 int logchunk =
static_cast<int>(std::log10( fChunkOut ));
331 int nChunk =
static_cast<int>( fChunkOut / std::exp(
static_cast<double>(logchunk-1) * M_LN10 ) );
334 else if( nChunk >= 35 )
336 else if ( nChunk > 20 )
338 else if ( nChunk >= 13 )
340 else if( nChunk > 5 )
344 fChunkOut =
static_cast<double>(nChunk) * exp(
static_cast<double>(logchunk-1) * M_LN10 );
346 nChunk =
static_cast<int>( fMin / fChunkOut );
347 fMinChunkOut =
static_cast<double>(nChunk) * fChunkOut;
348 while( fMinChunkOut < fMin )
349 fMinChunkOut += fChunkOut;
359 double xright, yright;
362 double factor = (yright-yleft)/(xright-xleft);
376 std::unique_ptr<double[]> nodex(
new double[ nSorted ]);
377 std::unique_ptr<double[]> nodey(
new double[ nSorted ]);
379 for(
i = 0;
i < nSorted;
i++ )
400 double const * pNodeX,
401 double const * pNodeY,
406 for(
int i = 0;
i < nNodes;
i++ )
408 double sum = pNodeY[
i ];
409 for(
int n = 0;
n < nNodes;
n++ )
413 sum *=
x - pNodeX[
n ];
414 sum /= pNodeX[
i ] - pNodeX[
n ];
449 OUString aMark(pBuf, strlen(pBuf), osl_getThreadTextEncoding());
453 rRenderContext.
DrawText(aPt, aMark);
462 OUString aMark(pBuf, strlen(pBuf), osl_getThreadTextEncoding());
466 rRenderContext.
DrawText(aPt, aMark);
574 Handles::size_type nMarkerIndex =
npos;
587 if( nMarkerIndex !=
npos )
595 if( nMarkerIndex !=
npos )
597 if( nMarkerIndex != 0 && nMarkerIndex !=
m_aHandles.size() - 1)
690 int nType = m_xResetTypeBox->get_active();
static const AllSettings & GetSettings()
const Size & GetSizePixel() const
virtual ~GridDialog() override
std::unique_ptr< weld::ComboBox > m_xResetTypeBox
std::unique_ptr< GridWindow > m_xGridWindow
std::unique_ptr< weld::Button > m_xResetButton
GridDialog(weld::Window *pParent, double *pXValues, double *pYValues, int nValues)
void setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY)
std::unique_ptr< double[]> m_pNewYValues
Handles::size_type m_nDragIndex
static constexpr auto npos
virtual void Paint(vcl::RenderContext &, const tools::Rectangle &rRect) override
static void computeChunk(double fMin, double fMax, double &fChunkOut, double &fMinChunkOut)
void drawNew(vcl::RenderContext &rRenderContext)
void ChangeMode(ResetType nType)
void drawGrid(vcl::RenderContext &rRenderContext)
Point transform(double x, double y)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY)
virtual bool MouseButtonDown(const MouseEvent &) override
virtual ~GridWindow() override
void drawOriginal(vcl::RenderContext &rRenderContext)
void Init(double *pXValues, double *pYValues, int nValues, bool bCutValues, const BitmapEx &rMarkerBitmap)
std::vector< impHandle > Handles
virtual bool MouseButtonUp(const MouseEvent &) override
static double interpolate(double x, double const *pNodeX, double const *pNodeY, int nNodes)
tools::Rectangle m_aGridArea
void drawHandles(vcl::RenderContext &rRenderContext)
void drawLine(vcl::RenderContext &rRenderContext, double x1, double y1, double x2, double y2)
virtual void Resize() override
virtual bool MouseMove(const MouseEvent &) override
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawLine(const Point &rStartPt, const Point &rEndPt)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
tools::Long GetTextHeight() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual OutputDevice & get_ref_device()=0
constexpr ::Color COL_YELLOW(0xFF, 0xFF, 0x00)
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
IMPL_LINK_NOARG(GridDialog, ClickButtonHdl, weld::Button &, void)
#define LINK(Instance, Class, Member)
int sprintf(char(&s)[N], char const *format, T &&... arguments)
bool isHit(OutputDevice const &rWin, const Point &rPos)
impHandle(const Point &rPos, sal_uInt16 nX, sal_uInt16 nY)
bool operator<(const impHandle &rComp) const
void draw(vcl::RenderContext &rRenderContext, const BitmapEx &rBitmapEx)