mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 17:20:53 +01:00
[apps] create an abstract class for node
Change-Id: I3a946df720c37ec2b087cf6131ea886da3e26c95
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
#include "tool_box_controller.h"
|
||||
#include "tool_box_node.h"
|
||||
|
||||
/* TODO: find a shorter way to initiate tree models
|
||||
* We create one model tree: each node keeps the label of the row it refers to
|
||||
* and the text which would be edited by clicking on the row. When the node is a
|
||||
* subtree, the edited text is set at nullptr. */
|
||||
|
||||
const Node calculChildren[4] = {Node("Nombre derivee", "diff(,)"), Node("Integrale", "Int(,,)"), Node("Somme", "sum(,,)"), Node("Produit", "Product(,,)")};
|
||||
const Node complexChildren[5] = {Node("Module", "abs()"), Node("Argument", "arg()"), Node("Partie reelle", "re()"), Node("Partie imaginaire", "im()"), Node("Conjugue", "conj()")};
|
||||
const Node probabilityChildren[4] = {Node("Combinaison", "binomial()"), Node("Arrangement", "permute(,)"), Node("Nombre aleatoire", "random(,)"), Node("Fonction gamma", "gamma()")};
|
||||
const Node arithmeticChildren[4] = {Node("PGCD", "gcd()"), Node("PPCM","lcm()"), Node("Reste division euclidienne", "rem()"), Node("Quotien division euclidienne", "quo()")};
|
||||
const Node matricesChildren[5] = {Node("Inverse", "inverse()"), Node("Determinant", "det()"), Node("Transposee", "transpose()"), Node("Trace", "trace()"), Node("Taille", "dim()")};
|
||||
const Node listesChildren[5] = {Node("Tri croissant", "sort<()"), Node("Tri decroissant", "sort>()"), Node("Maximum", "max()"), Node("Minimum", "min()"), Node("Taille", "dim()")};
|
||||
const Node approximationChildren[4] = {Node("Partie entiere", "floor()"), Node("Partie fractionnaire", "frac()"), Node("Plafond", "ceil()"), Node("Arrondi", "round(,)")};
|
||||
const Node trigonometryChildren[6] = {Node("cosh", "cosh()"), Node("sinh", "sinh()"), Node("tanh", "tanh()"), Node("acosh", "acosh()"), Node("asinh", "asinh()"), Node("atanh", "atanh()")};
|
||||
const ToolBoxNode calculChildren[4] = {ToolBoxNode("Nombre derivee", "diff(,)"), ToolBoxNode("Integrale", "Int(,,)"), ToolBoxNode("Somme", "sum(,,)"), ToolBoxNode("Produit", "Product(,,)")};
|
||||
const ToolBoxNode complexChildren[5] = {ToolBoxNode("Module", "abs()"), ToolBoxNode("Argument", "arg()"), ToolBoxNode("Partie reelle", "re()"), ToolBoxNode("Partie imaginaire", "im()"), ToolBoxNode("Conjugue", "conj()")};
|
||||
const ToolBoxNode probabilityChildren[4] = {ToolBoxNode("Combinaison", "binomial()"), ToolBoxNode("Arrangement", "permute(,)"), ToolBoxNode("Nombre aleatoire", "random(,)"), ToolBoxNode("Fonction gamma", "gamma()")};
|
||||
const ToolBoxNode arithmeticChildren[4] = {ToolBoxNode("PGCD", "gcd()"), ToolBoxNode("PPCM","lcm()"), ToolBoxNode("Reste division euclidienne", "rem()"), ToolBoxNode("Quotien division euclidienne", "quo()")};
|
||||
const ToolBoxNode matricesChildren[5] = {ToolBoxNode("Inverse", "inverse()"), ToolBoxNode("Determinant", "det()"), ToolBoxNode("Transposee", "transpose()"), ToolBoxNode("Trace", "trace()"), ToolBoxNode("Taille", "dim()")};
|
||||
const ToolBoxNode listesChildren[5] = {ToolBoxNode("Tri croissant", "sort<()"), ToolBoxNode("Tri decroissant", "sort>()"), ToolBoxNode("Maximum", "max()"), ToolBoxNode("Minimum", "min()"), ToolBoxNode("Taille", "dim()")};
|
||||
const ToolBoxNode approximationChildren[4] = {ToolBoxNode("Partie entiere", "floor()"), ToolBoxNode("Partie fractionnaire", "frac()"), ToolBoxNode("Plafond", "ceil()"), ToolBoxNode("Arrondi", "round(,)")};
|
||||
const ToolBoxNode trigonometryChildren[6] = {ToolBoxNode("cosh", "cosh()"), ToolBoxNode("sinh", "sinh()"), ToolBoxNode("tanh", "tanh()"), ToolBoxNode("acosh", "acosh()"), ToolBoxNode("asinh", "asinh()"), ToolBoxNode("atanh", "atanh()")};
|
||||
|
||||
const Node menu[11] = {Node("|x|", "abs()"), Node("root(x)", "root(,)"), Node("log(x)", "log(,)"),
|
||||
Node("Calcul", nullptr, calculChildren, 4), Node("Nombre complexe", nullptr, complexChildren, 5),
|
||||
Node("Probabilite", nullptr, probabilityChildren, 4), Node("Arithmetique", nullptr, arithmeticChildren, 4),
|
||||
Node("Matrice", nullptr,matricesChildren, 5), Node("Liste", nullptr, listesChildren, 5),
|
||||
Node("Approximation", nullptr, approximationChildren, 4), Node("Trigonometrie", nullptr, trigonometryChildren, 6)};
|
||||
const Node toolBoxModel = Node("ToolBox", nullptr, menu, 11);
|
||||
const ToolBoxNode menu[11] = {ToolBoxNode("|x|", "abs()"), ToolBoxNode("root(x)", "root(,)"), ToolBoxNode("log(x)", "log(,)"),
|
||||
ToolBoxNode("Calcul", nullptr, calculChildren, 4), ToolBoxNode("Nombre complexe", nullptr, complexChildren, 5),
|
||||
ToolBoxNode("Probabilite", nullptr, probabilityChildren, 4), ToolBoxNode("Arithmetique", nullptr, arithmeticChildren, 4),
|
||||
ToolBoxNode("Matrice", nullptr, matricesChildren, 5), ToolBoxNode("Liste", nullptr, listesChildren, 5),
|
||||
ToolBoxNode("Approximation", nullptr, approximationChildren, 4), ToolBoxNode("Trigonometrie", nullptr, trigonometryChildren, 6)};
|
||||
const ToolBoxNode toolBoxModel = ToolBoxNode("TOOLBOX", nullptr, menu, 11);
|
||||
|
||||
const char * ToolBoxController::title() const {
|
||||
return "ToolBoxController";
|
||||
@@ -30,7 +31,8 @@ Node * ToolBoxController::nodeModel() {
|
||||
}
|
||||
|
||||
bool ToolBoxController::selectLeaf(Node * selectedNode){
|
||||
const char * editedText = selectedNode->text();
|
||||
ToolBoxNode * node = (ToolBoxNode *)selectedNode;
|
||||
const char * editedText = node->text();
|
||||
m_textFieldCaller->appendText(editedText);
|
||||
int cursorPosition = 0;
|
||||
int editedTextLength = strlen(editedText);
|
||||
|
||||
Reference in New Issue
Block a user