Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
paramsd.h
Go to the documentation of this file.
1
// File: paramsd.cpp
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 GRAPHICS_DISABLED
23
#ifndef VARABLED_H
24
#define VARABLED_H
25
26
#include "
elst.h
"
27
#include "
scrollview.h
"
28
#include "
params.h
"
29
#include "
tesseractclass.h
"
30
31
class
SVMenuNode
;
32
33
// A list of all possible parameter types used.
34
enum
ParamType
{
35
VT_INTEGER
,
36
VT_BOOLEAN
,
37
VT_STRING
,
38
VT_DOUBLE
39
};
40
41
// A rather hackish helper structure which can take any kind of parameter input
42
// (defined by ParamType) and do a couple of common operations on them, like
43
// comparisond or getting its value. It is used in the context of the
44
// ParamsEditor as a bridge from the internal tesseract parameters to the
45
// ones displayed by the ScrollView server.
46
class
ParamContent
:
public
ELIST_LINK
{
47
public
:
48
// Compare two VC objects by their name.
49
static
int
Compare
(
const
void
* v1,
const
void
* v2);
50
51
// Gets a VC object identified by its ID.
52
static
ParamContent
*
GetParamContentById
(
int
id
);
53
54
// Constructors for the various ParamTypes.
55
ParamContent
() {
56
}
57
ParamContent
(
tesseract::StringParam
* it);
58
ParamContent
(
tesseract::IntParam
* it);
59
ParamContent
(
tesseract::BoolParam
* it);
60
ParamContent
(
tesseract::DoubleParam
* it);
61
62
63
// Getters and Setters.
64
void
SetValue
(
const
char
* val);
65
const
char
*
GetValue
()
const
;
66
const
char
*
GetName
()
const
;
67
const
char
*
GetDescription
()
const
;
68
69
int
GetId
() {
return
my_id_; }
70
bool
HasChanged
() {
return
changed_; }
71
72
private
:
73
// The unique ID of this VC object.
74
int
my_id_;
75
// Whether the parameter was changed_ and thus needs to be rewritten.
76
bool
changed_;
77
// The actual ParamType of this VC object.
78
ParamType
param_type_;
79
80
tesseract::StringParam
* sIt;
81
tesseract::IntParam
* iIt;
82
tesseract::BoolParam
* bIt;
83
tesseract::DoubleParam
* dIt;
84
};
85
86
ELISTIZEH
(
ParamContent
)
87
88
// The parameters editor enables the user to edit all the parameters used within
89
// tesseract. It can be invoked on its own, but is supposed to be invoked by
90
// the program editor.
91
class
ParamsEditor
: public
SVEventHandler
{
92
public
:
93
// Integrate the parameters editor as popupmenu into the existing scrollview
94
// window (usually the pg editor). If sv == null, create a new empty
95
// empty window and attach the parameter editor to that window (ugly).
96
ParamsEditor
(
tesseract::Tesseract
*,
ScrollView
* sv =
NULL
);
97
98
// Event listener. Waits for SVET_POPUP events and processes them.
99
void
Notify(
const
SVEvent
* sve);
100
101
private
:
102
// Gets the up to the first 3 prefixes from s (split by _).
103
// For example, tesseract_foo_bar will be split into tesseract,foo and bar.
104
void
GetPrefixes(
const
char
* s,
STRING
* level_one,
105
STRING
* level_two,
STRING
* level_three);
106
107
// Gets the first n words (split by _) and puts them in t.
108
// For example, tesseract_foo_bar with N=2 will yield tesseract_foo_.
109
void
GetFirstWords(
const
char
*s,
// source string
110
int
n,
// number of words
111
char
*t);
// target string
112
113
// Find all editable parameters used within tesseract and create a
114
// SVMenuNode tree from it.
115
SVMenuNode
*BuildListOfAllLeaves(
tesseract::Tesseract
*tess);
116
117
// Write all (changed_) parameters to a config file.
118
void
WriteParams(
char
*
filename
,
bool
changes_only);
119
120
ScrollView
* sv_window_;
121
};
122
123
#endif
124
#endif
ParamContent
Definition:
paramsd.h:46
ParamContent::HasChanged
bool HasChanged()
Definition:
paramsd.h:70
VT_STRING
Definition:
paramsd.h:37
tesseract::StringParam
Definition:
params.h:176
VT_DOUBLE
Definition:
paramsd.h:38
SVMenuNode
Definition:
svmnode.h:33
ParamContent::GetName
const char * GetName() const
Definition:
paramsd.cpp:116
NULL
#define NULL
Definition:
host.h:144
tesseract::Tesseract
Definition:
tesseractclass.h:139
SVEvent
Definition:
scrollview.h:61
ParamType
ParamType
Definition:
paramsd.h:34
ELIST_LINK
Definition:
elst.h:84
elst.h
tesseract::IntParam
Definition:
params.h:140
ParamContent::ParamContent
ParamContent()
Definition:
paramsd.h:55
SVEventHandler
Definition:
scrollview.h:86
ParamContent::Compare
static int Compare(const void *v1, const void *v2)
Definition:
paramsd.cpp:185
params.h
tesseract-c_api-demo.filename
string filename
Definition:
tesseract-c_api-demo.py:29
ParamContent::GetParamContentById
static ParamContent * GetParamContentById(int id)
Definition:
paramsd.cpp:91
VT_INTEGER
Definition:
paramsd.h:35
scrollview.h
VT_BOOLEAN
Definition:
paramsd.h:36
tesseract::DoubleParam
Definition:
params.h:197
ScrollView
Definition:
scrollview.h:102
STRING
Definition:
strngs.h:40
ParamContent::GetDescription
const char * GetDescription() const
Definition:
paramsd.cpp:126
ParamContent::SetValue
void SetValue(const char *val)
Definition:
paramsd.cpp:154
tesseract::BoolParam
Definition:
params.h:158
tesseractclass.h
ParamContent::GetId
int GetId()
Definition:
paramsd.h:69
ParamContent::GetValue
const char * GetValue() const
Definition:
paramsd.cpp:135
ParamsEditor
Definition:
paramsd.h:91
ELISTIZEH
#define ELISTIZEH(CLASSNAME)
Definition:
elst.h:979
home
abuild
rpmbuild
BUILD
tesseract-ocr-3.02.02
ccmain
paramsd.h
Generated on Wed Apr 2 2014 09:06:47 for Tesseract by
1.8.6