Skip to content

Commit 07ce9ca

Browse files
committed
V0.09.09h 2023/03/12
* Added: - GUI: working for inputs settings, circuits shown and results GUI debug output still goes to CLI - GUI: read custom formula from text entry - GUI: read custom values from text entry - GUI: extend textView vertically when window increase height - GUI: force refresh output while heavy calculation - GUI: autoscroll to last line - show allocated memory with SI prefix k,M,G,T - show calc and sort progress as percentage - generation of Linux AppImage
1 parent 84625ef commit 07ce9ca

18 files changed

+44
-23
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,28 @@ V0.09.09h 2023/03/12
286286
GUI debug output still goes to CLI
287287
- GUI: read custom formula from text entry
288288
- GUI: read custom values from text entry
289-
- GUI: output force refresh while heavy calculation
289+
- GUI: extend textView vertically when window increase height
290+
- GUI: force refresh output while heavy calculation
290291
- GUI: autoscroll to last line
291292
- show allocated memory with SI prefix k,M,G,T
293+
- show calc and sort progress as percentage
292294
- generation of Linux AppImage
293295

294296
ToDo:
295297
-----
296-
- show calc and sort progress as percent
297298
- On memory low: option to keep only the first N best results and discard
298299
others, autosorting of results while keeping first N best results
299300
- On memory low: save block of results to disk and deallocate memory
300301
- remove duplicated triangular solutions with MaxRp=2
301-
- first print exact results, separated by approximate results
302+
- print exact results, separated by approximate results
302303
- separate value below and over the target value (show delta sign)
303304
- support for 0 Ohm value in formula denominator (division by 0)
304305
- add support for variables with an index number. Es. R1, R2
305306
- add support for variables/letters other than a-b. Autoinit values
306307
- Made generic the number of total values, based on variables number in formula
307308
- For each position of resistance in circuit, add support for 'Rp' resistances
308309
in series or parallel. Probably not possible with current resources.
310+
- make a distribution package for macOS
309311
- GUI: working Stop and About buttons
310312
- GUI: better circuit images
311313
- GUI: show best results value in circuit

ReSolveGUI.png

27.9 KB
Loading

ReSolveGui-i386.AppImage

8 KB
Binary file not shown.

ReSolveGui-x86_64.AppImage

8 KB
Binary file not shown.

circuit03.png

8.88 KB
Loading

circuit03p.png

-250 Bytes
Loading

reSolve.glade

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Author: Valerio Messina
2323
-->
2424
<!-- GUI resource file for reSolve -->
2525
<interface>
26-
<requires lib="gtk+" version="3.6"/>
26+
<requires lib="gtk+" version="3.22"/>
2727
<!-- interface-license-type lgplv3 -->
2828
<!-- interface-name ReSolve -->
2929
<!-- interface-copyright 2022-2023 Valerio Messina -->
@@ -53,6 +53,7 @@ Author: Valerio Messina
5353
<object class="GtkBox">
5454
<property name="visible">True</property>
5555
<property name="can-focus">False</property>
56+
<property name="vexpand">True</property>
5657
<property name="orientation">vertical</property>
5758
<child>
5859
<object class="GtkBox">
@@ -391,11 +392,11 @@ operators: +,-,*,/,%,^, parentesis () with any depth</property>
391392
<property name="shadow-type">in</property>
392393
<property name="min-content-width">642</property>
393394
<property name="min-content-height">342</property>
395+
<property name="propagate-natural-height">True</property>
394396
<child>
395397
<object class="GtkTextView" id="textview">
396398
<property name="visible">True</property>
397399
<property name="can-focus">True</property>
398-
<property name="vexpand">True</property>
399400
<property name="editable">False</property>
400401
<property name="wrap-mode">char</property>
401402
<property name="buffer">output</property>

reSolveGuiLinux32

0 Bytes
Binary file not shown.

reSolveGuiLinux64

0 Bytes
Binary file not shown.

reSolveGuiWin32.exe

0 Bytes
Binary file not shown.

reSolveGuiWin64.exe

512 Bytes
Binary file not shown.

reSolveLinux32

0 Bytes
Binary file not shown.

reSolveLinux64

0 Bytes
Binary file not shown.

reSolveReadme.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,28 @@ V0.09.09h 2023/03/12
286286
GUI debug output still goes to CLI
287287
- GUI: read custom formula from text entry
288288
- GUI: read custom values from text entry
289-
- GUI: output force refresh while heavy calculation
289+
- GUI: extend textView vertically when window increase height
290+
- GUI: force refresh output while heavy calculation
290291
- GUI: autoscroll to last line
291292
- show allocated memory with SI prefix k,M,G,T
293+
- show calc and sort progress as percentage
292294
- generation of Linux AppImage
293295

294296
ToDo:
295297
-----
296-
- show calc and sort progress as percent
297298
- On memory low: option to keep only the first N best results and discard
298299
others, autosorting of results while keeping first N best results
299300
- On memory low: save block of results to disk and deallocate memory
300301
- remove duplicated triangular solutions with MaxRp=2
301-
- first print exact results, separated by approximate results
302+
- print exact results, separated by approximate results
302303
- separate value below and over the target value (show delta sign)
303304
- support for 0 Ohm value in formula denominator (division by 0)
304305
- add support for variables with an index number. Es. R1, R2
305306
- add support for variables/letters other than a-b. Autoinit values
306307
- Made generic the number of total values, based on variables number in formula
307308
- For each position of resistance in circuit, add support for 'Rp' resistances
308309
in series or parallel. Probably not possible with current resources.
310+
- make a distribution package for macOS
309311
- GUI: working Stop and About buttons
310312
- GUI: better circuit images
311313
- GUI: show best results value in circuit

reSolveWin32.exe

0 Bytes
Binary file not shown.

reSolveWin64.exe

0 Bytes
Binary file not shown.

src/reSolveGui.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void aboutButton(GtkWidget* widgetPtr, gpointer dataPtr) {
380380
g_print("About button\n");
381381
}
382382

383-
int quit() {
383+
int quit() { // called also on Window destroy
384384
// free mem allocated by fillConfigVars()
385385
if (baseR) free (baseR);
386386
if (baseRconf) free (baseRconf);
@@ -501,28 +501,32 @@ int guiInit(int argc, char *argv[]) {
501501

502502
/* Construct a GtkBuilder instance and load our UI description */
503503
builderPtr = gtk_builder_new();
504-
504+
//printf ("Try to load 'reSolve.glade'\n");
505505
#if 0
506-
GError* errorPtr = NULL;
507-
if (gtk_builder_add_from_file(builderPtr, "reSolve.glade", &errorPtr) == 0) {
508-
g_printerr ("Error loading file: %s\n", errorPtr->message);
509-
g_clear_error (&errorPtr);
510-
return 1;
511-
}
512-
#endif
513506
builderPtr=gtk_builder_new_from_file("reSolve.glade");
507+
printf ("gtk_builder_new_from_file() returned:%p\n", builderPtr);
514508
if (builderPtr == NULL) {
515509
//g_printerr ("Error loading file: %s\n", errorPtr->message);
516510
//g_clear_error (&errorPtr);
511+
printf ("'reSolve.glade' not found, quit\n");
517512
return 1;
518513
}
514+
#endif
515+
GError* errorPtr = NULL;
516+
gboolean bit;
517+
bit = gtk_builder_add_from_file(builderPtr, "reSolve.glade", &errorPtr);
518+
if (bit == 0) {
519+
g_printerr ("Error loading file: %s\n", errorPtr->message);
520+
g_clear_error (&errorPtr);
521+
return 1;
522+
}
523+
//printf ("'reSolve.glade' loaded\n");
519524

520525
/* Connect signal handlers to the constructed widgets */
521526
windowPtr = gtk_builder_get_object (builderPtr, "window");
522527
g_signal_connect (windowPtr, "destroy", G_CALLBACK(quit), NULL);
523528

524529
//gtk_builder_connect_signals(builderPtr, NULL); // seems unnecessary
525-
526530
widgetPtr = gtk_builder_get_object (builderPtr, "formulaList");
527531
g_signal_connect (widgetPtr, "changed", G_CALLBACK(formulaPre), NULL);
528532
widgetPtr = gtk_builder_get_object (builderPtr, "formula");
@@ -681,6 +685,10 @@ int main(int argc, char *argv[]) {
681685
gtk_disable_setlocale();
682686
printf ("Starting GUI ...\n");
683687
ret = guiInit(argc, argv);
688+
if (ret!=0) {
689+
printf ("GUI cannot be initialized, quit\n");
690+
exit (1);
691+
}
684692
ret = guiUpdateIn();
685693

686694
//ret=runReSolve(); // steps 6 to 12 called by widget callbacks

src/reSolveLib.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ int calcRvalues(void) { /* in series or parallel, support MaxRp=2 only */
626626
int calcFvalues(void) {
627627
u32 rc1, rc2;
628628
/*float res[maxRc];*/ /* single case, normally 2 resistances */
629+
register u64 per; // percentage progress
629630
register double val;
630631
register double delta = 0;
631632
register u32 pos = 0;
@@ -649,13 +650,16 @@ int calcFvalues(void) {
649650
results[pos].delta = delta;
650651
pos++;
651652
}
652-
if (rc1%1000==0) {
653-
if (dbgLv>=PRINTF) gprintf (gui, "%u,", rc1*numV);
653+
if (rc1%1000==0) { // here print something for user feedback (take time)
654+
//if (dbgLv>=PRINTF) gprintf (gui, "%u,", rc1*numV);
655+
per=(u64)rc1*numV*100/totV;
656+
if (dbgLv>=PRINTF) gprintf (gui, "%d%%,", per);
654657
fflush (NULL); // user space stdout flush
655658
fsync (1); // kernel space stdout flush
656659
}
657660
}
658-
if (dbgLv>=PRINTF) gprintf (gui, "%u\n", rc1*numV-1);
661+
//if (dbgLv>=PRINTF) gprintf (gui, "%u\n", rc1*numV-1); // here print something for user feedback (take time)
662+
if (dbgLv>=PRINTF) gprintf (gui, "100%\n"); // here print something for user feedback (take time)
659663
return (OK);
660664
} // int calcFvalues(void) {
661665

@@ -665,11 +669,14 @@ s32 tot; // used for communication between 'structQuickSort' & 'qsStruct'
665669
/* Sorting criteria: field 'abs(delta)' */
666670
void qsStruct(struct resultsTy results[], s32 left, s32 right) {
667671
register s32 l, r, m; /* position left, right and median */
672+
register u64 per; // percentage progress
668673
float mp; /* will contain data in center position */
669674
struct resultsTy temp; /* temp struct for swap */
670675
static u32 qs=0;
671676
if (qs%20000000==0) {
672-
if (dbgLv>=PRINTF) gprintf (gui, "%u,", qs);
677+
//if (dbgLv>=PRINTF) gprintf (gui, "%u,", qs);
678+
per=(u64)qs*100/tot;
679+
if (dbgLv>=PRINTF) gprintf (gui, "%d%%,", per);
673680
fflush (NULL); // user space stdout flush
674681
fsync (1); // kernel space stdout flush
675682
}
@@ -733,7 +740,8 @@ int structQuickSort(struct resultsTy results[], s32 totNumber) {
733740
fsync (1); // kernel space stdout flush
734741
}
735742
qsStruct (results, 0UL, totNumber-1);
736-
if (dbgLv>=PRINTF) gprintf (gui, "%d\n", totNumber-1);
743+
//if (dbgLv>=PRINTF) gprintf (gui, "%d\n", totNumber-1);
744+
if (dbgLv>=PRINTF) gprintf (gui, "100%%\n");
737745
if (dbgLv>=PRINTDEBUG) {
738746
for (s32 c=0; c<tot; c++) {
739747
printf ("f[%2d]=%11G\n", c, results[c].delta);

0 commit comments

Comments
 (0)