OpendTect  6.6
gmtpar.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Raman Singh
8  Date: July 2008
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "gmtmod.h"
15 
16 #include "gmtdef.h"
17 #include "iopar.h"
18 #include "manobjectset.h"
19 #include "od_ostream.h"
20 #include "oscommand.h"
21 #include "uistring.h"
22 
23 
25 {
26 public:
27  GMTPar( const IOPar& par, const char* workdir )
28  : IOPar(par),workingdir_(workdir) {}
29 
30  bool execute(od_ostream&,const char*);
31 
32  virtual const char* userRef() const = 0;
33  virtual bool fillLegendPar(IOPar&) const { return false; }
34 
35  bool execCmd(const OS::MachineCommand&,od_ostream& logstrm,
36  const char* fnm=nullptr,bool append=true);
38  od_ostream& logstrm,
39  const char* fnm=nullptr,bool append=true);
40 
43 
44  const char* getWorkDir() const { return workingdir_.buf(); }
45 
46 private:
47 
48  virtual bool doExecute(od_ostream&,const char*) = 0;
49  static void checkErrStrm(const char*,od_ostream&);
50 
52 
53 };
54 
55 
56 typedef GMTPar* (*GMTParCreateFunc)(const IOPar&,const char*);
57 
59 {
60 public:
61 
62  int add(const char* nm, GMTParCreateFunc);
63  GMTPar* create(const IOPar&,const char* workdir) const;
64 
65  const char* name(int) const;
66  int size() const { return entries_.size(); }
67 
68 protected:
69 
70  mStruct(GMT) Entry
71  {
72  Entry( const char* nm,
73  GMTParCreateFunc fn )
74  : name_(nm)
75  , crfn_(fn) {}
76 
77  BufferString name_;
78  GMTParCreateFunc crfn_;
79  };
80 
82 
83  Entry* getEntry(const char*) const;
84 
86 };
87 
89 
90 
91 #define mErrStrmRet(s) { strm << s << '\n'; return false; }
92 
93 #define mGetRangeString( str ) \
94  Interval<float> xrg, yrg, mapdim; \
95  get( ODGMT::sKeyXRange(), xrg ); \
96  get( ODGMT::sKeyYRange(), yrg ); \
97  str = "-R"; str += xrg.start; str += "/"; \
98  str += xrg.stop; str += "/"; \
99  str += yrg.start; str += "/"; str += yrg.stop;
100 
101 #define mGetProjString( str, projkey ) \
102  Interval<float> dim; \
103  get( ODGMT::sKeyMapDim(), dim ); \
104  str += "-J"; str += projkey; str += dim.start; str += "c/"; \
105  str += dim.stop; str += "c";
106 
107 #define mGetColorString( col, str ) \
108  str = (int) col.r(); \
109  str += "/"; str += (int) col.g(); \
110  str += "/"; str += (int) col.b();
111 
112 #define mGetLineStyleString( ls, str ) \
113  str = ls.width_; str += "p,"; \
114  BufferString lscol; \
115  mGetColorString( ls.color_, lscol ); \
116  str += lscol; str += ","; \
117  switch ( ls.type_ ) \
118  { \
119  case OD::LineStyle::Dash: \
120  str += "-"; \
121  break; \
122  case OD::LineStyle::Dot: \
123  str += "."; \
124  break; \
125  case OD::LineStyle::DashDot: \
126  str += "-."; \
127  break; \
128  case OD::LineStyle::DashDotDot: \
129  str += "-.."; \
130  break; \
131  default: break; \
132  }
133 
GMT
Definition: initgmtplugin.h:17
GMTPar::doExecute
virtual bool doExecute(od_ostream &, const char *)=0
gmtdef.h
GMTPar::getWorkDir
const char * getWorkDir() const
Definition: gmtpar.h:44
GMTParFactory::entries_
ManagedObjectSet< Entry > entries_
Definition: gmtpar.h:79
uistring.h
mGlobal
#define mGlobal(module)
Definition: commondefs.h:180
GMTPF
GMTParFactory & GMTPF()
GMTParFactory::getEntry
Entry * getEntry(const char *) const
od_ostream.h
GMTParFactory::name
const char * name(int) const
GMTPar::getErrFnm
static BufferString getErrFnm()
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
GMTPar::GMTPar
GMTPar(const IOPar &par, const char *workdir)
Definition: gmtpar.h:27
GMTPar::checkErrStrm
static void checkErrStrm(const char *, od_ostream &)
GMTPar::execCmd
bool execCmd(const OS::MachineCommand &, od_ostream &logstrm, const char *fnm=nullptr, bool append=true)
ManagedObjectSet< Entry >
mStruct
#define mStruct(module)
Definition: commondefs.h:182
GMTPar::execute
bool execute(od_ostream &, const char *)
GMTParFactory::add
int add(const char *nm, GMTParCreateFunc)
GMTPar::getWrappedComm
static OS::MachineCommand getWrappedComm(const OS::MachineCommand &)
GMTPar::fillLegendPar
virtual bool fillLegendPar(IOPar &) const
Definition: gmtpar.h:33
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
GMTParFactory::size
int size() const
Definition: gmtpar.h:66
OS::MachineCommand
Encapsulates an actual command to execute + the machine to run it on.
Definition: oscommand.h:94
GMTParCreateFunc
GMTPar *(* GMTParCreateFunc)(const IOPar &, const char *)
Definition: gmtpar.h:56
manobjectset.h
append
bool append(OD::ValVec< T, IT > &to, const OD::ValVec< S, J > &from)
append allowing a different type to be merged into set
Definition: typeset.h:239
iopar.h
GMTParFactory::GMTPF
friend GMTParFactory & GMTPF()
GMTParFactory::create
GMTPar * create(const IOPar &, const char *workdir) const
GMTParFactory
Definition: gmtpar.h:59
GMTPar
Definition: gmtpar.h:25
od_ostream
OD class for stream write common access to the user log file, or std::cout in other than od_main.
Definition: od_ostream.h:26
GMTPar::workingdir_
BufferString workingdir_
Definition: gmtpar.h:51
oscommand.h
GMTPar::userRef
virtual const char * userRef() const =0
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
GMTPar::makeOStream
od_ostream makeOStream(const OS::MachineCommand &, od_ostream &logstrm, const char *fnm=nullptr, bool append=true)

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021