ALBA
albaHTMLTemplateParserBlock.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaHTMLTemplateParserBlock
5 Authors: Gianluigi Crimi
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaHTMLTemplateParserBlock_H__
18#define __albaHTMLTemplateParserBlock_H__
19
20//----------------------------------------------------------------------------
21// Include:
22//----------------------------------------------------------------------------
23#include "albaDefines.h" //important: albaDefines should always be included as first
24#include <vector>
25
26//----------------------------------------------------------------------------
27// forward references :
28//----------------------------------------------------------------------------
30{
34};
35
37{
43};
44
45class albaView;
46class wxString;
47class vtkImageData;
48
54{
55
56
57public:
58 typedef struct vars{
59 wxString Name;
60 int Type;
61 int Pos;
62 } HTMLTemplateSubstitution;
63
64public:
65 typedef struct parsedItems{
68 } HTMLTemplateParsedItems;
69
71 albaHTMLTemplateParserBlock(int blockType, wxString name);
74
76 void AddVar(wxString name, double varValue);
78 void AddVar(wxString name, int varValue);
80 void AddVar(wxString name, wxString varValue);
82 void AddImageVar(wxString name, wxString imagePath = "", wxString label = "");
84 void AddImageVar(wxString name, albaView *view, wxString label = "");
86 void AddImageVar(wxString name, vtkImageData *imageData, wxString label = "", int flipAxis = -1);
88 void PushImageVar(wxString name, wxString imagePath, wxString label = "");
90 void PushImageVar(wxString name, albaView *view, wxString label = "");
92 void PushImageVar(wxString name, vtkImageData *imageData, wxString label = "");
94 void PushVar(wxString name, double varValue);
96 void PushVar(wxString name, int varValue);
98 void PushVar(wxString name, wxString varValue);
99
102 wxString GetVar(wxString name);
103
107 wxString GetNthVar(wxString name, int arrayPos=-1);
108
109
111 void AddBlock(wxString name, int blockType);
112
114 void PushBlock(wxString name, int blockType);
115
119
122 albaHTMLTemplateParserBlock *GetNthBlock(wxString name,int pos=-1);
123
125 void SetIfCondition(int condition);
126
129
131 void SetNLoops(int nloops);
132
135
136 /*mode 0 = none, mode 1 = horizontal, 2 = vertical*/
137 void SetImageRTFProps(int widthGoal = 8640, int heightGoal = 12960, int mode = 1);
138protected:
141 int SubstitutionPos(wxString *name);
142
145
147 void WriteSubstitution(HTMLTemplateSubstitution var, wxString *outputHTML);
148
151 void PreParse(wxString *inputTemplate, int &parsingPos);
152
154 int PreParseTag(wxString *inputTemplate, int &parsingPos);
155
157 void SkipInputSpaces(wxString *inputTemplate, int &parsingPos);
158
161 int AddSubstitution(wxString *tagName, int SubstitutionType);
162
166 int AddForward(wxString *tagName, int substitutionType);
167
169 int SubStringCompare(wxString *input, char *subString, int inputPos);
170
173
175 void GenerateOutput(wxString *outputHTML);
176
179 void ReadTagName(wxString *inputTemplate, int &parsingPos, wxString &tagName);
180
183
186
187 wxString CalculateImageRTF(wxString imagePath, int width, int height);
188
192
193 //VARIABLES
195
196 wxString m_BlockName;
198
201
205
206 std::vector<HTMLTemplateSubstitution> m_SubstitutionTable;
207
208 std::vector < wxString > m_Variables;
209 std::vector < std::vector<wxString> > m_VariablesArray;
210
211 std::vector < albaHTMLTemplateParserBlock * > m_SubBlocks;
212 std::vector < std::vector< albaHTMLTemplateParserBlock * > > m_SubBlocksArray;
213
215 std::vector < HTMLTemplateParsedItems > m_Substitutions;
216
217};
218#endif
@ alba_HTML_TEMPLATE_MAIN
@ alba_HTML_TEMPLATE_LOOP
@ alba_HTML_SUBSTITUTION_FORWARD_UP
@ alba_HTML_SUBSTITUTION_VARIABLE_ARRAY
@ alba_HTML_SUBSTITUTION_BLOCK
@ alba_HTML_SUBSTITUTION_VARIABLE
@ alba_HTML_SUBSTITUTION_BLOCK_ARRAY
class name: albaHTMLTemplateParserBlock sub-class for Template parsing used by albaHTMLTemplateParser
void PushImageVar(wxString name, vtkImageData *imageData, wxString label="")
Push the variable specified in the name string to the list of variables.
std::vector< albaHTMLTemplateParserBlock * > m_SubBlocks
int ConsistenceCheck()
Check the consistence of the generated structure.
void SkipInputSpaces(wxString *inputTemplate, int &parsingPos)
Utility function that skip spaces on input template.
void PushImageVar(wxString name, albaView *view, wxString label="")
Push the variable specified in the name string to the list of variables.
void AddBlock(wxString name, int blockType)
Add the Block specified in the list of Blocks.
void PushVar(wxString name, wxString varValue)
Push the variable specified in the name string to the list of variables.
std::vector< HTMLTemplateSubstitution > m_SubstitutionTable
void SetImageRTFProps(int widthGoal=8640, int heightGoal=12960, int mode=1)
int SubStringCompare(wxString *input, char *subString, int inputPos)
Return true if input contains subString starting from inputPos.
void AddImageVar(wxString name, wxString imagePath="", wxString label="")
Add the variable specified in the name string to the list of variables.
wxString GetNthVar(wxString name, int arrayPos=-1)
Return the string of the Variable Used for variable-arrays, if pos=-1 last pushed variable will be re...
~albaHTMLTemplateParserBlock()
destructor
albaHTMLTemplateParserBlock * GetNthBlock(wxString name, int pos=-1)
Return the pointer to the block specified in name and pos.
void WriteSubstitution(HTMLTemplateSubstitution var, wxString *outputHTML)
Write a specified Var to the output.
void CleanPreParsingInfo()
Clean the structures generated on PreParse phase.
void AddImageVar(wxString name, vtkImageData *imageData, wxString label="", int flipAxis=-1)
Add the variable specified in the name string to the list of variables.
void PushVar(wxString name, double varValue)
Push the variable specified in the name string to the list of variables.
void AddVar(wxString name, wxString varValue)
Add the variable specified in the name string to the list of variables.
wxString GetVar(wxString name)
Return the string of the Variable used for added vars.
int GetNLoops()
Set the number of loops for the "if" blocks.
wxString CalculateImageRTF(wxString imagePath, int width, int height)
int PreParseTag(wxString *inputTemplate, int &parsingPos)
Parse the input starting from a tag.
void SetFather(albaHTMLTemplateParserBlock *father)
Sets the father for the block.
std::vector< std::vector< wxString > > m_VariablesArray
void SetIfCondition(int condition)
Set the verity value for the "if" blocks.
void PushBlock(wxString name, int blockType)
Push the Block specified in the list of Blocks.
void ReadTagName(wxString *inputTemplate, int &parsingPos, wxString &tagName)
Reads the name of the tag from the input template and save it to varName.
void PushVar(wxString name, int varValue)
Push the variable specified in the name string to the list of variables.
void SetNLoops(int nloops)
Set the number of loops for the "if" blocks.
std::vector< HTMLTemplateParsedItems > m_Substitutions
void PushImageVar(wxString name, wxString imagePath, wxString label="")
Push the variable specified in the name string to the list of variables.
albaHTMLTemplateParserBlock * m_Father
int AddForward(wxString *tagName, int substitutionType)
This function is called when a substitution is not found in local scope in order to search it upward ...
int AddSubstitution(wxString *tagName, int SubstitutionType)
AddSubstitution to m_Subistitution if necessary search the correspondent variable to the block root,...
void PreParse(wxString *inputTemplate, int &parsingPos)
Generate PreParsing structures from input template for this block and return the number of parsed cha...
void GenerateOutput(wxString *outputHTML)
Generate HTML output.
void AddVar(wxString name, int varValue)
Add the variable specified in the name string to the list of variables.
void AddVar(wxString name, double varValue)
Add the variable specified in the name string to the list of variables.
albaHTMLTemplateParserBlock(int blockType, wxString name)
constructor
std::vector< std::vector< albaHTMLTemplateParserBlock * > > m_SubBlocksArray
int GetIfCondition()
Set the verity value for the "if" blocks.
void AddImageVar(wxString name, albaView *view, wxString label="")
Add the variable specified in the name string to the list of variables.
int SubstitutionPos(wxString *name)
Return the position of the variable in the Variable Table.
HTMLTemplateSubstitution GetSubstitution(wxString name)
Finds a variable starting from his name.
albaHTMLTemplateParserBlock * GetBlock(wxString name)
Return the pointer to the block specified in name if the block is part of an block-array last pushed ...
albaView is the base class for Views in alba.
Definition: albaView.h:79