OpenCPN Partial API docs
Loading...
Searching...
No Matches
IsoLine.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2008 by Jacques Zaninetti *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
42#ifndef ISOLINE_H
43#define ISOLINE_H
44
45#include <iostream>
46#include <cmath>
47#include <vector>
48#include <list>
49#include <set>
50
51#include "ocpn_plugin.h"
52
53#include "GribReader.h"
54
55class ViewPort;
56class wxDC;
57
58class Segment;
59WX_DECLARE_LIST(Segment, MySegList);
60WX_DECLARE_LIST(MySegList, MySegListList);
61
62//-------------------------------------------------------------------------------------------------------
63// Cohen & Sutherland Line clipping algorithms
64//-------------------------------------------------------------------------------------------------------
65/*
66 *
67 * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
68 *
69 * Authors: Percy Zahl <zahl@users.sf.net>
70 * additional features: Andreas Klust <klust@users.sf.net>
71 * WWW Home: http://gxsm.sf.net
72 *
73 */
74
75typedef enum { Visible, Invisible } ClipResult;
76typedef enum { LEFT, RIGHT, BOTTOM, TOP } edge;
77typedef long outcode;
78
79void CompOutCode(double x, double y, outcode *code,
81#ifdef __cplusplus
82ClipResult cohen_sutherland_line_clip_d(double *x0, double *y0, double *x1,
83 double *y1, double xmin_, double xmax_,
84 double ymin_, double ymax_);
85
86extern "C" ClipResult cohen_sutherland_line_clip_i(int *x0, int *y0, int *x1,
87 int *y1, int xmin_,
88 int xmax_, int ymin_,
89 int ymax_);
90
91#endif
92
93// TODO: join segments and draw a spline
94
95//===============================================================
96// Elément d'isobare qui passe dans un carré (ab-cd)de la grille.
97// a b
98// c d
99// Rejoint l'arête (i,j)-(k,l) à l'arête (m,n)-(o,p) (indices ds la grille GRIB)
100
101class Segment {
102public:
103 Segment(int I, int w, int J, char c1, char c2, char c3, char c4,
104 const GribRecord *rec, double pressure);
105
106 int i, j, k, l; // arête 1
107 double px1, py1; // Coordonées de l'intersection (i,j)-(k,l)
108 int m, n, o, p; // arête 2
109 double px2, py2; // Coordonées de l'intersection (m,n)-(o,p)
110 bool bUsed;
111
112private:
113 void traduitCode(int I, int w, int J, char c1, int &i, int &j);
114
115 void intersectionAreteGrille(int i, int j, int k, int l, double *x, double *y,
116 const GribRecord *rec, double pressure);
117};
118
120class TexFont;
121
122//===============================================================
123class IsoLine {
124public:
125 IsoLine(double val, double coeff, double offset, const GribRecord *rec);
126 ~IsoLine();
127
128 void drawIsoLine(GRIBOverlayFactory *pof, wxDC *dc, PlugIn_ViewPort *vp,
129 bool bHiDef);
130
131 void drawIsoLineLabels(GRIBOverlayFactory *pof, wxDC *dc, PlugIn_ViewPort *vp,
132 int density, int first, wxImage &imageLabel);
133 void drawIsoLineLabelsGL(GRIBOverlayFactory *pof, PlugIn_ViewPort *vp,
134 int density, int first, wxString label,
135 wxColour &color, TexFont &texfont);
136
137 int getNbSegments() { return trace.size(); }
138
139 double getValue() { return value; }
140
141private:
142 double value;
143 int W, H; // taille de la grille
144 const GribRecord *rec;
145
146 wxColour isoLineColor;
147 std::list<Segment *> trace;
148
149 void intersectionAreteGrille(int i, int j, int k, int l, double *x, double *y,
150 const GribRecord *rec);
151
152 //-----------------------------------------------------------------------
153 // Génère la liste des segments.
154 // Les coordonnées sont les indices dans la grille du GribRecord
155 //---------------------------------------------------------
156 void extractIsoLine(const GribRecord *rec);
157 MySegList *BuildContinuousSegment(void);
158
159 MySegList m_seglist;
160 MySegListList m_SegListList;
161
162 double m_pixelMM;
163};
164
165#endif
GRIB (GRIdded Binary) file reader and parser.
Factory class for creating and managing GRIB data visualizations.
Represents a meteorological data grid from a GRIB (Gridded Binary) file.
Definition GribRecord.h:182
Represents the view port for chart display in OpenCPN.
Definition viewport.h:84
PlugIn Object Definition/API.