tesseract
v4.0.0-17-g361f3264
Open Source OCR Engine
paramsd.h
1
// File: paramsd.h
3
// Description: Tesseract parameter editor
4
// Author: Joern Wanke
5
// Created: Wed Jul 18 10:05:01 PDT 2007
6
//
7
// (C) Copyright 2007, Google Inc.
8
// Licensed under the Apache License, Version 2.0 (the "License");
9
// you may not use this file except in compliance with the License.
10
// You may obtain a copy of the License at
11
// http://www.apache.org/licenses/LICENSE-2.0
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17
//
19
//
20
// Tesseract parameter editor is used to edit all the parameters used
21
// within tesseract from the ui.
22
#ifndef TESSERACT_CCMAIN_PARAMSD_H_
23
#define TESSERACT_CCMAIN_PARAMSD_H_
24
25
#ifndef GRAPHICS_DISABLED
26
27
#include "elst.h"
// for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
28
#include "scrollview.h"
// for ScrollView (ptr only), SVEvent (ptr only)
29
#include "strngs.h"
// for STRING
30
31
class
SVMenuNode
;
32
33
namespace
tesseract
{
34
class
BoolParam;
35
class
DoubleParam;
36
class
IntParam;
37
class
StringParam;
38
class
Tesseract;
39
}
40
41
// A list of all possible parameter types used.
42
enum
ParamType {
43
VT_INTEGER,
44
VT_BOOLEAN,
45
VT_STRING,
46
VT_DOUBLE
47
};
48
49
// A rather hackish helper structure which can take any kind of parameter input
50
// (defined by ParamType) and do a couple of common operations on them, like
51
// comparisond or getting its value. It is used in the context of the
52
// ParamsEditor as a bridge from the internal tesseract parameters to the
53
// ones displayed by the ScrollView server.
54
class
ParamContent
:
public
ELIST_LINK
{
55
public
:
56
// Compare two VC objects by their name.
57
static
int
Compare(
const
void
* v1,
const
void
* v2);
58
59
// Gets a VC object identified by its ID.
60
static
ParamContent
* GetParamContentById(
int
id
);
61
62
// Constructors for the various ParamTypes.
63
ParamContent
() =
default
;
64
explicit
ParamContent
(
tesseract::StringParam
* it);
65
explicit
ParamContent
(
tesseract::IntParam
* it);
66
explicit
ParamContent
(
tesseract::BoolParam
* it);
67
explicit
ParamContent
(
tesseract::DoubleParam
* it);
68
69
70
// Getters and Setters.
71
void
SetValue(
const
char
* val);
72
STRING
GetValue()
const
;
73
const
char
* GetName()
const
;
74
const
char
* GetDescription()
const
;
75
76
int
GetId
() {
return
my_id_; }
77
bool
HasChanged
() {
return
changed_; }
78
79
private
:
80
// The unique ID of this VC object.
81
int
my_id_
;
82
// Whether the parameter was changed_ and thus needs to be rewritten.
83
bool
changed_
;
84
// The actual ParamType of this VC object.
85
ParamType
param_type_
;
86
87
tesseract::StringParam
*
sIt
;
88
tesseract::IntParam
*
iIt
;
89
tesseract::BoolParam
*
bIt
;
90
tesseract::DoubleParam
*
dIt
;
91
};
92
93
ELISTIZEH(
ParamContent
)
94
95
// The parameters editor enables the user to edit all the parameters used within
96
// tesseract. It can be invoked on its own, but is supposed to be invoked by
97
// the program editor.
98
class
ParamsEditor
: public
SVEventHandler
{
99
public
:
100
// Integrate the parameters editor as popupmenu into the existing scrollview
101
// window (usually the pg editor). If sv == null, create a new empty
102
// empty window and attach the parameter editor to that window (ugly).
103
explicit
ParamsEditor
(
tesseract::Tesseract
*,
ScrollView
* sv =
nullptr
);
104
105
// Event listener. Waits for SVET_POPUP events and processes them.
106
void
Notify(
const
SVEvent
* sve);
107
108
private
:
109
// Gets the up to the first 3 prefixes from s (split by _).
110
// For example, tesseract_foo_bar will be split into tesseract,foo and bar.
111
void
GetPrefixes(
const
char
* s,
STRING
* level_one,
112
STRING
* level_two,
STRING
* level_three);
113
114
// Gets the first n words (split by _) and puts them in t.
115
// For example, tesseract_foo_bar with N=2 will yield tesseract_foo_.
116
void
GetFirstWords(
const
char
*s,
// source string
117
int
n,
// number of words
118
char
*t);
// target string
119
120
// Find all editable parameters used within tesseract and create a
121
// SVMenuNode tree from it.
122
SVMenuNode
*BuildListOfAllLeaves(
tesseract::Tesseract
*tess);
123
124
// Write all (changed_) parameters to a config file.
125
void
WriteParams(
char
* filename,
bool
changes_only);
126
127
ScrollView
*
sv_window_
;
128
};
129
130
#endif // GRAPHICS_DISABLED
131
#endif // TESSERACT_CCMAIN_PARAMSD_H_
ParamContent::HasChanged
bool HasChanged()
Definition:
paramsd.h:77
tesseract::StringParam
Definition:
params.h:190
SVEvent
Definition:
scrollview.h:61
ParamContent::param_type_
ParamType param_type_
Definition:
paramsd.h:85
ParamContent::dIt
tesseract::DoubleParam * dIt
Definition:
paramsd.h:90
ParamContent::GetId
int GetId()
Definition:
paramsd.h:76
ParamContent
Definition:
paramsd.h:54
tesseract
Definition:
baseapi.cpp:94
ParamContent::bIt
tesseract::BoolParam * bIt
Definition:
paramsd.h:89
ELIST_LINK
Definition:
elst.h:84
tesseract::BoolParam
Definition:
params.h:166
tesseract::IntParam
Definition:
params.h:142
ScrollView
Definition:
scrollview.h:102
ParamContent::changed_
bool changed_
Definition:
paramsd.h:83
STRING
Definition:
strngs.h:45
ParamsEditor
Definition:
paramsd.h:98
SVMenuNode
Definition:
svmnode.h:35
tesseract::Tesseract
Definition:
tesseractclass.h:173
SVEventHandler
Definition:
scrollview.h:86
ParamsEditor::sv_window_
ScrollView * sv_window_
Definition:
paramsd.h:127
ParamContent::iIt
tesseract::IntParam * iIt
Definition:
paramsd.h:88
ParamContent::my_id_
int my_id_
Definition:
paramsd.h:81
ParamContent::sIt
tesseract::StringParam * sIt
Definition:
paramsd.h:87
tesseract::DoubleParam
Definition:
params.h:219
src
tesseract
src
ccmain
paramsd.h
Generated on Wed Nov 7 2018 13:45:42 for tesseract by
1.8.13