changes fixed the Histogram display but spoilt the Geometry display 
Author Message
 changes fixed the Histogram display but spoilt the Geometry display

Here we are again with the buggy Tcl GUI ... sigh ..

The format conversion error that popped up with histograms
visualization was fixed by applying the following  changes to the
procedure format_vis:

proc format_vis { num ticksfmt } {
# Accomodate integer overflows.
  if {![string match *.* $num]} {
     append num .
   }

And moreover replacing the original, now commented statement, with the
following one.
# set num_pnt [expr $num-int($num)]
                set num_pnt [expr fmod($num, 1.)]

The above modifications solved the histograms display. But the changed
procedure is, unfortunately, called by many different places. .. So
when the simple collider gepometry is displayed the procedure in
question is called as well ... and the latest changes make the
following error message to pop up:
"Error: syntax error in expression 'fmod(.,1.)"
The stack Trace has recorded the following:

syntax error in expression "fmod(., 1.)"
    while executing
"expr fmod($num, 1.)"
    (procedure "format_vis" line 38)
    invoked from within
"format_vis $hst_id """
    (procedure "show_info_frame" line 113)
    invoked from within
"show_info_frame 393 190"
    (command bound to event)

I stuffed the procedure format_vis with puts statement to narrow down
the problem which seems to be, as far as I can tell, a call to proc
format_vis where both argument are empty strings. Every time I click on
any point on the displayed collider geometry slice I printed out a
reference to the proc format_vis call and the parameters it is passed
on the current call:

% geo_h calling format_vis
ticksfmt: %8.0f
num: 19.1666666667
geo_v calling format_vis
ticksfmt: %8.0f
num: 17.3574074074
*** fld_id *** calling format_vis
BEFORE fld_id:   0.00000e+00
ticksfmt:
AFTER fld_id: 0.0
*** hst_id *** calling format_vis
BEFORE hst_id:
ticksfmt:
num: .

In the following I'm copying the last version of the incriminated proc
...
Hopefully someone can give me some good advice how to fix that ...
Thank you so much in advance.
Maura

********************************************************************************************************************
proc format_vis { num ticksfmt } {

puts "ticksfmt: $ticksfmt"

# Accomodate integer overflows.
  if {![string match *.* $num]} {
     append num .
   }

    set intfmt   "%8.1f"
    set floatfmt "%8.4f"
    set scienfmt "%8.2e"

    set res ""

    if { $num != "" } {

        set res "0.0"

        if { $num != 0.0 } {

            if { $ticksfmt != "" } {
                if { [string first "f" $ticksfmt] > 0 } {
                    if { [string first "12" $ticksfmt] > 0 } {
                        set res [format $ticksfmt $num]
                    } else {
                        if { [string first "20" $ticksfmt] > 0 } {
                            set res [format $ticksfmt $num]
                        }
                    }
                }
            }

            if { $res == "0.0" } {

# set num_pnt [expr $num-int($num)]
                puts "num: $num"
                set num_pnt [expr fmod($num, 1.)]
                if { [expr abs($num_pnt)] < 0.00001 } {
                    set res [format $intfmt $num]
                } else {proc format_vis { num ticksfmt } {

puts "ticksfmt: $ticksfmt"

# Accomodate integer overflows.
  if {![string match *.* $num]} {
     append num .
   }

    set intfmt   "%8.1f"
    set floatfmt "%8.4f"
    set scienfmt "%8.2e"

    set res ""

    if { $num != "" } {

        set res "0.0"

        if { $num != 0.0 } {

            if { $ticksfmt != "" } {
                if { [string first "f" $ticksfmt] > 0 } {
                    if { [string first "12" $ticksfmt] > 0 } {
                        set res [format $ticksfmt $num]
                    } else {
                        if { [string first "20" $ticksfmt] > 0 } {
                            set res [format $ticksfmt $num]
                        }
                    }
                }
            }

            if { $res == "0.0" } {

# set num_pnt [expr $num-int($num)]
                puts "num: $num"
                set num_pnt [expr fmod($num, 1.)]
                if { [expr abs($num_pnt)] < 0.00001 } {
                    set res [format $intfmt $num]
                } else {
                    set res [format $floatfmt $num]
                }
proc format_vis { num ticksfmt } {

puts "ticksfmt: $ticksfmt"

# Accomodate integer overflows.
  if {![string match *.* $num]} {
     append num .
   }

    set intfmt   "%8.1f"
    set floatfmt "%8.4f"
    set scienfmt "%8.2e"

    set res ""

    if { $num != "" } {

        set res "0.0"

        if { $num != 0.0 } {

            if { $ticksfmt != "" } {
                if { [string first "f" $ticksfmt] > 0 } {
                    if { [string first "12" $ticksfmt] > 0 } {
                        set res [format $ticksfmt $num]
                    } else {
                        if { [string first "20" $ticksfmt] > 0 } {
                            set res [format $ticksfmt $num]
                        }
                    }
                }
            }

            if { $res == "0.0" } {

# set num_pnt [expr $num-int($num)]
                puts "num: $num"
                set num_pnt [expr fmod($num, 1.)]
                if { [expr abs($num_pnt)] < 0.00001 } {
                    set res [format $intfmt $num]
                } else {
                    set res [format $floatfmt $num]
                }

                if { $num > 9999.9999 } {
                    set res [format $scienfmt $num]
                } else {
                    if { $num < -9999.9999 } {
                        set res [format $scienfmt $num]
                    } else {
                        if { $num < 0.0001 } {
                            if { $num > -0.0001 } {
                                set res [format $scienfmt $num]
                            }
                        }
                    }
                }
            }
        }
    }
    return $res

Quote:
}

                if { $num > 9999.9999 } {
                    set res [format $scienfmt $num]
                } else {
                    if { $num < -9999.9999 } {
                        set res [format $scienfmt $num]
                    } else {
                        if { $num < 0.0001 } {
                            if { $num > -0.0001 } {
                                set res [format $scienfmt $num]
                            }
                        }
                    }
                }
            }
        }
    }
    return $res

Quote:
}

                    set res [format $floatfmt $num]
                }

                if { $num > 9999.9999 } {
                    set res [format $scienfmt $num]
                } else {
                    if { $num < -9999.9999 } {
                        set res [format $scienfmt $num]
                    } else {
                        if { $num < 0.0001 } {
                            if { $num > -0.0001 } {
                                set res [format $scienfmt $num]
                            }
                        }
                    }
                }
            }
        }
    }
    return $res

Quote:
}

********************************************************************************************************************


Sat, 18 Oct 2008 03:52:56 GMT  
 changes fixed the Histogram display but spoilt the Geometry display

Quote:

> Here we are again with the buggy Tcl GUI ... sigh ..

> The format conversion error that popped up with histograms
> visualization was fixed by applying the following  changes to the
> procedure format_vis:

> proc format_vis { num ticksfmt } {
> # Accomodate integer overflows.
>   if {![string match *.* $num]} {
>      append num .
>    }

> And moreover replacing the original, now commented statement, with the
> following one.
> # set num_pnt [expr $num-int($num)]
>                 set num_pnt [expr fmod($num, 1.)]

> The above modifications solved the histograms display. But the changed
> procedure is, unfortunately, called by many different places. .. So
> when the simple collider gepometry is displayed the procedure in
> question is called as well ... and the latest changes make the
> following error message to pop up:
> "Error: syntax error in expression 'fmod(.,1.)"
> The stack Trace has recorded the following:

> syntax error in expression "fmod(., 1.)"
>     while executing
> "expr fmod($num, 1.)"

OK, this shows the $num is just ".", which given the above
statement to look for a dot and append one if need be means that
the function was called with empty string for num.

I see in other parts of that proc that $num is checked for being
empty - but with your addition above this won't be true.

A couple of options - Don't just add the dot at the front of the proc
do that only when you are about to use $num as a number - then the blank
checks will still work, or change the above to:

# Accomodate integer overflows.
   if {![string match *.* $num] && $num != ""} {
      append num .
    }
so blank nums stay blank and the rest of the logic works.

Now from an overall standpoint I would say that proc needs
serious rework (as well as probably many of the places that
call it) but I understand that you real job is to do physics
not play with code, so hopefully this will get you going along
until the next bit bytes you ;)

Good Luck,
   Bruce



Sat, 18 Oct 2008 04:36:46 GMT  
 changes fixed the Histogram display but spoilt the Geometry display
Thank you very much.
It makes sense that a math function cannot be applied to a string....
Your patch works.
But there are some other problems that hopefully/presumably are not
related to the proc in question.
I've just found out that when the GUI is heavily stimulated, I mean whe
I try to load different histograms consecutively then it dies with
core-dump.

You're perfectly right at stating that the whole GUI should be
rewritten from scratch rather than patched up. But the plan is to make
the current Mars users happy with the current GUI and then move on and
implement a 3-D GUI that allows for volume rendering of the collider
zones and 3-D rotations and cutting the volume with an arbitrary plain,
etc ...
I do not think Tcl/Tk is the proper tool to do that but I might be very
mistaken as I'm new to it.

Unluckily i still have a couple more gui-related problems to patch up.

Thank you very much for your help.

Regards,
Maura



Sat, 18 Oct 2008 06:23:28 GMT  
 changes fixed the Histogram display but spoilt the Geometry display


Quote:
> Thank you very much.
> It makes sense that a math function cannot be applied to a string....
> Your patch works.
> But there are some other problems that hopefully/presumably are not
> related to the proc in question.
> I've just found out that when the GUI is heavily stimulated, I mean whe
> I try to load different histograms consecutively then it dies with
> core-dump.

> You're perfectly right at stating that the whole GUI should be
> rewritten from scratch rather than patched up. But the plan is to make
> the current Mars users happy with the current GUI and then move on and
> implement a 3-D GUI that allows for volume rendering of the collider
> zones and 3-D rotations and cutting the volume with an arbitrary plain,
> etc ...
> I do not think Tcl/Tk is the proper tool to do that but I might be very
> mistaken as I'm new to it.

When you do get to the 3D GUI, you might want to take a look
a VTK, http://www.vtk.org .

From the site : "The Visualization ToolKit (VTK) is an open source,
freely available software system for 3D computer graphics, image
processing, and visualization used by thousands of researchers
and developers around the world.  VTK consists of a C++ class library,
and several interpreted interface layers including Tcl/Tk, Java and Python."

--Mark



Sat, 18 Oct 2008 07:14:02 GMT  
 changes fixed the Histogram display but spoilt the Geometry display

Quote:

>Thank you very much.
>It makes sense that a math function cannot be applied to a string....
>Your patch works.
>But there are some other problems that hopefully/presumably are not
>related to the proc in question.
>I've just found out that when the GUI is heavily stimulated, I mean whe
>I try to load different histograms consecutively then it dies with
>core-dump.

>You're perfectly right at stating that the whole GUI should be
>rewritten from scratch rather than patched up. But the plan is to make
>the current Mars users happy with the current GUI and then move on and
>implement a 3-D GUI that allows for volume rendering of the collider
>zones and 3-D rotations and cutting the volume with an arbitrary plain,
>etc ...
>I do not think Tcl/Tk is the proper tool to do that but I might be very
>mistaken as I'm new to it.

>Unluckily i still have a couple more gui-related problems to patch up.

                        .
                        .
                        .
It's VERY unusual for pure Tk code to dump core.  We'd definitely
like details on that one.

3-D displays are a big subject.  Before saying more on that, please
detail more of the requirements:  on what platforms will the GUI
need to run?  What licenses are feasible?  Do you have quantitive
performance requirements?



Sat, 18 Oct 2008 09:07:57 GMT  
 changes fixed the Histogram display but spoilt the Geometry display

Quote:

> In the following I'm copying the last version of the incriminated proc

Your pasting of the proc got all messed up.

I don't think you should have gone patching the number with decimal
points; you should have just rearranged the tests (as I suggested)
to wit:

proc format_vis1_fix { num ticksfmt } {

    set intfmt   "%8.1f"
    set floatfmt "%8.4f"
    set scienfmt "%8.2e"

    set res ""

    if { $num != "" } {

        set res 0.0

        if { $num != 0.0 } {

            if { $ticksfmt != "" } {
                if { [string first "f" $ticksfmt] > 0 } {
                    if { [string first "12" $ticksfmt] > 0 } {
                        set res [format $ticksfmt $num]
                    } else {
                        if { [string first "20" $ticksfmt] > 0 } {
                            set res [format $ticksfmt $num]
                        }
                    }
                }
            }

            if { $res == 0.0 } {

                if { abs($num) > 9999.9999 } {
                    set res [format $scienfmt $num]
                } elseif { abs($num) < 0.0001 } {
                    set res [format $scienfmt $num]
                } elseif { abs($num-int($num)) < 0.00001 } {
                    set res [format $intfmt $num]
                } else {
                    set res [format $floatfmt $num]
                }

            }
        }
    }
    return $res

Quote:
}

--



Sat, 18 Oct 2008 11:09:58 GMT  
 changes fixed the Histogram display but spoilt the Geometry display


Quote:

>> In the following I'm copying the last version of the incriminated proc

>Your pasting of the proc got all messed up.

>I don't think you should have gone patching the number with decimal
>points; you should have just rearranged the tests (as I suggested)
>to wit:

>proc format_vis1_fix { num ticksfmt } {

                        .
                        .
                        .
Quote:
>            if { $res == 0.0 } {

>                if { abs($num) > 9999.9999 } {
>                    set res [format $scienfmt $num]
>                } elseif { abs($num) < 0.0001 } {
>                    set res [format $scienfmt $num]
>                } elseif { abs($num-int($num)) < 0.00001 } {
>                    set res [format $intfmt $num]
>                } else {
>                    set res [format $floatfmt $num]
>                }

>            }
>        }
>    }
>    return $res
>}

                        .
                        .
                        .
Donald, for extreme $num, the predicates complain
  argument to math function didn't have numeric value


Sat, 18 Oct 2008 13:07:52 GMT  
 changes fixed the Histogram display but spoilt the Geometry display

Quote:

> Donald, for extreme $num, the predicates complain
>   argument to math function didn't have numeric value

If $num may have huge integer values, then I'd insert

        set num [scan $num %f]

right after

    if { $num != "" } {

but that doesn't throw errors on bad non-numerics.

If an error should be generated, then use

    if { $num != "" } {
      if { [scan $num "%f %c" num c] != 1 } {
         return -code error "Non numeric value in format_vis"
      }

If the bad non-numerics should be ignored silently, then I'd
put the scan before the test for nullity

    scan $num %f num
    if { $num != "" } {

--



Sat, 18 Oct 2008 22:04:58 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. How to display a bin count histogram

2. Q: Problem with displaying geometry in PROTOS

3. icons displayed in browses not displaying

4. Display.TransferBlock not supported by display

5. Display RGB pixel data in a display window

6. DISPLAY statement and screen displays

7. no display name and no $DISPLAY environment variable

8. can't read env(DISPLAY) from regexp with $env(DISPLAY)

9. no display name and no $DISPLAY environment variable -- ????

10. browse display 'flickers' - FIX

11. I want the wavegraph display 10 grids on x,y axis,how to make it fixed

12. Deuce display problem and possible fix

 

 
Powered by phpBB® Forum Software