Skip to content
Snippets Groups Projects
Commit 82d40575 authored by francois.grand's avatar francois.grand
Browse files

Stockage des résultats de calcul dans la classe FormulaireDefinition

- création des classes FixedVarResults, SectionResults et RemousResults pour stocker les résultats de calculettes dans FormulaireDefinition
- CalculatorResultsComponent renommé en FixedVarResultsComponent
- création d'un composant CalculatorResultsComponent qui inclut tous les composants de résultats (FixedVarResultsComponent, SectionResultsComponent, RemousResultsComponent)
- création d'un service de paramétrage global de l'appli (ApplicationSetupService)
- fichiers JSON de configuration des calculettes : ajout d'un champ sectionSelectId pour désigner le select qui détermine le type de section
parent 77e4a55a
No related branches found
No related tags found
No related merge requests found
Showing
with 1402 additions and 899 deletions
......@@ -92,13 +92,17 @@ export class AppComponent implements Observer {
console.log(data);
}
else if (sender instanceof FormulaireService) {
const f: FormulaireDefinition = data;
this._calculators.push(
{
"title": CalculatorType[f.calculatorType] + String(f.uid),
"uid": String(f.uid)
}
);
switch (data["action"]) {
case "create":
const f: FormulaireDefinition = data["form"];
this._calculators.push(
{
"title": CalculatorType[f.calculatorType] + String(f.uid),
"uid": String(f.uid)
}
);
break;
}
}
}
......
......@@ -12,6 +12,7 @@ import { FormulaireService } from "./services/formulaire/formulaire.service";
import { ParamService } from "./services/param/param.service";
import { InternationalisationService } from "./services/internationalisation/internationalisation.service";
import { HttpService } from "./services/http/http.service";
import { ApplicationSetupService } from "./services/app-setup/app-setup.service";
import { AppComponent } from './app.component';
import { ParamInputComponent } from './components/param-input/param-input.component';
import { FieldSetComponent } from './components/field-set/field-set.component';
......@@ -21,6 +22,7 @@ import { CheckFieldLineComponent } from './components/check-field-line/check-fie
// import { AlertDialog } from './components/alert-dialog/alert-dialog.component';
import { AppErrorModule } from './error.module';
import { CalculatorResultsComponent } from './components/calculator-results/calculator-results.component';
import { FixedVarResultsComponent } from './components/fixedvar-results/fixedvar-results.component';
import { SectionResultsComponent } from './components/section-results/section-results.component';
import { GenericCalculatorComponent } from './calculators/generic/calculator.component';
import { CalcCanvasComponent } from './components/canvas/canvas.component';
......@@ -60,12 +62,12 @@ const appRoutes: Routes = [
CalculatorListComponent,
GenericCalculatorComponent,
// AlertDialog,
CalculatorResultsComponent, SectionResultsComponent, RemousResultsComponent,
CalculatorResultsComponent, FixedVarResultsComponent, SectionResultsComponent, RemousResultsComponent,
CalcCanvasComponent, SectionCanvasComponent
],
// entryComponents: [AlertDialog],
providers: [ // services
ParamService, InternationalisationService, HttpService, FormulaireService
ParamService, InternationalisationService, HttpService, FormulaireService, ApplicationSetupService
],
schemas: [NO_ERRORS_SCHEMA],
bootstrap: [AppComponent]
......
......@@ -23,6 +23,4 @@
<p></p>
</div>
</div>
<calc-results [style.display]="getResultsStyleDisplay()"></calc-results>
<section-results [style.display]="getSectionResultsStyleDisplay()"></section-results>
<remous-results [style.display]="getRemousResultsStyleDisplay()"></remous-results>
\ No newline at end of file
<calc-results></calc-results>
\ No newline at end of file
This diff is collapsed.
......@@ -167,6 +167,7 @@
{
"id": "options",
"idCal": "Q",
"nodeType": "RegimeUniforme"
"nodeType": "RegimeUniforme",
"sectionSelectId": "select_section"
}
]
\ No newline at end of file
......@@ -258,6 +258,7 @@
},
{
"id": "options",
"nodeType": "CourbeRemous"
"nodeType": "CourbeRemous",
"sectionSelectId": "select_section"
}
]
\ No newline at end of file
......@@ -270,6 +270,7 @@
},
{
"id": "options",
"nodeType": "SectionParametree"
"nodeType": "SectionParametree",
"sectionSelectId": "select_section"
}
]
\ No newline at end of file
<div class="row">
<div class="col-12 mx-auto">
<log></log>
</div>
</div>
<div class="row">
<div class="col-8 mx-auto">
<chart *ngIf="showVarResults" [type]="graph_type" [data]="graph_data" [options]="graph_options">
</chart>
</div>
</div>
<!--
classe conditionnelle :
[ngClass]="(condition) ? 'classe-si-vrai' : 'classe-si-faux'"
-->
<div class="row">
<!-- table des résultats fixés -->
<div [ngClass]="(showVarResults) ? 'col-xs-12 col-sm-10 col-lg-8 col-xl-6 mx-auto':'col-xs-10 col-md-8 col-lg-6 col-xl-5 mx-auto'">
<div class="row">
<div [ngClass]="(showVarResults) ? 'col-6':'col-12'" *ngIf="showFixedResults">
<table class="table" style="border: 1px solid rgb(230,230,230);">
<tr>
<th class="result_center">{{uitextParamFixes}}</th>
<th class="result_center">{{uitextValeurs}}</th>
</tr>
<tr *ngFor="let r of _fixedResults; let i=index">
<td class="result_right {{getFixedResultClass(i)}}">{{r.label}}</td>
<td class="result_center {{getFixedResultClass(i)}}">{{r.value}}</td>
</tr>
</table>
</div>
<!-- table des résultats variés -->
<div class="col-6" *ngIf="showVarResults">
<table class="table table-striped" style="border: 1px solid rgb(230,230,230);">
<tr>
<th class="result_center">{{_variableParamHeader}}</th>
<th class="result_center">{{_variableResultHeader}}</th>
</tr>
<tr *ngFor="let r of _varResults; let i=index">
<td class="result_center">{{r.param}}</td>
<td class="result_center">{{r.result}}</td>
</tr>
</table>
</div>
</div>
<fixedvar-results [style.display]="getFixedVarResultsStyleDisplay()"> </fixedvar-results>
<section-results [style.display]="getSectionResultsStyleDisplay()"></section-results>
<remous-results [style.display]="getRemousResultsStyleDisplay()"></remous-results>
</div>
</div>
\ No newline at end of file
import { Component, ViewChild } from "@angular/core";
import { NgParameter } from "../../formulaire/ngparam";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
import { LogComponent } from '../../components/log/log.component';
import { cLog } from "jalhyd";
import { FixedVarResultsComponent } from "../../components/fixedvar-results/fixedvar-results.component";
import { SectionResultsComponent } from "../../components/section-results/section-results.component";
import { RemousResultsComponent } from "../../components/remous-results/remous-results.component";
import { FormulaireDefinition } from "../../formulaire/formulaire-definition";
@Component({
selector: "calc-results",
templateUrl: "./calculator-results.component.html",
styles: [`
.result_right {
text-align: right;
}
.result_center {
text-align: center;
}
.result_id_0 {
background-color: #f0f0f0;
}
.result_id_1 {
background-color: #ffffff;
}
.result_id_2 {
font-weight: bolder;
background-color: #00d0ff;
}
`
]
})
export class CalculatorResultsComponent {
/**
* résultats fixed (true) ou variés (false)
*/
private _isFixed: boolean;
private _fixedResults: Object[] = [];
/**
* affichage de la table des résultats fixés
*/
private get showFixedResults(): boolean {
return this._fixedResults.length > 0;
}
/**
* affichage de la table des résultats variés
*/
private get showVarResults(): boolean {
return this._varResults.length > 0;
}
private _variableParamHeader: string;
private _variableResultHeader: string;
private _formulaire: FormulaireDefinition;
/**
* tableau de valeurs de la table des résultats variés
* composant d'affichage des résultats de paramètres fixés/variables
*/
private _varResults: Object[] = [];
@ViewChild(FixedVarResultsComponent)
private fixedVarResultsComponent: FixedVarResultsComponent;
/**
* tableau de valeurs du graphe des résultats variés
* composant d'affichage des résultats des sections paramétrées
*/
private _varGraph: number[] = [];
/*
* config du graphe
*/
private graph_type = "line";
private graph_data = {};
private graph_options = {
responsive: true,
maintainAspectRatio: true,
animation: {
duration: 0
},
legend: {
display: false
},
title: {
display: true,
text: ""
}
};
@ViewChild(SectionResultsComponent)
private sectionResultsComponent: SectionResultsComponent;
/**
* composant journal
* composant d'affichage des résultats des courbes de remous
*/
@ViewChild(LogComponent)
private logComponent: LogComponent;
constructor(private intlService: InternationalisationService) {
}
private get uitextParamFixes() {
return this.intlService.localizeText("INFO_CALCULATOR_PARAMFIXES");
}
private get uitextValeurs() {
return this.intlService.localizeText("INFO_CALCULATOR_VALEURS");
}
public addFixedResult(p: NgParameter, v: number, fixedPrec: number, displaySymbol: boolean) {
this._fixedResults.push({ "label": this.paramLabel(p, displaySymbol), "value": v.toFixed(fixedPrec) });
}
public addVarResult(paramVal: number, resVal: number, fixedPrec: number) {
this._varResults.push({ "param": paramVal.toFixed(fixedPrec), "result": resVal.toFixed(fixedPrec) });
this._varGraph.push(resVal);
}
public addLogMessages(l: cLog) {
this.logComponent.addLogEntries(l);
}
public generateGraph() {
let labs = [];
let dat = [];
for (let i in this._varResults) {
let r = this._varResults[i];
labs.push(r["param"]);
dat.push(this._varGraph[i]);
}
this.graph_data = {
labels: labs,
datasets: [
{
label: "",
data: dat
}
]
};
}
public reset(fixed: boolean) {
this._isFixed = fixed;
this._fixedResults = [];
this._varResults = [];
this._varGraph = [];
this._variableParamHeader = undefined;
this._variableResultHeader = undefined;
this.graph_options.title.text = undefined;
this.logComponent.reset();
}
public setVariableParamHeader(h: string) {
this._variableParamHeader = h;
}
public setVariableParamHeaderFromParameter(p: NgParameter, displaySymbol: boolean) {
this._variableParamHeader = this.paramLabel(p, displaySymbol);
}
@ViewChild(RemousResultsComponent)
private remousResultsComponent: RemousResultsComponent;
public setVariableResultHeader(h: string) {
this._variableResultHeader = h;
public set formulaire(f: FormulaireDefinition) {
this._formulaire = f;
this.fixedVarResultsComponent.results = f.fixVarResults;
this.sectionResultsComponent.results = f.sectionResults;
this.remousResultsComponent.results = f.remousResults;
}
public setVariableResultHeaderFromParameter(p: NgParameter) {
this._variableResultHeader = this.paramLabel(p, true);
public updateView() {
this.fixedVarResultsComponent.updateView();
this.sectionResultsComponent.updateView();
this.remousResultsComponent.updateView();
}
public setGraphTitle(t: string) {
this.graph_options.title.text = t;
private getFixedVarResultsStyleDisplay() {
return this._formulaire != undefined && this._formulaire.hasFixVarResults() ? "block" : "none";
}
private paramLabel(p: NgParameter, displaySymbol: boolean): string {
let res = "";
if (displaySymbol)
res += p.symbol;
if (p.label != undefined && p.label != "")
if (p.symbol != p.label || !displaySymbol) {
if (res.length > 0)
res += ":";
res += p.label;
}
if (p.unit != undefined && p.unit != "")
res += " (" + p.unit + ")";
return res;
private getSectionResultsStyleDisplay() {
return this._formulaire != undefined && this._formulaire.hasSectionResults() ? "block" : "none";
}
private getFixedResultClass(i: number) {
if (this._isFixed && i == this._fixedResults.length - 1)
return "font-weight-bold";
return "result_id_" + String(i & 1);
private getRemousResultsStyleDisplay() {
return this._formulaire != undefined && this._formulaire.hasRemousResults() ? "block" : "none";
}
}
......@@ -45,7 +45,8 @@ export class CalcCanvasComponent implements AfterViewInit {
}
public clear() {
this._context2d.clearRect(0, 0, this.width, this.height);
if (this._context2d != undefined)
this._context2d.clearRect(0, 0, this.width, this.height);
}
public setStrokeColor(r: number, g: number, b: number) {
......
<div class="row">
<div class="col-12 mx-auto">
<log></log>
</div>
</div>
<div class="row">
<div class="col-8 mx-auto">
<chart *ngIf="showVarResults" [type]="graph_type" [data]="graph_data" [options]="graph_options">
</chart>
</div>
</div>
<!--
classe conditionnelle :
[ngClass]="(condition) ? 'classe-si-vrai' : 'classe-si-faux'"
-->
<div class="row">
<!-- table des résultats fixés -->
<div [ngClass]="(showVarResults) ? 'col-xs-12 col-sm-10 col-lg-8 col-xl-6 mx-auto':'col-xs-10 col-md-8 col-lg-6 col-xl-5 mx-auto'">
<div class="row">
<div [ngClass]="(showVarResults) ? 'col-6':'col-12'" *ngIf="showFixedResults">
<table class="table" style="border: 1px solid rgb(230,230,230);">
<tr>
<th class="result_center">{{uitextParamFixes}}</th>
<th class="result_center">{{uitextValeurs}}</th>
</tr>
<tr *ngFor="let r of _fixedResults; let i=index">
<td class="result_right {{getFixedResultClass(i)}}">{{r.label}}</td>
<td class="result_center {{getFixedResultClass(i)}}">{{r.value}}</td>
</tr>
</table>
</div>
<!-- table des résultats variés -->
<div class="col-6" *ngIf="showVarResults">
<table class="table table-striped" style="border: 1px solid rgb(230,230,230);">
<tr>
<th class="result_center">{{_results.variableParamHeader}}</th>
<th class="result_center">{{_results.variableResultHeader}}</th>
</tr>
<tr *ngFor="let r of _varResults; let i=index">
<td class="result_center">{{r.param}}</td>
<td class="result_center">{{r.result}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, ViewChild } from "@angular/core";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
import { ApplicationSetupService } from '../../services/app-setup/app-setup.service';
import { LogComponent } from '../../components/log/log.component';
import { cLog } from "jalhyd";
import { FixedVarResults } from "../../results/fixed-var-results";
@Component({
selector: "fixedvar-results",
templateUrl: "./fixedvar-results.component.html",
styles: [`
.result_right {
text-align: right;
}
.result_center {
text-align: center;
}
.result_id_0 {
background-color: #f0f0f0;
}
.result_id_1 {
background-color: #ffffff;
}
.result_id_2 {
font-weight: bolder;
background-color: #00d0ff;
}
`
]
})
export class FixedVarResultsComponent {
/**
* résultats non mis en forme
*/
private _results: FixedVarResults;
/**
* résultats fixed mis en forme
*/
private _fixedResults: Object[];
/**
* résultats fixed mis en forme
*/
private _varResults: Object[];
/*
* config du graphe
*/
private graph_type = "line";
private graph_data = {};
private graph_options = {
responsive: true,
maintainAspectRatio: true,
animation: {
duration: 0
},
legend: {
display: false
},
title: {
display: true,
text: ""
}
};
/**
* composant journal
*/
@ViewChild(LogComponent)
private logComponent: LogComponent;
constructor(
private intlService: InternationalisationService,
private appSetupService: ApplicationSetupService
) { }
public set results(r: FixedVarResults) {
this._results = r;
this.updateView();
}
public updateView() {
this._fixedResults = [];
this._varResults = [];
this.logComponent.log = undefined;
if (this._results != undefined)
this.generateResults();
}
private generateResults() {
const nDigits = this.appSetupService.displayDigits;
const prec = this.appSetupService.displayPrecision;
for (let r of this._results.fixedResults) {
let v = r["value"];
if (v > prec)
this._fixedResults.push({ "label": r["label"], "value": v.toFixed(nDigits) });
else
this._fixedResults.push({ "label": r["label"], "value": v });
}
for (let r of this._results.varResults)
this._varResults.push({ "param": r["param"].toFixed(nDigits), "result": r["result"].toFixed(nDigits) });
this.logComponent.log = this._results.log;
this.generateGraph();
}
/**
* affichage de la table des résultats fixés
*/
private get showFixedResults(): boolean {
return this._results != undefined && this._results.hasFixedResults();
}
/**
* affichage de la table des résultats variés
*/
private get showVarResults(): boolean {
return this._results != undefined && this._results.hasVarResults();
}
private get uitextParamFixes() {
return this.intlService.localizeText("INFO_CALCULATOR_PARAMFIXES");
}
private get uitextValeurs() {
return this.intlService.localizeText("INFO_CALCULATOR_VALEURS");
}
// public addFixedResult(p: NgParameter, v: number, fixedPrec: number, displaySymbol: boolean) {
// this._fixedResults.push({ "label": this.paramLabel(p, displaySymbol), "value": v.toFixed(fixedPrec) });
// }
// public addVarResult(paramVal: number, resVal: number, fixedPrec: number) {
// this._varResults.push({ "param": paramVal.toFixed(fixedPrec), "result": resVal.toFixed(fixedPrec) });
// this._varGraph.push(resVal);
// }
// public addLogMessages(l: cLog) {
// this.logComponent.addLogEntries(l);
// }
private generateGraph() {
let labs = [];
let dat = [];
for (let i in this._results.varResults) {
let r = this._results.varResults[i];
labs.push(r["param"]);
dat.push(this._results.varGraph[i]);
}
this.graph_options.title.text = this._results.graphTitle;
this.graph_data = {
labels: labs,
datasets: [
{
label: "",
data: dat
}
]
};
}
// public reset(fixed: boolean) {
// this._results.reset();
// this.logComponent.reset();
// }
// public setVariableParamHeader(h: string) {
// this._variableParamHeader = h;
// }
// public setVariableParamHeaderFromParameter(p: NgParameter, displaySymbol: boolean) {
// this._variableParamHeader = this.paramLabel(p, displaySymbol);
// }
// public setVariableResultHeader(h: string) {
// this._variableResultHeader = h;
// }
// public setVariableResultHeaderFromParameter(p: NgParameter) {
// this._variableResultHeader = this.paramLabel(p, true);
// }
// public setGraphTitle(t: string) {
// this.graph_options.title.text = t;
// }
// private paramLabel(p: NgParameter, displaySymbol: boolean): string {
// let res = "";
// if (displaySymbol)
// res += p.symbol;
// if (p.label != undefined && p.label != "")
// if (p.symbol != p.label || !displaySymbol) {
// if (res.length > 0)
// res += ":";
// res += p.label;
// }
// if (p.unit != undefined && p.unit != "")
// res += " (" + p.unit + ")";
// return res;
// }
private getFixedResultClass(i: number) {
if (this._results.isFixed && i == this._results.fixedResults.length - 1)
return "font-weight-bold";
return "result_id_" + String(i & 1);
}
}
......@@ -4,6 +4,7 @@ import { Message, cLog } from 'jalhyd';
import { NgParameter } from "../../formulaire/ngparam";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
import { ApplicationSetupService } from '../../services/app-setup/app-setup.service';
@Component({
......@@ -32,32 +33,39 @@ import { InternationalisationService } from "../../services/internationalisation
})
export class LogComponent {
/**
* entrées du journal
* journal
*/
private _log: cLog;
/**
* entrées du journal mises en forme
*/
private _logEntries: Object[];
private _logEntries: string[];
constructor(private intlService: InternationalisationService) {
this.reset();
}
constructor(
private intlService: InternationalisationService,
private appSetupService: ApplicationSetupService
) { }
private get uitextTitreJournal() {
return this.intlService.localizeText("INFO_REMOUSRESULTS_TITREJOURNAL")
}
private get hasEntries(): boolean {
return this._logEntries.length != 0;
return this._logEntries != undefined && this._logEntries.length != 0;
}
public reset() {
private generateEntries() {
this._logEntries = [];
if (this._log != undefined) {
const nDigits = this.appSetupService.displayDigits;
for (let m of this._log.messages)
this._logEntries.push(this.intlService.localizeMessage(m, nDigits));
}
}
public addLogEntry(m: Message, nDigits: number) {
this._logEntries.push(this.intlService.localizeMessage(m, nDigits));
}
public addLogEntries(l: cLog) {
for (let m of l.messages)
this._logEntries.push(this.intlService.localizeMessage(m));
public set log(log: cLog) {
this._log = log;
this.generateEntries();
}
}
......@@ -5,7 +5,7 @@
</div>
<div class="row">
<div class="col-10 mx-auto">
<chart *ngIf="_extraGraph" [type]="graph2_type" [data]="graph2_data" [options]="graph2_options"></chart>
<chart *ngIf="_results.extraGraph" [type]="graph2_type" [data]="graph2_data" [options]="graph2_options"></chart>
</div>
</div>
......@@ -31,12 +31,12 @@
<tr>
<th>{{uitextAbscisse}}</th>
<th>{{uitextTirant}}</th>
<th>{{_extraParamLabel}}</th>
<th>{{_results.extraParamLabel}}</th>
<th>{{uitextTirant}}</th>
<th>{{_extraParamLabel}}</th>
<th>{{_results.extraParamLabel}}</th>
</tr>
</thead>
<tr *ngFor="let r of _results; let i=index" [class]="getResultClass(i)">
<tr *ngFor="let r of _results.series; let i=index" [class]="getResultClass(i)">
<td>{{r.abs}}</td>
<td>{{r.flu}}</td>
<td>{{r.extraFlu}}</td>
......
......@@ -4,6 +4,7 @@ import { Message } from 'jalhyd';
import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
import { LogComponent } from '../../components/log/log.component';
import { RemousResults } from "../../results/remous-results";
@Component({
selector: 'remous-results',
......@@ -30,36 +31,7 @@ import { LogComponent } from '../../components/log/log.component';
]
})
export class RemousResultsComponent {
/**
* hauteur de berge
*/
private _hautBerge: number;
/**
* hauteur normale
*/
private _hautNormale: number;
/**
* hauteur critique
*/
private _hautCritique: number;
/**
* résultats numériques
*/
private _results: Object[] = [];
/**
* présence d'un paramètre supplémentaire
*/
private _hasExtra: boolean;
/**
* titre de la colonne du paramètre supplémentaire
*/
private _extraParamLabel: string;
private _results: RemousResults;
/*
* config du graphe principal
......@@ -75,18 +47,12 @@ export class RemousResultsComponent {
private graph2_data = {};
private graph2_options = {};
/**
* le paramètre supplémentaire est affiché dans un graphe séparé
*/
private _extraGraph: boolean;
/**
* composant journal
*/
@ViewChild(LogComponent)
private logComponent: LogComponent;
constructor(private intlService: InternationalisationService) {
}
......@@ -122,20 +88,21 @@ export class RemousResultsComponent {
return this.intlService.localizeText("INFO_REMOUSRESULTS_TIRANTCRITIQUE")
}
public reset() {
this._results = [];
this.logComponent.reset();
this._extraParamLabel = undefined;
this._hasExtra = false;
this._extraGraph = false;
public set results(r: RemousResults) {
this._results = r;
this.updateView();
}
public updateView() {
this.graph1_data = {};
this.graph1_options = {};
this.graph2_data = {};
this.graph2_options = {};
}
public set extraParamLabel(l: string) {
this._extraParamLabel = l;
this.logComponent.log = undefined;
if (this._results != undefined) {
this.logComponent.log = this._results.log;
this.generateGraph();
}
}
private searchObjectInArray(array: any[], key: string, value: any) {
......@@ -159,7 +126,7 @@ export class RemousResultsComponent {
let minXflu; // abscisse de début de la courbe fluviale
for (let x of tX) {
let r = this.searchObjectInArray(this._results, "abs", x);
let r = this.searchObjectInArray(this._results.series, "abs", x);
if (r["flu"] != "") {
minXflu = x;
break;
......@@ -178,7 +145,7 @@ export class RemousResultsComponent {
let maxXtor; // abscisse de fin de la courbe torrentielle
tX.reverse();
for (let x of tX) {
let r = this.searchObjectInArray(this._results, "abs", x);
let r = this.searchObjectInArray(this._results.series, "abs", x);
if (r["tor"] != "") {
maxXtor = x;
break;
......@@ -196,15 +163,17 @@ export class RemousResultsComponent {
}
}
public generateGraph(penteFond: number) {
private generateGraph() {
// http://www.chartjs.org/docs/latest/charts/line.html
// le dernier dataset de la liste datasets est dessiné en 1er
const penteFond: number = this._results.penteFond;
// abscisses
let labs: number[] = [];
let xmax = -1e8;
for (let r of this._results) {
for (let r of this._results.series) {
let x = +r["abs"];
labs.push(x);
xmax = Math.max(x, xmax);
......@@ -213,33 +182,33 @@ export class RemousResultsComponent {
// init graphiques
let gr1 = new GraphData(labs, penteFond, xmax);
if (this._extraGraph)
if (this._results.extraGraph)
var gr2 = new GraphData(labs, 0, xmax);
// ligne de fond
gr1.drawLine(0, 0, 3, "#753F00", this.uitextFond, "#753F00");
// ligne de berge
gr1.drawLine(this._hautBerge, this._hautBerge, 4, "#C58F50", this.uitextBerge);
gr1.drawLine(this._results.hautBerge, this._results.hautBerge, 4, "#C58F50", this.uitextBerge);
// hauteur normale
gr1.drawLine(this._hautNormale, this._hautNormale, 5, "#A4C537", this.uitextTirantNormal);
gr1.drawLine(this._results.hautNormale, this._results.hautNormale, 5, "#A4C537", this.uitextTirantNormal);
// hauteur critique
gr1.drawLine(this._hautCritique, this._hautCritique, 6, "#FF0000", this.uitextTirantCritique);
gr1.drawLine(this._results.hautCritique, this._results.hautCritique, 6, "#FF0000", this.uitextTirantCritique);
// lignes d'eau torrentielle et fluviale
let lineFlu = gr1.newLine(0);
let lineTor = gr1.newLine(1);
if (this._hasExtra) {
if (this._extraGraph)
if (this._results.hasExtra) {
if (this._results.extraGraph)
var lineExtra = gr2.newLine(2);
else
lineExtra = gr1.newLine(2);
}
for (let r of this._results) {
for (let r of this._results.series) {
let x: number = +r["abs"];
let yFlu: string = r["flu"];
let yTor: string = r["tor"];
......@@ -256,11 +225,11 @@ export class RemousResultsComponent {
lineExtra.mapPoint(x, +yExtra);
}
if (this._hasExtra) {
if (this._extraGraph)
lineExtra.data = { label: this._extraParamLabel, tension: 0, spanGaps: true, borderColor: "#0093BD", pointRadius: 4 };
if (this._results.hasExtra) {
if (this._results.extraGraph)
lineExtra.data = { label: this._results.extraParamLabel, tension: 0, spanGaps: true, borderColor: "#0093BD", pointRadius: 4 };
else
lineExtra.data = { label: this._extraParamLabel, tension: 0, fill: false, spanGaps: true, borderColor: "#C17AF0", pointRadius: 4 };
lineExtra.data = { label: this._results.extraParamLabel, tension: 0, fill: false, spanGaps: true, borderColor: "#C17AF0", pointRadius: 4 };
}
// raccordement ligne fluviale -> torrentielle pour dessiner le ressaut
......@@ -291,7 +260,7 @@ export class RemousResultsComponent {
}
};
if (this._extraGraph) {
if (this._results.extraGraph) {
this.graph2_data = gr2.data;
this.graph2_options = {
......@@ -313,34 +282,6 @@ export class RemousResultsComponent {
}
}
public addResult(x: string, flu: string, tor: string, extra: string) {
let extraFlu = (flu == "" ? "" : extra);
let extraTor = (tor == "" ? "" : extra);
if (extraFlu != "" || extraTor != "")
this._hasExtra = true;
this._results.push({ "abs": x, "flu": flu, "extraFlu": extraFlu, "tor": tor, "extraTor": extraTor });
}
public addLogEntry(m: Message, nDigits: number) {
this.logComponent.addLogEntry(m, nDigits);
}
public setHauteurBerge(v: number) {
this._hautBerge = v;
}
public setHauteurNormale(v: number) {
this._hautNormale = v;
}
public setHauteurCritique(v: number) {
this._hautCritique = v;
}
public set extraGraph(b: boolean) {
this._extraGraph = b;
}
private getResultClass(i: number) {
return "result_id_" + String(i & 1);
}
......
......@@ -3,6 +3,8 @@ import { Component, ViewChild } from '@angular/core';
import { acSection } from 'jalhyd';
import { SectionCanvasComponent } from '../section-canvas/section-canvas.component';
import { SectionResults } from '../../results/section-results';
import { ApplicationSetupService } from '../../services/app-setup/app-setup.service';
@Component({
selector: 'section-results',
......@@ -30,9 +32,16 @@ import { SectionCanvasComponent } from '../section-canvas/section-canvas.compone
})
export class SectionResultsComponent {
/**
* résultats
* résultats non mis en forme
*/
private _results: Object[] = [];
private _sectionResults: SectionResults;
/**
* résultats mis en forme
*/
private _results: Object[];
constructor(private appSetupService: ApplicationSetupService) { }
private static labelColors: { [key: string]: any; } = {
"Hs": { r: 255, g: 0, b: 0 },
......@@ -47,19 +56,33 @@ export class SectionResultsComponent {
@ViewChild("sectionCanvas")
private _sectionCanvas: SectionCanvasComponent;
public reset() {
public set results(r: SectionResults) {
this._sectionResults = r;
this.updateView();
}
public updateView() {
this._results = [];
this._sectionCanvas.reset();
if (this._sectionResults != undefined)
this.formatResults();
}
public set section(section: acSection) {
this._sectionCanvas.section = section;
}
private formatResults() {
if (this._sectionResults.results.length > 0) {
const nDigits = this.appSetupService.displayDigits;
for (let r of this._sectionResults.results) {
const v = r["value"];
const l = r["label"];
this._results.push({ "label": l, "value": v.toFixed(nDigits) });
public addResult(v: number, l: string, fixedPrec: number, drawLabel: string) {
this._results.push({ "label": l, "value": v.toFixed(fixedPrec) });
if (drawLabel != undefined) {
this._sectionCanvas.addLevel(v, drawLabel + " = " + v.toFixed(fixedPrec), SectionResultsComponent.labelColors[drawLabel]);
const drawLabel = r["drawLabel"];
if (drawLabel != undefined)
this._sectionCanvas.addLevel(v, drawLabel + " = " + v.toFixed(nDigits), SectionResultsComponent.labelColors[drawLabel]);
}
this._sectionCanvas.section = this._sectionResults.section;
}
}
......
This diff is collapsed.
import { NgParameter } from "../formulaire/ngparam";
export abstract class CalculatorResults {
protected paramLabel(p: NgParameter, displaySymbol: boolean): string {
let res = "";
if (displaySymbol)
res += p.symbol;
if (p.label != undefined && p.label != "")
if (p.symbol != p.label || !displaySymbol) {
if (res.length > 0)
res += ":";
res += p.label;
}
if (p.unit != undefined && p.unit != "")
res += " (" + p.unit + ")";
return res;
}
/**
* remet tous les résultats à zero
*/
public abstract reset();
/**
* indique si il existe des résultats à afficher
*/
public abstract hasResults(): boolean;
}
\ No newline at end of file
import { cLog } from "jalhyd";
import { NgParameter } from "../formulaire/ngparam";
import { CalculatorResults } from "./calculator-results";
export class FixedVarResults extends CalculatorResults {
/**
* résultats fixed (true) ou variés (false)
*/
private _isFixed: boolean;
/**
* liste des résultats avec tous les paramètres fixés
*/
private _fixedResults: Object[];
/**
* liste des résultats avec un paramètre variable
*/
private _varResults: Object[];
/**
* titre de la 1ère colonne des résultats variés
*/
private _variableParamHeader: string;
/**
* titre de la 2ème colonne des résultats variés
*/
private _variableResultHeader: string;
/**
* titre du graphe des résultats variés
*/
private _graphTitle: string;
/**
* tableau de valeurs du graphe des résultats variés
*/
private _varGraph: number[] = [];
/**
* journal de calcul
*/
private _log: cLog;
constructor() {
super();
this.reset();
}
public get log() {
return this._log;
}
public get fixedResults() {
return this._fixedResults;
}
public get varResults() {
return this._varResults;
}
public get varGraph() {
return this._varGraph;
}
public get isFixed() {
return this._isFixed;
}
public reset() {
this._isFixed = true;
this._fixedResults = [];
this._varResults = [];
this._varGraph = [];
this._variableParamHeader = undefined;
this._variableResultHeader = undefined;
this._graphTitle = undefined;
this._log = new cLog();
}
public addFixedResult(p: NgParameter, v: number, displaySymbol: boolean) {
this._fixedResults.push({ "label": this.paramLabel(p, displaySymbol), "value": v });
}
public addVarResult(paramVal: number, resVal: number) {
this._isFixed = false;
this._varResults.push({ "param": paramVal, "result": resVal });
this._varGraph.push(resVal);
}
public addLogMessages(l: cLog) {
for (let m of l.messages)
this._log.add(m);
}
public get variableParamHeader() {
return this._variableParamHeader;
}
public setVariableParamHeaderFromParameter(p: NgParameter, displaySymbol: boolean) {
this._variableParamHeader = this.paramLabel(p, displaySymbol);
}
public get variableResultHeader() {
return this._variableResultHeader;
}
public setVariableResultHeader(h: string) {
this._variableResultHeader = h;
}
public setVariableResultHeaderFromParameter(p: NgParameter) {
this._variableResultHeader = this.paramLabel(p, true);
}
public get graphTitle() {
return this._graphTitle;
}
public set graphTitle(t: string) {
this._graphTitle = t;
}
public hasFixedResults(): boolean {
return this._fixedResults.length > 0;
}
public hasVarResults(): boolean {
return this._varResults.length > 0;
}
public hasResults(): boolean {
return this.hasFixedResults() || this.hasVarResults();
}
}
import { CalculatorResults } from "./calculator-results";
import { cLog } from "jalhyd";
export class RemousResults extends CalculatorResults {
/**
* hauteur de berge
*/
private _hautBerge: number;
/**
* pente du fond
*/
private _penteFond: number;
/**
* hauteur normale
*/
private _hautNormale: number;
/**
* hauteur critique
*/
private _hautCritique: number;
/**
* résultats numériques
*/
private _series: Object[] = [];
/**
* présence d'un paramètre supplémentaire
*/
private _hasExtra: boolean;
/**
* le paramètre supplémentaire est affiché dans un graphe séparé
*/
private _extraGraph: boolean;
/**
* titre de la colonne du paramètre supplémentaire
*/
private _extraParamLabel: string;
/**
* journal de calcul
*/
private _log: cLog;
constructor() {
super();
this.reset();
}
public reset() {
this._series = [];
this._log = new cLog();
this._extraParamLabel = undefined;
this._hasExtra = false;
this._extraGraph = false;
}
public get log() {
return this._log;
}
public set log(l: cLog) {
this._log = l;
}
public get series() {
return this._series;
}
public addResult(x: string, flu: string, tor: string, extra: string) {
let extraFlu = (flu == "" ? "" : extra);
let extraTor = (tor == "" ? "" : extra);
if (extraFlu != "" || extraTor != "")
this._hasExtra = true;
this._series.push({ "abs": x, "flu": flu, "extraFlu": extraFlu, "tor": tor, "extraTor": extraTor });
}
public get extraParamLabel() {
return this._extraParamLabel;
}
public set extraParamLabel(l: string) {
this._extraParamLabel = l;
}
// public addLogEntry(m: Message, nDigits: number) {
// this.logComponent.addLogEntry(m, nDigits);
// }
public get hautBerge() {
return this._hautBerge;
}
public set hauteurBerge(v: number) {
this._hautBerge = v;
}
public get penteFond() {
return this._penteFond;
}
public set penteFond(v: number) {
this._penteFond = v;
}
public get hautNormale() {
return this._hautNormale;
}
public set hauteurNormale(v: number) {
this._hautNormale = v;
}
public get hautCritique() {
return this._hautCritique;
}
public set hauteurCritique(v: number) {
this._hautCritique = v;
}
public get hasExtra() {
return this._hasExtra;
}
public get extraGraph() {
return this._extraGraph;
}
public set extraGraph(b: boolean) {
this._extraGraph = b;
}
public hasResults(): boolean {
return this._series.length > 0;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment