UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
zqb_lith_engine.hpp
1 /* zqb_lith_engine.hpp */
2 /* $Id: zqb_lith_engine.hpp,v 1.3 2006/10/26 12:24:58 kayo Exp $ */
3 #ifndef __zqb_lith_engine_hpp
4 #define __zqb_lith_engine_hpp
5 
8 #include <fstream>
9 
10 #include <math.h>
11 #include <string>
12 
13 #include <qnamespace.h>
14 #include <qcolor.h>
15 #include <qrect.h>
16 #include <qpoint.h>
17 #include <qpen.h>
18 #include <qbrush.h>
19 #include <qpainter.h>
20 #include <qfont.h>
21 #include <qpixmap.h>
22 #include <qsize.h>
23 #include <qbitmap.h>
24 
25 using namespace std;
26 
28 #define LITH_PAT_SCALE 0.1
29 
30 #define LITH_LP_FILENAME "LithBase.lp"
32 /*****************************************************************************************
33  *
34  * General definitions.
35  *
36  */
37 
38 /*********************************************************************
39  *
40  * Logical constants
41  *
42  */
43 
44 enum hcp_Logic
45  {
46  hcpL_FALSE = 0, // Logical "FALSE"
47  hcpL_TRUE // Logical "TRUE"
48  };
49 
50 /*********************************************************************
51  *
52  * Routine status (kind of return code)
53  *
54  */
55 
56 enum hcp_Status
57  {
58  // Common return codes {
59  hcpS_VOID = 0, // Void or dummy return code
60  hcpS_OK = 1, // Normal return code (all is OK)
61  hcpS_BAD = 2, // Something wrong !
62 
63  hcpS_BAD_PARAMETER = 100, // Bad parameter value
64  // Common return codes }
65 
66  // Alien routines return codes {
67  hcpS_BAD_CREATE_ENHANCED = 200, // Bad return code of CreateEnhanced routine
68  hcpS_BAD_CLOSE_ENHANCED = 201, // Bad return code of CloseEnhanced routine
69  // Alien routines return codes }
70 
71  // File stream i/o routines return codes {
72  hcpS_FSIO_UNKNOWN = 300, // Unknown file stream status
73 
74  hcpS_FSIO_BAD_OPEN_FILE = 301, // Bad return code of open file routine
75  hcpS_FSIO_BAD_FILE_DATA = 302, // Bad or incorrect file data
76 
77  hcpS_FSIO_GOODBIT = 303, // No error condition
78  hcpS_FSIO_EOFBIT = 304, // End of file reached
79  hcpS_FSIO_FAILBIT = 305, // A possibly recoverable formatting or conversion error
80  hcpS_FSIO_BADBIT = 306 // A severe i/o error or unknown state
81  // File stream i/o routines return codes {
82  };
83 
84 /*********************************************************************
85  *
86  * Size units
87  *
88  */
89 
90 enum hcp_Units
91  {
92  hcpU_DEFAULT = 0, // Default units (defined by user)
93  hcpU_MILLIMETERS, // Millimeters
94  hcpU_INCHES // Inches
95  };
96 
97 /*
98  * Auxiliary routines
99  */
100 
101 /*********************************************************************
102  *
103  * Units conversion tool
104  *
105  */
106 
107 hcp_Status hcp_aux_ConvertUnits (hcp_Units, int &);
108 
109 /*********************************************************************
110  *
111  * Bounding rectangle units conversion
112  *
113  */
114 
115 hcp_Status hcp_aux_BoundsUnitsConvert (hcp_Units, QRect *);
116 
117 /*********************************************************************
118  *
119  * Searching minimal and maximal vector values
120  *
121  */
122 
123 hcp_Status hcp_aux_SearchVectMinMax (int n, float *, float &, float &);
124 
125 /*****************************************************************************************
126  *
127  * Picture object definitions.
128  *
129  */
130 
131 /*********************************************************************
132  *
133  * Picture object configuration
134  *
135  */
136 
137 typedef struct
138 {
139  std::string pict_filename; // Picture filename
140  std::string pict_desc; // Picture description
141 
142  hcp_Units pict_units; // Picture size units
143 
144  int pict_width; // Picture width
145  int pict_height; // Picture height
146 
147  hcp_Logic enable_frame; // Enable bounding frame
148  hcp_Logic transp_backgr; // Enable transparent background (dummy if enable_frame value is hcpL_FALSE)
149 
151 
152 /*********************************************************************
153  *
154  * Picture object
155  *
156  */
157 
159 {
160 
161 private:
162 
163  hcp_PictConfig pict_config; // Current configuration of picture object
164 
165 public:
166 
167  hcp_Status Config (hcp_PictConfig *); // Configure picture object
168 
169  //hcp_Status CreatePicture (HDC, CMetaFileDC *) const; // Create new picture with current configuration
170  //hcp_Status ClosePicture (CMetaFileDC *) const; // Close current picture
171 
172 };
173 
174 /*****************************************************************************************
175  *
176  * Lithology object definitions.
177  *
178  */
179 
180 /*********************************************************************
181  *
182  * Lithology commands
183  *
184  */
185 
186 #define hcp_MAX_LCMD_LENGTH 50 // Maximal amount of chars in lithology command
187 
188 #define hcp_MAX_LOCALIZ_LENGTH 3 // Maximal amount of chars in localization name
189 #define hcp_MAX_PATTERN_DESC_LENGTH 50 // Maximal amount of chars in current localization of lithology pattern name
190 
191 // System commands {
192 #define hcp_LCMD_PATTERN_ID "LithPattern" // Lithology pattern identification [int]
193 
194 #define hcp_LCMD_START_PATTERN "StartPattern" // Start of lithology pattern body block []
195 #define hcp_LCMD_END_PATTERN "EndPattern" // End of lithology pattern body block []
196 
197 #define hcp_LCMD_PATTERN_DESC_ID "LithPatternDesc" // Start of lithology pattern description block [int]
198 #define hcp_LCMD_END_PATTERN_DESC "EndPatternDesc" // End of lithology pattern description block []
199 // System commands }
200 
201 // Lithology pattern configuration {
202 #define hcp_LCMD_PATTERN_WIDTH "PatternWidth" // Lithology pattern width [int]
203 #define hcp_LCMD_PATTERN_HEIGHT "PatternHeight" // Lithology pattern height [int]
204 // Lithology pattern configuration }
205 
206 // Base graphic primitives {
207 #define hcp_LCMD_POINT "Point" // Draw point [int,int, int, int, int,int,int]
208 #define hcp_LCMD_LINE "Line" // Draw line [int,int, int,int, int, int,int,int]
209 #define hcp_LCMD_ARC "Arc" // Draw arc [int,int, int,int, float,float, int, int,int,int]
210 // Base graphic primitives }
211 
212 // Lithology pattern description commands {
213 #define hcp_LCMD_PATTERN_NAME "PatternName" // Lithology pattern name in specified localization [char[hcp_MAX_LOCALIZ_LENGTH], char[hcp_MAX_PATTERN_DESC_LENGHT]]
214 // Lithology pattern description commands }
215 
216 /*********************************************************************
217  *
218  * Lithology object data configuration
219  *
220  */
221 
222 typedef struct
223 {
224  std::string lp_filename; // Lithology patterns data file
225  std::string lpd_filename; // Lithology patterns description file
226 
227  float ptrn_scale; // Lithology pattern scale
228 
230 
231 /*********************************************************************
232  *
233  * Lithology pattern configuration
234  *
235  */
236 
237 typedef struct
238 {
239  int ptrn_width; // Lithology pattern width
240  int ptrn_height; // Lithology pattern height
241 
243 
244 /*********************************************************************
245  *
246  * Lithology pattern description
247  *
248  */
249 
250 typedef struct
251 {
252  char *localization; // Localization name
253  char *ptrn_name; // Lithology pattern name in current localization
254 
256 
257 /*********************************************************************
258  *
259  * Lithology legend styles
260  *
261  */
262 
263 enum hcp_LegendStyle
264  {
265  hcpLS_HORIZONTAL = 0, // Horizontal lithology legend
266  hcpLS_VERTICAL, // Vertical lithology legend
267  hcpLS_BOX, // Box like lithology legend
268  hcpLS_MANUAL // User style lithology legend
269  };
270 
271 /*********************************************************************
272  *
273  * Lithology legend configuration
274  *
275  */
276 
277 typedef struct
278 {
279  hcp_LegendStyle legend_style; // Lithology legend drawing style
280 
281  int element_step_x; // Lithology legend elements step by X axis
282  int element_step_y; // Lithology legend elements step by Y axis
283 
284  int element_width; // Lithology legend elements width
285  int element_height; // Lithology legend elements height
286 
287  const char *font_family; // Font family
288 
290 
291 /*********************************************************************
292  *
293  * Lithology object
294  *
295  */
296 
297 class hcp_Lith
298 {
299 
300 private:
301 
302  hcp_LithDataConfig lith_data_config; // Current lithology object data configuration
303 
304  // Auxiliary
305  hcp_Status aux_IFStream (ifstream *) const; // In-file stream status check
306  hcp_Status aux_FindNext (ifstream *, char*) const; // Find next lithology command in file
307 
308 public:
309 
310  // Configuration
311  hcp_Status AttachLithData (hcp_LithDataConfig *); // Attach new lithology data
312 
313  // Lithology patterns {
314  hcp_Status LithPtrnExist (int) const; // Lithology pattern existence
315  hcp_Status ConfigLithPtrn (int, hcp_LithPtrnConfig *) const; // Configure lithology pattern
316  hcp_Status LocalizeLithPtrn (int, char*, char*) const; // Localize lithology pattern
317 
318  hcp_Status DrawLithPtrnDesc (QPainter *, char [],
319  int, int, int, const char *) const; // Draw lithology pattern description
320 
321  hcp_Status DrawFluid (QPainter *, hcp_Units, QRect *, // Draw fluid
322  int) const;
323  hcp_Status DrawLithPtrn (QPainter *, hcp_Units, int,int, // Draw lithology pattern
324  int, QRect *, hcp_Logic) const;
325 
326  hcp_Status Fill (QPainter *, hcp_Units, int, QRect *, hcp_Logic) const; // Fill rectangle by specified lithology pattern
327  // Lithology patterns }
328 
329 };
330 
331 /*
332  * Exported lithology routines
333  */
334 
335 /*********************************************************************
336  *
337  * Create new file with lithology
338  *
339  */
340 
341 hcp_Status hcp_core_NewLithology (QPainter *, hcp_PictConfig *, hcp_LithDataConfig *,
342  int, int, int,
343  int, float *, float *, int *, int *, int *,
344  float, float);
345 
346 /*********************************************************************
347  *
348  * Create new file with lithology legend
349  *
350  */
351 
352 hcp_Status hcp_core_NewLegend (QPainter *, hcp_PictConfig *,
354  int, int *, char [], int);
355 
356 /*********************************************************************
357  *
358  * Localize one lithology pattern
359  *
360  */
361 
362 hcp_Status hcp_core_LocalizeLithPtrn (hcp_LithDataConfig *, int, char [], char []);
363 
364 /*****************************************************************************************
365  *
366  * Graphic definitions.
367  *
368  */
369 
370 #define hcp_PI 3.1415926535897 // Pi constant
371 #define hcp_ARC_APPROX 10.0 // Arc aproximation constant
372 
373 /*********************************************************************
374  *
375  * Point styles
376  *
377  */
378 
379 enum hcp_PointStyle
380  {
381  hcpPS_SQUARE = 0, // Square point
382  hcpPS_ELLIPTIC // Elliptic point (most similar point emulation)
383  };
384 
385 /*********************************************************************
386  *
387  * Point configuration
388  *
389  */
390 
391 typedef struct
392 {
393  int pnt_width; // Point width (!) Warning: this value has no units conversion
394  QColor pnt_color; // Point color
395 
396  hcp_PointStyle pnt_style; // Point style
397 
399 
400 /*********************************************************************
401  *
402  * Line configuration
403  *
404  */
405 
406 typedef struct
407 {
408  int line_width; // Line width
409  QColor line_color; // Line color
410 
412 
413 /*
414  * Base graphic primitives
415  */
416 
417 /*********************************************************************
418  *
419  * Point
420  *
421  */
422 
423 hcp_Status hcp_Point (QPainter *, QRect *, int, int, hcp_Units, hcp_PointConfig *, hcp_Logic);
424 
425 /*********************************************************************
426  *
427  * Line
428  *
429  */
430 
431 hcp_Status hcp_Line (QPainter *, QRect *, int, int, int, int, hcp_Units, hcp_LineConfig *, hcp_Logic);
432 
433 /*********************************************************************
434  *
435  * Arc
436  *
437  */
438 
439 hcp_Status hcp_Arc (QPainter *, QRect *, QRect *, double, double, hcp_Units, hcp_LineConfig *, hcp_Logic);
440 
441 /*
442  * Auxiliary graphic routines.
443  */
444 
445 /*********************************************************************
446  *
447  * Searching intersection point of bounding rectangle and line
448  *
449  */
450 
451 hcp_Status hcp_graux_BoundsIntersect (QRect *, double, double, double, double, double &, double &);
452 
453 /*********************************************************************
454  *
455  * Searching all intersection points of bounding rectangle and line
456  *
457  */
458 
459 hcp_Status hcp_graux_BoundsAllIntersect (QRect *, double, double, double, double, double &, double &, double &, double &);
460 
465 class
467 {
468 public:
469 
470  hcp_Lith hcpLith;
471  hcp_Status rStatus;
472  hcp_LithPtrnConfig rLithPtrnConfig;
473  hcp_LithDataConfig rLithDataConfig;
474 
476  ZqbLithEngine (const char *lp_filename_s, const char *lpd_filename_s, float scale_factor);
477 
479  QBitmap* getRaster (int lith_code);
480 };
481 
482 #endif /* zqb_lith_engine.hpp */
Definition: zqb_lith_engine.hpp:222
Definition: zqb_lith_engine.hpp:250
Definition: zqb_lith_engine.hpp:158
Definition: zqb_lith_engine.hpp:137
Definition: zqb_lith_engine.hpp:465
Definition: zqb_lith_engine.hpp:277
Definition: zqb_lith_engine.hpp:391
Definition: zqb_lith_engine.hpp:237
Definition: zqb_lith_engine.hpp:406
Definition: zqb_lith_engine.hpp:297