ARB
Classes | Macros | Typedefs | Functions | Variables
saicalc.cxx File Reference
#include "saicalc.h"
#include "saiop.h"
#include <awt_sel_boxes.hxx>
#include <awt_config_manager.hxx>
#include <aw_select.hxx>
#include <aw_awar_defs.hxx>
#include <aw_awar.hxx>
#include <aw_root.hxx>
#include <aw_msg.hxx>
#include <rootAsWin.h>
#include <downcast.h>
#include "calculator.h"
Include dependency graph for saicalc.cxx:

Go to the source code of this file.

Classes

struct  CompareByLength
 
struct  CompareAlpha
 

Macros

#define AWAR_SC_BASE   "sai/calc/"
 
#define AWAR_SC_TEMP   "tmp/" AWAR_SC_BASE
 
#define AWAR_SC_TRANSLATE_BASE   AWAR_SC_BASE "translate/"
 
#define AWAR_SC_TRANSLATE_TEMP   AWAR_SC_TEMP "translate/"
 
#define AWAR_SC_MATRIX_BASE   AWAR_SC_BASE "matrix/"
 
#define AWAR_SC_MATRIX_TEMP   AWAR_SC_TEMP "matrix/"
 
#define AWAR_SC_BOOL_BASE   AWAR_SC_BASE "bool/"
 
#define AWAR_SC_BOOL_TEMP   AWAR_SC_TEMP "bool/"
 
#define AWAR_SC_ACI_BASE   AWAR_SC_BASE "aci/"
 
#define AWAR_SC_ACI_TEMP   AWAR_SC_TEMP "aci/"
 
#define AWAR_SC_TARGET_SAI   AWAR_SC_BASE "target"
 
#define AWAR_SC_SOURCE_SAI_LIST   AWAR_SC_BASE "sources"
 
#define AWAR_SC_METHOD   AWAR_SC_BASE "method"
 
#define AWAR_SC_SCOPE   AWAR_SC_BASE "scope"
 
#define AWAR_SC_METHOD_CONFIG   AWAR_SC_TEMP "config"
 
#define AWAR_SC_TRANSLATE_CONFIG   AWAR_SC_TRANSLATE_BASE "config"
 
#define AWAR_SC_TRANSLATE_DEFAULT   AWAR_SC_TRANSLATE_TEMP "default"
 
#define AWAR_SC_TRANSLATE_IO_TEMPL   AWAR_SC_TRANSLATE_TEMP "%c%i"
 
#define AWAR_SC_MATRIX_CONFIG   AWAR_SC_MATRIX_BASE "config"
 
#define AWAR_SC_MATRIX_CELL_TEMPL   AWAR_SC_MATRIX_TEMP "m%i_%i"
 
#define AWAR_SC_BOOL_CONFIG   AWAR_SC_BOOL_BASE "config"
 
#define AWAR_SC_BOOL_IN1   AWAR_SC_BOOL_TEMP "in1"
 
#define AWAR_SC_BOOL_IN0   AWAR_SC_BOOL_TEMP "in0"
 
#define AWAR_SC_BOOL_OP   AWAR_SC_BOOL_TEMP "op"
 
#define AWAR_SC_BOOL_OUT1   AWAR_SC_BOOL_TEMP "out1"
 
#define AWAR_SC_BOOL_OUT0   AWAR_SC_BOOL_TEMP "out0"
 
#define AWAR_SC_BOOL_SEL_RULE   AWAR_SC_BOOL_TEMP "selrule"
 
#define AWAR_SC_BOOL_RULES   AWAR_SC_BOOL_TEMP "rules"
 
#define AWAR_SC_ACI_CONFIG   AWAR_SC_ACI_BASE "config"
 
#define AWAR_SC_ACI   AWAR_SC_ACI_TEMP "aci"
 
#define TRANSLATION_RULES   10
 
#define MATRIX_RULES   (7+1)
 
#define MATRIX_AWARS   (MATRIX_RULES+1)
 

Typedefs

typedef vector< stringStringVector
 

Functions

static void sai_seletion_changed_cb (AW_selection *sel_sai, bool, AW_CL)
 
static void fill_with_source_sais (ConstStrArray &sainame, AW_root *awr)
 
static void source_sai_list_changed_cb (AW_root *awr, AW_selection *sel_sai)
 
static const charawar_translate (bool in, int num)
 
static AW_windowcreate_translator_config_window (AW_root *awr)
 
static const charawar_matrix_cell (int x, int y)
 
static void normalize_matrix_cb (AW_window *aww)
 
static AW_windowcreate_matrix_config_window (AW_root *awr)
 
static AW_windowcreate_aciapp_config_window (AW_root *awr)
 
static void refill_boolrules_sellist (const ConstStrArray &ruleArray)
 
static void update_rulesAwar (AW_root *awr, const CharPtrArray &ruleArray)
 
static void fill_boolrules_array_from_AWAR (AW_root *awr, ConstStrArray &ruleArray)
 
static void refill_boolrules_sellist_from_AWAR (AW_root *awr)
 
static SaiBoolRulePtr build_rule_from_AWARs (AW_root *awr, bool createFirstRule)
 
static void add_boolrule_cb (AW_window *aww)
 
static void mod_boolrule_cb (AW_window *aww)
 
static void del_boolrule_cb (AW_window *aww)
 
static AW_windowcreate_boolchain_config_window (AW_root *awr)
 
static void saicalc_edit_method_cb (AW_root *awr, bool forcePopup)
 
static SaiOperatorPtr createOpFromConfigAwar (SaiOperatorType type, AW_awar *awar_config)
 
static void translate_config_changed_cb (AW_root *awr)
 
static void translate_gui_changed_cb (AW_root *awr, bool, int)
 
static const charcontent_matrix_cell (int x, int y)
 
static SaiOperatorPtr buildColumnTranslatorFromAwars (int x, bool returnDefault)
 
static void detectEqualRowsAndColumns (const string &out, StringVector &row, StringVector &col)
 
static void matrix_config_changed_cb (AW_root *awr)
 
static void matrix_gui_changed_cb (AW_root *awr, int, int)
 
static char firstCharOfAwarOrDefault (AW_root *awr, const char *awarname)
 
static void bool_config_changed_cb (AW_root *awr)
 
static void boolchain_gui_changed_cb (AW_root *awr)
 
static void boolchain_rulesAwar_changed_cb (AW_root *awr)
 
static void display_selected_rule_cb (AW_root *awr)
 
static void inputCharsetChanged_cb (AW_root *awr, bool defTrue)
 
static void aci_config_changed_cb (AW_root *awr)
 
static void aci_gui_changed_cb (AW_root *awr)
 
static void calc_method_changed_cb (AW_root *awr)
 
static void calculate_sai_cb (AW_window *aww, GBDATA *gb_main)
 
static void use_selected_as_target_cb (AW_window *aww)
 
static void SAI_init_calculator_awars (AW_root *awr)
 
void SAI_popup_calculator_window (AW_window *awp, GBDATA *gb_main)
 

Variables

static AWT_config_mapping_def saicalc_config_mapping []
 
static AWT_predefined_config saicalc_predefined_configs []
 
static const char *const RULELIST_DELIMITER = "\1"
 
static AW_selection_listboolrule_sellst = NULp
 
static bool in_translate_awar_callback = false
 
static bool in_matrix_awar_callback = false
 
static bool in_boolchain_awar_callback = false
 
static bool in_boolchain_inputCharset_awar_callback = false
 
static bool in_aci_awar_callback = false
 

Macro Definition Documentation

#define AWAR_SC_BASE   "sai/calc/"

Definition at line 28 of file saicalc.cxx.

#define AWAR_SC_TEMP   "tmp/" AWAR_SC_BASE

Definition at line 29 of file saicalc.cxx.

#define AWAR_SC_TRANSLATE_BASE   AWAR_SC_BASE "translate/"

Definition at line 30 of file saicalc.cxx.

#define AWAR_SC_TRANSLATE_TEMP   AWAR_SC_TEMP "translate/"

Definition at line 31 of file saicalc.cxx.

#define AWAR_SC_MATRIX_BASE   AWAR_SC_BASE "matrix/"

Definition at line 32 of file saicalc.cxx.

#define AWAR_SC_MATRIX_TEMP   AWAR_SC_TEMP "matrix/"

Definition at line 33 of file saicalc.cxx.

#define AWAR_SC_BOOL_BASE   AWAR_SC_BASE "bool/"

Definition at line 34 of file saicalc.cxx.

#define AWAR_SC_BOOL_TEMP   AWAR_SC_TEMP "bool/"

Definition at line 35 of file saicalc.cxx.

#define AWAR_SC_ACI_BASE   AWAR_SC_BASE "aci/"

Definition at line 36 of file saicalc.cxx.

#define AWAR_SC_ACI_TEMP   AWAR_SC_TEMP "aci/"

Definition at line 37 of file saicalc.cxx.

#define AWAR_SC_TARGET_SAI   AWAR_SC_BASE "target"
#define AWAR_SC_SOURCE_SAI_LIST   AWAR_SC_BASE "sources"
#define AWAR_SC_METHOD   AWAR_SC_BASE "method"
#define AWAR_SC_SCOPE   AWAR_SC_BASE "scope"
#define AWAR_SC_METHOD_CONFIG   AWAR_SC_TEMP "config"

Definition at line 43 of file saicalc.cxx.

Referenced by calc_method_changed_cb(), calculate_sai_cb(), and SAI_init_calculator_awars().

#define AWAR_SC_TRANSLATE_CONFIG   AWAR_SC_TRANSLATE_BASE "config"
#define AWAR_SC_TRANSLATE_DEFAULT   AWAR_SC_TRANSLATE_TEMP "default"
#define AWAR_SC_TRANSLATE_IO_TEMPL   AWAR_SC_TRANSLATE_TEMP "%c%i"

Definition at line 47 of file saicalc.cxx.

Referenced by awar_translate().

#define AWAR_SC_MATRIX_CONFIG   AWAR_SC_MATRIX_BASE "config"
#define AWAR_SC_MATRIX_CELL_TEMPL   AWAR_SC_MATRIX_TEMP "m%i_%i"

Definition at line 50 of file saicalc.cxx.

Referenced by awar_matrix_cell().

#define AWAR_SC_BOOL_CONFIG   AWAR_SC_BOOL_BASE "config"
#define AWAR_SC_BOOL_IN1   AWAR_SC_BOOL_TEMP "in1"
#define AWAR_SC_BOOL_IN0   AWAR_SC_BOOL_TEMP "in0"
#define AWAR_SC_BOOL_OP   AWAR_SC_BOOL_TEMP "op"
#define AWAR_SC_BOOL_OUT1   AWAR_SC_BOOL_TEMP "out1"
#define AWAR_SC_BOOL_OUT0   AWAR_SC_BOOL_TEMP "out0"
#define AWAR_SC_BOOL_SEL_RULE   AWAR_SC_BOOL_TEMP "selrule"
#define AWAR_SC_BOOL_RULES   AWAR_SC_BOOL_TEMP "rules"
#define AWAR_SC_ACI_CONFIG   AWAR_SC_ACI_BASE "config"
#define AWAR_SC_ACI   AWAR_SC_ACI_TEMP "aci"
#define TRANSLATION_RULES   10
#define MATRIX_RULES   (7+1)

Definition at line 66 of file saicalc.cxx.

#define MATRIX_AWARS   (MATRIX_RULES+1)

Typedef Documentation

typedef vector<string> StringVector

Definition at line 651 of file saicalc.cxx.

Function Documentation

static void sai_seletion_changed_cb ( AW_selection sel_sai,
bool  ,
AW_CL   
)
static
static void fill_with_source_sais ( ConstStrArray sainame,
AW_root awr 
)
static
static void source_sai_list_changed_cb ( AW_root awr,
AW_selection sel_sai 
)
static
static const char* awar_translate ( bool  in,
int  num 
)
static
static AW_window* create_translator_config_window ( AW_root awr)
static
static const char* awar_matrix_cell ( int  x,
int  y 
)
static
static void normalize_matrix_cb ( AW_window aww)
static
static AW_window* create_matrix_config_window ( AW_root awr)
static
static AW_window* create_aciapp_config_window ( AW_root awr)
static

Definition at line 244 of file saicalc.cxx.

References AW_POPDOWN(), AWAR_SC_ACI, AW_window::load_xfig(), and makeHelpCallback().

Referenced by saicalc_edit_method_cb().

static void refill_boolrules_sellist ( const ConstStrArray ruleArray)
static
static void update_rulesAwar ( AW_root awr,
const CharPtrArray ruleArray 
)
static
static void fill_boolrules_array_from_AWAR ( AW_root awr,
ConstStrArray ruleArray 
)
static
static void refill_boolrules_sellist_from_AWAR ( AW_root awr)
static
static SaiBoolRulePtr build_rule_from_AWARs ( AW_root awr,
bool  createFirstRule 
)
static
static void add_boolrule_cb ( AW_window aww)
static
static void mod_boolrule_cb ( AW_window aww)
static
static void del_boolrule_cb ( AW_window aww)
static
static AW_window* create_boolchain_config_window ( AW_root awr)
static
static void saicalc_edit_method_cb ( AW_root awr,
bool  forcePopup 
)
static
static SaiOperatorPtr createOpFromConfigAwar ( SaiOperatorType  type,
AW_awar awar_config 
)
static
static void translate_config_changed_cb ( AW_root awr)
static
static void translate_gui_changed_cb ( AW_root awr,
bool  ,
int   
)
static
static const char* content_matrix_cell ( int  x,
int  y 
)
static
static SaiOperatorPtr buildColumnTranslatorFromAwars ( int  x,
bool  returnDefault 
)
static
static void detectEqualRowsAndColumns ( const string out,
StringVector row,
StringVector col 
)
static

Definition at line 656 of file saicalc.cxx.

References y.

Referenced by matrix_config_changed_cb().

static void matrix_config_changed_cb ( AW_root awr)
static
static void matrix_gui_changed_cb ( AW_root awr,
int  ,
int   
)
static
static char firstCharOfAwarOrDefault ( AW_root awr,
const char awarname 
)
static

read value of awar 'awarname' return either

  • first char of its value or (if empty)
  • first char of its default value

Definition at line 850 of file saicalc.cxx.

References AW_root::awar(), error(), AW_awar::read_char_pntr(), AW_awar::read_string(), AW_awar::reset_to_default(), result, sai_assert, and AW_awar::write_string().

Referenced by boolchain_gui_changed_cb().

static void bool_config_changed_cb ( AW_root awr)
static
static void boolchain_gui_changed_cb ( AW_root awr)
static
static void boolchain_rulesAwar_changed_cb ( AW_root awr)
static
static void display_selected_rule_cb ( AW_root awr)
static
static void inputCharsetChanged_cb ( AW_root awr,
bool  defTrue 
)
static
static void aci_config_changed_cb ( AW_root awr)
static
static void aci_gui_changed_cb ( AW_root awr)
static
static void calc_method_changed_cb ( AW_root awr)
static
static void calculate_sai_cb ( AW_window aww,
GBDATA gb_main 
)
static
static void use_selected_as_target_cb ( AW_window aww)
static
static void SAI_init_calculator_awars ( AW_root awr)
static
void SAI_popup_calculator_window ( AW_window awp,
GBDATA gb_main 
)

Variable Documentation

AWT_config_mapping_def saicalc_config_mapping[]
static
Initial value:
= {
{ AWAR_SC_TARGET_SAI, "target" },
{ AWAR_SC_SOURCE_SAI_LIST, "sources" },
{ AWAR_SC_METHOD, "method" },
{ AWAR_SC_SCOPE, "scope" },
{ AWAR_SC_METHOD_CONFIG, "~config" },
{ NULp, NULp }
}
#define AWAR_SC_SCOPE
Definition: saicalc.cxx:42
#define AWAR_SC_TARGET_SAI
Definition: saicalc.cxx:39
#define AWAR_SC_SOURCE_SAI_LIST
Definition: saicalc.cxx:40
#define AWAR_SC_METHOD_CONFIG
Definition: saicalc.cxx:43
#define AWAR_SC_METHOD
Definition: saicalc.cxx:41
#define NULp
Definition: cxxforward.h:116

Definition at line 69 of file saicalc.cxx.

AWT_predefined_config saicalc_predefined_configs[]
static
Initial value:
= {
{ "*diff2", "Compares 2 SAI.\nResult: '-' where equal\n 'x' where different", "method='0';target='diff';~config='aci=\\'colsplit|compare|plus(1)|translate(\"012\",\"x-x\")\\''" },
{ "*diff2_ignCase", "Compares 2 SAI (ignoring case).\nResult: '-' where equal \n 'x' where different", "method='0';target='idiff';~config='aci=\\'upper|colsplit|compare|plus(1)|translate(\"012\",\"x-x\")\\''" },
{ "*count_x", "Count 'x' in multiple SAI (up to 9).", "method='0';target='x-count';~config='aci=\\'keep(\"x\")|len|translate(\"0\",\"-\")\\''" },
{ "*sum_up_2", "Sum up 2 SAI containing digits and gaps\n(raises error if result overflows 9).", "method='0';target='sum';~config='aci=\\'translate(\"-=\",\"00\")|colsplit|plus\\''" },
{ "*cutByTermini", "Sai1: termini (containing 'x' in region)\nSai2: any\n=> same as Sai2 at all 'x' in Sai1\n else same as Sai1 (normally gap).", "method='0';sources='termini';~config='aci=\\'command(\"/^x//\")|head(1)\\''" },
{ "*invert_binary", "inverts binary SAI\n(works with binary source and/or target)", "method='0';~config='aci=\\'translate(\"01\",\"10\")\\''" },
{ NULp, NULp, NULp }
}
#define NULp
Definition: cxxforward.h:116

Definition at line 79 of file saicalc.cxx.

const char* const RULELIST_DELIMITER = "\1"
static

Definition at line 269 of file saicalc.cxx.

AW_selection_list* boolrule_sellst = NULp
static

Definition at line 270 of file saicalc.cxx.

bool in_translate_awar_callback = false
static

Definition at line 533 of file saicalc.cxx.

Referenced by translate_config_changed_cb(), and translate_gui_changed_cb().

bool in_matrix_awar_callback = false
static

Definition at line 610 of file saicalc.cxx.

Referenced by matrix_config_changed_cb(), and matrix_gui_changed_cb().

bool in_boolchain_awar_callback = false
static

Definition at line 879 of file saicalc.cxx.

Referenced by bool_config_changed_cb(), and boolchain_gui_changed_cb().

bool in_boolchain_inputCharset_awar_callback = false
static

Definition at line 951 of file saicalc.cxx.

Referenced by display_selected_rule_cb(), and inputCharsetChanged_cb().

bool in_aci_awar_callback = false
static

Definition at line 997 of file saicalc.cxx.

Referenced by aci_config_changed_cb(), and aci_gui_changed_cb().