xref: /trunk/main/extensions/source/scanner/grid.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*46dbaceeSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*46dbaceeSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*46dbaceeSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*46dbaceeSAndrew Rist  * distributed with this work for additional information
6*46dbaceeSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*46dbaceeSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*46dbaceeSAndrew Rist  * "License"); you may not use this file except in compliance
9*46dbaceeSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*46dbaceeSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*46dbaceeSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*46dbaceeSAndrew Rist  * software distributed under the License is distributed on an
15*46dbaceeSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*46dbaceeSAndrew Rist  * KIND, either express or implied.  See the License for the
17*46dbaceeSAndrew Rist  * specific language governing permissions and limitations
18*46dbaceeSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*46dbaceeSAndrew Rist  *************************************************************/
21*46dbaceeSAndrew Rist 
22*46dbaceeSAndrew Rist 
23cdf0e10cSrcweir #ifndef _EXTENSIONS_SCANNER_GRID_HXX
24cdf0e10cSrcweir #define _EXTENSIONS_SCANNER_GRID_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <vcl/window.hxx>
27cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
28cdf0e10cSrcweir #include <vcl/button.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <vcl/lstbox.hxx>
31cdf0e10cSrcweir #include <vcl/dialog.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class GridWindow : public ModalDialog
34cdf0e10cSrcweir {
35cdf0e10cSrcweir     // helper class for handles
36cdf0e10cSrcweir     struct impHandle
37cdf0e10cSrcweir     {
38cdf0e10cSrcweir         Point           maPos;
39cdf0e10cSrcweir         sal_uInt16      mnOffX;
40cdf0e10cSrcweir         sal_uInt16      mnOffY;
41cdf0e10cSrcweir 
impHandleGridWindow::impHandle42cdf0e10cSrcweir         impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY)
43cdf0e10cSrcweir         :   maPos(rPos), mnOffX(nX), mnOffY(nY)
44cdf0e10cSrcweir         {
45cdf0e10cSrcweir         }
46cdf0e10cSrcweir 
operator <GridWindow::impHandle47cdf0e10cSrcweir         bool operator<(const impHandle& rComp) const
48cdf0e10cSrcweir         {
49cdf0e10cSrcweir             return (maPos.X() < rComp.maPos.X());
50cdf0e10cSrcweir         }
51cdf0e10cSrcweir 
drawGridWindow::impHandle52cdf0e10cSrcweir         void draw(Window& rWin, const BitmapEx& rBitmapEx)
53cdf0e10cSrcweir         {
54cdf0e10cSrcweir             const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
55cdf0e10cSrcweir             rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx);
56cdf0e10cSrcweir         }
57cdf0e10cSrcweir 
isHitGridWindow::impHandle58cdf0e10cSrcweir         bool isHit(Window& rWin, const Point& rPos)
59cdf0e10cSrcweir         {
60cdf0e10cSrcweir             const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
61cdf0e10cSrcweir             const Rectangle aTarget(maPos - aOffset, maPos + aOffset);
62cdf0e10cSrcweir             return aTarget.IsInside(rPos);
63cdf0e10cSrcweir         }
64cdf0e10cSrcweir     };
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     Rectangle       m_aGridArea;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     double          m_fMinX;
69cdf0e10cSrcweir     double          m_fMinY;
70cdf0e10cSrcweir     double          m_fMaxX;
71cdf0e10cSrcweir     double          m_fMaxY;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     double          m_fChunkX;
74cdf0e10cSrcweir     double          m_fMinChunkX;
75cdf0e10cSrcweir     double          m_fChunkY;
76cdf0e10cSrcweir     double          m_fMinChunkY;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     double*         m_pXValues;
79cdf0e10cSrcweir     double*         m_pOrigYValues;
80cdf0e10cSrcweir     int             m_nValues;
81cdf0e10cSrcweir     double*         m_pNewYValues;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     sal_uInt16      m_BmOffX;
84cdf0e10cSrcweir     sal_uInt16      m_BmOffY;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     sal_Bool            m_bCutValues;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     // stuff for handles
89cdf0e10cSrcweir     std::vector< impHandle >    m_aHandles;
90cdf0e10cSrcweir     sal_uInt32                  m_nDragIndex;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     BitmapEx        m_aMarkerBitmap;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     OKButton        m_aOKButton;
95cdf0e10cSrcweir     CancelButton    m_aCancelButton;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     ListBox         m_aResetTypeBox;
98cdf0e10cSrcweir     PushButton      m_aResetButton;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     Point transform( double x, double y );
102cdf0e10cSrcweir     void transform( const Point& rOriginal, double& x, double& y );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     double findMinX();
105cdf0e10cSrcweir     double findMinY();
106cdf0e10cSrcweir     double findMaxX();
107cdf0e10cSrcweir     double findMaxY();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     void drawGrid();
110cdf0e10cSrcweir     void drawOriginal();
111cdf0e10cSrcweir     void drawNew();
112cdf0e10cSrcweir     void drawHandles();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     void computeExtremes();
115cdf0e10cSrcweir     void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut );
116cdf0e10cSrcweir     void computeNew();
117cdf0e10cSrcweir     double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     DECL_LINK( ClickButtonHdl, Button* );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual void MouseMove( const MouseEvent& );
122cdf0e10cSrcweir     virtual void MouseButtonDown( const MouseEvent& );
123cdf0e10cSrcweir     virtual void MouseButtonUp( const MouseEvent& );
124cdf0e10cSrcweir public:
125cdf0e10cSrcweir     GridWindow( double* pXValues, double* pYValues, int nValues,
126cdf0e10cSrcweir                 Window* pParent, sal_Bool bCutValues = sal_True );
127cdf0e10cSrcweir     ~GridWindow();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
getMinX()130cdf0e10cSrcweir     double getMinX() { return m_fMinX; }
getMinY()131cdf0e10cSrcweir     double getMinY() { return m_fMinY; }
getMaxX()132cdf0e10cSrcweir     double getMaxX() { return m_fMaxX; }
getMaxY()133cdf0e10cSrcweir     double getMaxY() { return m_fMaxY; }
134cdf0e10cSrcweir 
countValues()135cdf0e10cSrcweir     int countValues() { return m_nValues; }
getXValues()136cdf0e10cSrcweir     double* getXValues() { return m_pXValues; }
getOrigYValues()137cdf0e10cSrcweir     double* getOrigYValues() { return m_pOrigYValues; }
getNewYValues()138cdf0e10cSrcweir     double* getNewYValues() { return m_pNewYValues; }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     void drawLine( double x1, double y1, double x2, double y2 );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     virtual void Paint( const Rectangle& rRect );
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif // _EXTENSIONS_SCANNER_GRID_HXX
146