This file is indexed.

/usr/include/magics/BaseDriver.h is in libmagics++-dev 2.22.7.dfsg.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
/******************************** LICENSE ********************************

 Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 ******************************** LICENSE ********************************/

/*! \defgroup drivers Output drivers

   \section generalDriver Overview

   Magics++ supports various vector and raster output formats. It
   produces a generic descriptions of the output plot which
   than gets converted by a chosen driver to the requested format(s).

   \sa DriverManager::DriverManager(), OutputHandler(), OutputFactory()

   \section usingDrivers Using drivers

   In MagML the \<drivers\> Tag is used to define all drivers being used. Each output
   format

   Example test/MagML/drivers.magml test/C/drivers.c

   \section addDriver How to add a new output format / driver

   It is assumed you try to add a driver called <i>NewDriver</i>.

   - go into the <i>tools</i> directory and run <i>perl newdriver New</i>
   - edit your <i>NewDriver.xml</i> and copy it to <i>src/xml</i>
   - add this file in <i>src/xml/Makefile.am</i>
   - edit <i>NewDriver.cc/.h</i> and copy them to <i>src/drivers/</i>
   - add the new files in <i>src/drivers/Makefile.am</i>
   - look at <i>NewDriver.todo</i> and add factories in:
		-# <i>src/common/OutputHandler.cc</i>
		-# <i>src/common/OutputFactory.cc/.h</i>


\example drivers.c Example how mulitiples drivers can be used in C.
\example drivers.magml Example how drivers can be used in MagML.
*/

/*! \file BaseDriver.h
    \brief Definition of driver base class.
    \author Meteorological Visualisation Section, ECMWF

    Started: Jan 2004

*/
#ifndef MPP_BaseDriver_H
#define MPP_BaseDriver_H

#include <magics.h>
#include <MagTranslator.h>
#include <Colour.h>
#include <BaseDriverAttributes.h>
#include "MagicsObserver.h"

namespace magics{

class Layer;
class SceneLayer;
class StaticLayer;
class NoDataLayer;
class StepLayer;

class Layout;
class SceneLayout;
class LegendLayout;
class StartPage;
class EndPage;
class RootLayout;
class BinaryObject;
class Polyline;
class PolylineSet;
class Text;
class Symbol;
class TextSymbol;
class ClearObject;
class ComplexSymbol;
class TextItem;
class FlagItem;
class SymbolItem;

class Image;
class Arrow;
class Flag;
class ImportObject;
class PaperPoint;

struct ShadingProperties;
struct FillShadingProperties;
struct DotShadingProperties;
struct HatchShadingProperties;

class SelectionMode;
class MtInputEvent;
class PreviewLayout;
class HistoLayout;
class MagnifierLayout;

/*!
 Codes for Brinary reading and writing
*/
#define BINARY_VERSION 2               // last updated with version 2.15.0

typedef double MFloat;


/*!
 \brief helper compare function for string maps

 The function follows the descriptionn of Josuttis's STL book at page 213.
*/
class RuntimeStringCompare
{
	static bool nocase_compare(char c1, char c2) {return toupper(c1)<toupper(c2);}
public:
	RuntimeStringCompare(){}
	bool operator() (const string& s1, const string& s2) const 
	{
		return lexicographical_compare(s1.begin(),s1.end(),s2.begin(),s2.end(),nocase_compare);
	}
};

/*!
 \brief Method to extract points of Polylines
 
 First all possible commas are replaced by spaces and than all points are read through a stream 
*/
inline void parsePoints(vector<PaperPoint> &vPP, string &points)
{
	string::size_type pos = points.find_first_of(",");

	while(pos != string::npos)
	{
		points.replace(pos,1," ",1);
		pos = points.find_first_of(",",pos);
	}

	istringstream totalString(points);
	MFloat x,y;

	while(!totalString.eof())
	{
		totalString >> x >> y;
		PaperPoint pp;
		pp.x(x);
		pp.y(y);
		vPP.push_back(pp);
	}
}

/*!
 \brief struct describing an XML element

 Helper construct for symbol plotting.
*/
struct xmlElement
{
	string name;
	std::map<string, string> attributes;
	xmlElement() : name("") {}
};

/*!
 \brief struct describing an SVG element

 Helper construct for symbol plotting.
*/
struct svgSymbol
{
	string id;
	vector<xmlElement> elements;
	svgSymbol() : id("") {}
};

typedef vector<svgSymbol> vSymbols;

/*!
 \brief struct describing a entry in the font table

 All fonts read in by readFonts() are stored in this way.

 \sa readFonts()
*/
struct magFont
{
	int	id;
	string	magics_name;
	string	ps_name;
	string	ps_filename;
	string	ttf_filename;
	string	css_name;
};


/*! \class BaseDriver
    \brief Base class for all drivers of Magics++.
    \ingroup drivers

    This abstract class provides an interface for Magics
    to call various device drivers.

    Every new driver has to inherit this class and has
    to provide own implementation of abstract members.
*/
class BaseDriver : public BaseDriverAttributes, public MagicsObserver
{
public:
	BaseDriver();
	virtual ~BaseDriver();

	virtual void set(const XmlNode& node)
	{
		BaseDriverAttributes::set(node);
	}
	void setWidth(double width) { width_ = width; }

	virtual void set(const std::map<string, string>& map)
	{
		BaseDriverAttributes::set(map);
	}

	virtual void open() {}
	virtual void close() {}
	void printOutputName(const std::string & str) const; 

	virtual void project(const Layout& ) const {}
	virtual void unproject() const {}

	virtual void newLayer() const { debugOutput("BaseDriver::newLayer");}
	virtual void closeLayer() const { debugOutput("BaseDriver::closeLayer");}
	virtual void newLayer(Layer&) const {debugOutput("BaseDriver::newLayer()");}
	virtual void closeLayer(Layer&) const {debugOutput("BaseDriver::closeLayer()");}
	virtual void newLayer(StaticLayer&) const {debugOutput("BaseDriver::newStaticLayer");}
	virtual void closeLayer(StaticLayer&) const {debugOutput("BaseDriver::closeStaticLayer");}
	virtual void newLayer(StepLayer&) const {debugOutput("BaseDriver::newStepLayer");}
	virtual void closeLayer(StepLayer&) const {debugOutput("BaseDriver::closeStepLayer");}

	intarray frames() const  { return frame_list_; }

	MAGICS_NO_EXPORT void redisplay(const Layout&) const;
	MAGICS_NO_EXPORT void redisplay(const RootLayout&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const LegendLayout&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const SceneLayout&) const;
	MAGICS_NO_EXPORT void redisplay(const StartPage&) const;
	MAGICS_NO_EXPORT void redisplay(const EndPage&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const Layer&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const SceneLayer&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const StaticLayer&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const NoDataLayer&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const StepLayer&) const;
	
	virtual MAGICS_NO_EXPORT void redisplay(const Polyline&) const;
	virtual MAGICS_NO_EXPORT void redisplay(const PolylineSet&) const;

#ifdef MAGICS_QT
	virtual MAGICS_NO_EXPORT void redisplay(const PreviewLayout&) const {};
	virtual MAGICS_NO_EXPORT void redisplay(const HistoLayout&) const {};
	virtual MAGICS_NO_EXPORT void redisplay(const MagnifierLayout&) const {};
#endif
	typedef void (BaseDriver::*ModeFunction)(const SelectionMode&);
	typedef void (BaseDriver::*ControlFunction)(bool);
	typedef void (BaseDriver::*InputEventFunction)(MtInputEvent*);

	virtual void redisplay(const BinaryObject&) const;
	void setDimensionsFromBinary(string mbg_tmpl,MFloat &ratio,int &width) const;

	//! Method to redisplay a Text.
	MAGICS_NO_EXPORT void redisplay(const Text&) const;
	//! Method to redisplay a Symbol.
	MAGICS_NO_EXPORT void redisplay(const Symbol&) const;
	//! Method to redisplay a TextSymbol.
	MAGICS_NO_EXPORT void redisplay(const TextSymbol&) const;
	//! Method to redisplay a ComlpexSymbol.
	void redisplay(const ComplexSymbol&) const;
	void redisplay(const ClearObject&) const;
	void redisplay(const TextItem&, const ComplexSymbol&) const;
	void redisplay(const FlagItem&, const ComplexSymbol&) const;
	void redisplay(const SymbolItem&, const ComplexSymbol&) const;
	
	//! Method to redisplay an Arrow.
	virtual MAGICS_NO_EXPORT void redisplay(const Arrow&) const;
	//! Method to redisplay an Flag.
	virtual MAGICS_NO_EXPORT void redisplay(const Flag&) const;
	//! Method to redisplay a external file.
	void redisplay(const ImportObject&) const;
	//! Method to redisplay a external file.
	MAGICS_NO_EXPORT void redisplay(const Image&) const;

	void shade(const FillShadingProperties&) const;
	void shade(const DotShadingProperties&) const;
	void shade(const HatchShadingProperties&) const;

	bool disable() const { return disabled_; }
	void disable(bool disabled) { disabled_ = disabled; }


	/*!
	 SUPER_PAGE_X_LENGTH Default: 29.7
	*/
	MAGICS_NO_EXPORT void setXDeviceLength(MFloat xdevicelength)
		{ xDeviceLength_ =  xdevicelength; }
	MAGICS_NO_EXPORT MFloat getXDeviceLength() const
		{ return xDeviceLength_; }

	/*!
	 SUPER_PAGE_Y_LENGTH Default: 21.0
	*/
	MAGICS_NO_EXPORT void setYDeviceLength(MFloat ydevicelength)
		{ yDeviceLength_ =  ydevicelength; }
	MAGICS_NO_EXPORT MFloat getYDeviceLength() const
		{ return yDeviceLength_; }


protected:
	MFloat convertCM(const MFloat cm) const {return cm*cmScale_;}
	void setCMscale(const MFloat scale) const {cmScale_ = scale;}

	/*!
	  \brief set Y values positive or negative

	  Some drivers hava a Y axis which is positive towards the bottom of the plot
	  and these need to set this method negative.
	*/
	virtual MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return y;}

	/*!
	  \brief set Y values positive or negative dependent how symbols are interpreted

	*/
	virtual MAGICS_NO_EXPORT MFloat setSymbolY(const MFloat y) const {return y;}

	/*!
	  \brief set Y values positive or negative dependent how angles are interpreted

	  Some drivers hava a angle orientation different to PS
	  and these need to set this method negative.
	*/
        virtual MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return y;}
        virtual MAGICS_NO_EXPORT MFloat setFlagY(const MFloat y) const {return y;}

	string getFileName(const string &extension, const unsigned int no = 0) const;

	//! Method to print string about this class on to a stream of type ostream (virtual).
	virtual void print(ostream&) const;
        virtual void startPage() const{};
        virtual void endPage() const{};
	virtual void setNewColour(const Colour &) const {};
	virtual void printLine(const Polyline &line) const;

	virtual void renderText(const Text &) const {}
	virtual void debugOutput(const string &s) const 
	{
		if(debug_) MagLog::debug() <<" DRIVERS: "<<s<< "\n";
	}

	virtual MFloat projectX(const MFloat x) const {return coordRatioX_*x;}
	virtual MFloat projectY(const MFloat y) const {return coordRatioY_*y;}
		
	string getTmpName() const;

	double LSF(MFloat *x,MFloat *y, int i0) const;

	mutable int	currentPage_;
	mutable string	fileName_;
	mutable string	currentLayer_;  // from Layer (open & close)

	mutable LineStyle currentLineType_;
	mutable MFloat	currentLineWidth_;
	mutable int	currentLineStyle_;
	mutable Colour	currentColour_;

	mutable MFloat	coordRatioX_;
	mutable MFloat	coordRatioY_;
	mutable MFloat	dimensionX_;
        mutable MFloat	dimensionY_;
        mutable MFloat	offsetX_;
        mutable MFloat	offsetY_;

	mutable std::stack<MFloat>  dimensionStack_;
	mutable std::stack<MFloat>  scalesX_;
	mutable std::stack<MFloat>  scalesY_;

//	mutable MFloat	lastAreaHeightPercentage_;
//	mutable MFloat	lastAreaWidthPercentage_;
	mutable bool	newPage_;
//	mutable bool	firstPage_;
//	mutable	bool	newLayout_;
//	mutable	bool    external_;
//	mutable bool    polylineAntialiasing_;

	bool    disabled_;
	bool    alphaEnabled_;
	mutable vSymbols  sym_;

	virtual MAGICS_NO_EXPORT void setNewLineWidth(const MFloat w) const {currentLineWidth_ = w;}
	MAGICS_NO_EXPORT MFloat getNewLineWidth() const {return currentLineWidth_;}

	//! Load svg symbols from file
	void loadSymbols() const;

	virtual MAGICS_NO_EXPORT void renderTextSymbols(const TextSymbol& symbol) const;
	
	virtual void renderComplexSymbols(const ComplexSymbol& symbol) const;
	virtual void renderTextItem(const TextItem&, const ComplexSymbol&) const;
	virtual void renderFlagItem(const FlagItem&, const ComplexSymbol& symbol) const;
	virtual void renderSymbolItem(const SymbolItem&, const ComplexSymbol& symbol) const;
	virtual void renderSymbols(const Symbol& symbol) const;
	virtual void renderPolyline(const int, MFloat *, MFloat *) const {};
	virtual void renderPolyline2(const int, MFloat *, MFloat *) const {}
	void renderPolyline(vector<PaperPoint> &vP) const;
	void renderPolyline2(vector<PaperPoint> &vP) const;

	virtual MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const = 0;
	virtual MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const = 0;
	virtual void circle(const MFloat, const MFloat, const MFloat, const int) const {}
	virtual MAGICS_NO_EXPORT int setLineParameters(const LineStyle st, const MFloat w) const {currentLineType_=st; setNewLineWidth(w);return 0;}

	// Filling calculating methods
	// PolylineSets rendering methods
	//MAGICS_NO_EXPORT void renderPolylineSets(const PolylineSet<PaperPoint>&) const;
	mutable unsigned int indexHatch_;
	mutable Shading   currentShading_;
	mutable const ShadingProperties *currentShadingProperties_;

        // wind calculating methods (overridden in Binary)
        virtual MAGICS_NO_EXPORT void renderWindArrow(const Arrow &arrow) const;
        virtual MAGICS_NO_EXPORT void renderWindFlag(const Flag &flag) const;

	// images + bitmap methods
	virtual void renderImage(const ImportObject& object) const;
	MAGICS_NO_EXPORT void renderImage(const Image& obj) const {renderCellArray(obj);}
        virtual MAGICS_NO_EXPORT bool convertToPixmap(const string &fname, const GraphicsFormat format, const int reso,
	             const MFloat wx0, const MFloat wy0,const MFloat wx1,const MFloat wy1) const;
	virtual MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool hasAlpha=false) const;
	virtual MAGICS_NO_EXPORT bool renderCellArray(const Image& ) const;

	mutable std::map<string, magFont, RuntimeStringCompare> FontMap_;
	typedef std::map<string, magFont, RuntimeStringCompare>::const_iterator fontMapIter;

	void terminate() const {exit(1);}

	void readFonts() const;
	void relieveFonts() const {FontMap_.clear();}

private:
	mutable MFloat cmScale_;
	MFloat xDeviceLength_;
	MFloat yDeviceLength_;
	static int numFiles_;
	mutable double obs_distance_;
	mutable stack<const Layout *>  staLayouts_;
	mutable vector<const PaperPoint *>  vecPoints_;
	bool checkDistanceMoreThan(const PaperPoint *pp, double distance) const;
	void renderSimplePolygon(vector<PaperPoint> &vP) const;
	void snowflake(const MFloat, const MFloat, const MFloat) const;
	void drizzle(const MFloat, const MFloat, const MFloat) const;
	void triangle(const MFloat, const MFloat, const MFloat, const int, const int) const;
	void lightning(const MFloat x, const MFloat y, const MFloat size) const;

	//! Copy constructor - No copy allowed
	BaseDriver(const BaseDriver&);
	//! Overloaded << operator to copy - No copy allowed
	BaseDriver& operator=(const BaseDriver&);

// -- Friends
	//! Overloaded << operator to call print().
	friend ostream& operator<<(ostream& s,const BaseDriver& p) { p.print(s); return s; }
};

/*!
 \brief translates a string to a driver
*/
template<>
class MagTranslator<string, BaseDriver>
{
public:
	MAGICS_NO_EXPORT BaseDriver* operator()(const string& val )
	{
		 return SimpleObjectMaker<BaseDriver>::create(val);
	}
	MAGICS_NO_EXPORT BaseDriver* magics(const string& param)
	{
		BaseDriver* object;
		ParameterManager::update(param, object);
		return object;
	}
};

} // namespace magics
#endif