OpendTect  6.3
uiodstratlayermodelmgr.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: Prajjaval Singh
8  Date: Jan 2017
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "uistratlayermodel.h"
14 
15 #include "dbman.h"
16 #include "separstr.h"
17 #include "settings.h"
18 #include "stratlayseqgendesc.h"
19 #include "stratlayermodel.h"
20 #include "stratlaygen.h"
21 #include "strattransl.h"
22 #include "stratlaymodgen.h"
23 #include "stratreftree.h"
24 #include "stratsynth.h"
25 #include "uichecklist.h"
26 #include "uilistbox.h"
27 #include "uimsg.h"
28 #include "uiodmain.h"
29 #include "uiselsimple.h"
31 #include "uistratlaymodtools.h"
33 #include "uistratsynthcrossplot.h"
34 #include "uistrattreewin.h"
35 #include "uistrings.h"
36 
37 
40 public:
41 
43  : dlg_(0)
44 {
47 }
48 
49 
51 {
52  if ( dlg_ )
53  dlg_->saveGenDescIfNecessary( false );
54  delete dlg_; dlg_ = 0;
55 }
56 
58 {
60  dlg_ = 0;
61 }
62 
63 void startCB( CallBacker* cb )
64 {
65  if ( haveExistingDlg() )
66  return;
67  const uiStringSet& usrnms =
68  uiLayerSequenceGenDesc::factory().getUserNames();
69  const BufferStringSet& nms = uiLayerSequenceGenDesc::factory().getNames();
71  if ( Strat::RT().isEmpty() || nms.isEmpty() )
72  { pErrMsg("Pre-condition not met"); return; }
73 
74  uiParent* par = tb ? tb->parent() : ODMainWin();
75  const char* settres = Settings::common().find(
77  BufferString modnm( settres );
78  int defmodnr = -1;
79  bool givechoice = nms.size() > 1;
80  if ( modnm.isEmpty() )
81  modnm = *nms.last();
82  else
83  {
84  FileMultiString fms( modnm );
85  modnm = fms[0];
86  defmodnr = nms.indexOf( modnm.buf() );
87  if ( defmodnr < 0 )
88  modnm.setEmpty();
89  else
90  {
91  const bool alwayswant = fms.size() > 1 && *fms[1] == 'A';
92  givechoice = givechoice && !alwayswant;
93  }
94  }
95 
96  if ( givechoice )
97  {
98  uiSelectFromList::Setup sflsu( tr("Select modeling type"), usrnms );
99  sflsu.current( defmodnr < 0 ? nms.size()-1 : defmodnr );
100  uiSelectFromList dlg( par, sflsu );
101  uiCheckList* defpol = new uiCheckList( &dlg, uiCheckList::Chain1st,
102  OD::Horizontal );
103  defpol->addItem( tr("Set as default") )
104  .addItem( tr("Always use this type") );
105  defpol->setChecked( 0, defmodnr >= 0 );
106  defpol->attach( centeredBelow, dlg.selFld() );
107  if ( !dlg.go() ) return;
108 
109  const int sel = dlg.selection();
110  if ( sel < 0 ) return;
111  const BufferString newmodnm = nms.get( sel );
112  int indic = defpol->isChecked(0) ? (defpol->isChecked(1) ? 2 : 1) : 0;
113  bool needwrite = true;
114  if ( indic == 0 )
115  {
116  if ( defmodnr < 0 )
117  needwrite = false;
118  else
121  }
122  else
123  {
124  if ( indic == 2 || defmodnr < 0 || modnm != newmodnm )
125  {
127  BufferString(newmodnm, indic == 2 ? "`Always" : "") );
128  }
129  else if ( defmodnr >= 0 )
130  needwrite = false;
131  }
132 
133  if ( needwrite )
134  Settings::common().write( false );
135  modnm = newmodnm;
136  }
137  doLayerModel( modnm, 0 );
138 }
139 
141 {
142  if ( dlg_ )
143  {
144  uiMSG().error(tr("Please exit your other layer modeling window first"));
145  dlg_->raise();
146  return true;
147  }
148  return false;
149 }
150 
151 void launchLayerModel( const char* modnm, int opt )
152 {
153  if ( haveExistingDlg() || Strat::RT().isEmpty() )
154  return;
155 
156  dlg_ = new uiStratLayerModel( ODMainWin(), modnm, opt );
157  if ( !dlg_->moddisp_ )
158  { delete dlg_; dlg_ = 0; }
159  else
160  {
163  dlg_->go();
164  }
165 }
166 
168 {
169  uiToolButtonSetup* su = new uiToolButtonSetup( "stratlayermodeling",
170  tr("Start layer/synthetics modeling"),
173 }
174 
176 
177 
178 
180 {
182  return theinst;
183 }
184 
185 static void initClass()
186 {
188 }
189 
190 
191 static void doLayerModel( const char* modnm, int opt )
192 {
193  if ( Strat::RT().isEmpty() )
194  StratTreeWin().popUp();
195  else
196  uislm_manager().launchLayerModel( modnm, opt );
197 }
198 
199 static void doBasicLayerModel()
200 {
202 }
203 
204 };
uiStratTreeWin & StratTreeWin()
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
bool write(bool read_before=true) const
void attach(constraintType t, int margin=-1)
Definition: uiparent.h:53
void addToTreeWin()
Definition: uiodstratlayermodelmgr.h:167
void raise()
static void makeEditable(bool allow)
bool saveGenDescIfNecessary(bool allowcancel=true) const
static const char * sKeyModeler2Use()
static void addTool(uiToolButtonSetup *)
becomes mine
Group of check boxes. Ensures a certain policy is honored.
Definition: uichecklist.h:32
#define mDefineStaticLocalObject(type, var, init)
Definition: commondefs.h:199
Definition: uiselsimple.h:30
BufferString & setEmpty()
BufferString & get(size_type idx)
Definition: bufstringset.h:49
Definition: uichecklist.h:37
static void initClass()
Definition: uiodstratlayermodelmgr.h:185
Definition: oduicommon.h:23
Definition: uiparent.h:24
Set of BufferString objects.
Definition: bufstringset.h:25
int go()
uiListBox * selFld()
Definition: uiselsimple.h:56
int size() const
static void doBasicLayerModel()
Definition: uiodstratlayermodelmgr.h:199
uiCheckList & addItem(const uiString &txt, const char *iconfnm=0)
SeparString with backquotes as separators, use in most ascii files.
Definition: separstr.h:131
bool haveExistingDlg()
Definition: uiodstratlayermodelmgr.h:140
void survChg(CallBacker *)
Definition: uiodstratlayermodelmgr.h:50
Definition: uitoolbutton.h:74
Definition: uilayout.h:24
void go()
Definition: uistratlayermodel.h:45
void removeWithKey(const char *key)
uiMsg & uiMSG()
DBMan & DBM()
#define mCB(obj, clss, fn)
To make your CallBack. Used in many places, especially the UI.
Definition: callback.h:41
const char * find(const char *) const
returns null if not found
int selection() const
-1 = no selection made (cancelled or 0 list items)
Definition: uiselsimple.h:53
Definition: uiodstratlayermodelmgr.h:38
void startCB(CallBacker *cb)
Definition: uiodstratlayermodelmgr.h:63
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:123
Select entry from list.
Definition: uiselsimple.h:26
const char * buf() const
Definition: odstring.h:45
Notifier< DBMan > surveyToBeChanged
Before the change.
Definition: dbman.h:71
size_type indexOf(const char *) const
first match
static uiStratLayerModelManager & uislm_manager()
Definition: uiodstratlayermodelmgr.h:179
Notifier< DBMan > applicationClosing
&#39;Final&#39; call ...
Definition: dbman.h:74
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
bool isChecked(int) const
bool isEmpty() const
Definition: odstring.h:49
bool isEmpty(const char *)
uiStratLayerModelDisp * moddisp_
Definition: uistratlayermodel.h:94
uiODMain * ODMainWin()
Top-level access for plugins.
void popUp() const
const RefTree & RT()
bool isEmpty() const
Definition: bufstringset.h:38
Definition: uitoolbutton.h:20
uiStratLayerModel * dlg_
Definition: uiodstratlayermodelmgr.h:175
Definition: uistring.h:235
size_type size() const
Definition: bufstringset.h:37
void winClose(CallBacker *)
Definition: uiodstratlayermodelmgr.h:57
static Settings & common()
Definition: settings.h:36
mODTextTranslationClass(uiStratLayerModelManager)
static const char * typeStr()
Definition: uistratbasiclayseqgendesc.h:29
#define pErrMsg(msg)
Usual access point for programmer error messages.
Definition: errmsg.h:34
void set(const char *ky, const char *val)
Definition: uistratlayermodel.h:36
static void doLayerModel(const char *modnm, int opt)
Definition: uiodstratlayermodelmgr.h:191
uiCheckList & setChecked(int, bool)
Notifier< uiMainWin > windowClosed
triggered when window exits
Definition: uimainwin.h:130
BufferString * last()
Definition: bufstringset.h:53
uiStratLayerModelManager()
Definition: uiodstratlayermodelmgr.h:42
void notify(const CallBack &, bool first=false) const
bool error(const uiString &, const uiString &part2=uiString::emptyString(), const uiString &part3=uiString::emptyString(), bool withdontshowagain=false)
void launchLayerModel(const char *modnm, int opt)
Definition: uiodstratlayermodelmgr.h:151

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