bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / scanner / grid.hxx
blob33876f589a7c2b6ec1f1cabcc8ffd2b6e2034600
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _EXTENSIONS_SCANNER_GRID_HXX
20 #define _EXTENSIONS_SCANNER_GRID_HXX
22 #include <vcl/window.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/lstbox.hxx>
25 #include <vcl/dialog.hxx>
27 class GridWindow : public ModalDialog
29 // helper class for handles
30 struct impHandle
32 Point maPos;
33 sal_uInt16 mnOffX;
34 sal_uInt16 mnOffY;
36 impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY)
37 : maPos(rPos), mnOffX(nX), mnOffY(nY)
41 bool operator<(const impHandle& rComp) const
43 return (maPos.X() < rComp.maPos.X());
46 void draw(Window& rWin, const BitmapEx& rBitmapEx)
48 const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
49 rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx);
52 bool isHit(Window& rWin, const Point& rPos)
54 const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
55 const Rectangle aTarget(maPos - aOffset, maPos + aOffset);
56 return aTarget.IsInside(rPos);
60 Rectangle m_aGridArea;
62 double m_fMinX;
63 double m_fMinY;
64 double m_fMaxX;
65 double m_fMaxY;
67 double m_fChunkX;
68 double m_fMinChunkX;
69 double m_fChunkY;
70 double m_fMinChunkY;
72 double* m_pXValues;
73 double* m_pOrigYValues;
74 int m_nValues;
75 double* m_pNewYValues;
77 sal_uInt16 m_BmOffX;
78 sal_uInt16 m_BmOffY;
80 sal_Bool m_bCutValues;
82 // stuff for handles
83 std::vector< impHandle > m_aHandles;
84 sal_uInt32 m_nDragIndex;
86 BitmapEx m_aMarkerBitmap;
88 OKButton m_aOKButton;
89 CancelButton m_aCancelButton;
91 ListBox m_aResetTypeBox;
92 PushButton m_aResetButton;
95 Point transform( double x, double y );
96 void transform( const Point& rOriginal, double& x, double& y );
98 double findMinX();
99 double findMinY();
100 double findMaxX();
101 double findMaxY();
103 void drawGrid();
104 void drawOriginal();
105 void drawNew();
106 void drawHandles();
108 void computeExtremes();
109 void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut );
110 void computeNew();
111 double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes );
113 DECL_LINK( ClickButtonHdl, Button* );
115 virtual void MouseMove( const MouseEvent& );
116 virtual void MouseButtonDown( const MouseEvent& );
117 virtual void MouseButtonUp( const MouseEvent& );
118 public:
119 GridWindow( double* pXValues, double* pYValues, int nValues,
120 Window* pParent, sal_Bool bCutValues = sal_True );
121 ~GridWindow();
123 void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
124 double getMinX() { return m_fMinX; }
125 double getMinY() { return m_fMinY; }
126 double getMaxX() { return m_fMaxX; }
127 double getMaxY() { return m_fMaxY; }
129 int countValues() { return m_nValues; }
130 double* getXValues() { return m_pXValues; }
131 double* getOrigYValues() { return m_pOrigYValues; }
132 double* getNewYValues() { return m_pNewYValues; }
134 void drawLine( double x1, double y1, double x2, double y2 );
136 virtual void Paint( const Rectangle& rRect );
139 #endif // _EXTENSIONS_SCANNER_GRID_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */