1# Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2# Copyright (C) 2004 - INRIA - Fabrice Leray 3# Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy 4# 5# Copyright (C) 2012 - 2016 - Scilab Enterprises 6# 7# This file is hereby licensed under the terms of the GNU GPL v2.0, 8# pursuant to article 5.3.4 of the CeCILL v.2.1. 9# This file was originally licensed under the terms of the CeCILL v2.1, 10# and continues to be available under such terms. 11# For more information, see the COPYING file which you should have received 12# along with this program. 13 14set pwd [pwd] 15cd [file dirname [info script]] 16variable DEMODIR [pwd] 17cd $pwd 18 19global MySciPath 20set MySciPath [file join "$env(SCIPATH)"] 21 22 23variable DEMODIR 24 25lappend ::auto_path [file dirname "$env(SCIPATH)/modules/tclsci/tcl/BWidget"] 26namespace inscope :: package require BWidget 27package require BWidget 28 29global sourcedir 30set sourcedir [file join "$env(SCIPATH)" "modules" "tclsci" "tcl" "utils"] 31set sourcedir2 [file join "$env(SCIPATH)" "modules" "graphics" "tcl" "ged"] 32 33source [file join $sourcedir Notebook.tcl] 34source [file join $sourcedir Combobox.tcl] 35source [file join $sourcedir Balloon.tcl] 36source [file join $sourcedir2 ObjectsBrowser.tcl] 37 38package require combobox 2.3 39catch {namespace import combobox::*} 40 41#package require lemonTree 42catch {namespace import LemonTree::*} 43 44global envSCIHOME MAIN_WINDOW_POSITION TICK_WINDOW_POSITION msdos 45set ged_listofpref "MAIN_WINDOW_POSITION TICK_WINDOW_POSITION" 46set MAIN_WINDOW_POSITION "+0+0" 47set TICK_WINDOW_POSITION "+0+0" 48 49set envSCIHOME $SCIHOME 50set preffilename $envSCIHOME/.GedPreferences.tcl 51catch {source $preffilename} 52 53 54global SELOBJECT 55global ged_handle_list_size 56global lalist 57global curgedindex 58global curgedobject 59global RED GREEN BLUE 60 61global curvis 62global curcolormode curthick colorflagToggle curforeground curhiddencolor 63global curmarkmode curlinemode curmarksize curmarksizeunit curmarkforeground curmarkbackground 64#global nbrowX nbrowY plot3dXVAL plot3dYVAL plot3dZVAL plot3dCOLORVAL 65#global nbrowZ nbcolZ nbrowCOLOR nbcolCOLOR 66global ncolors flagCOLOR 67 68global scicomint_dataX scicomint_dataY scicomint_dataZ scicomint_dataCOLOR 69global curdata_x curdata_y curdata_z curdata_color 70 71#To update foreground color grey ("off"), black ("on") for checkbutton boxes 72proc OnOffForeground { frame flag } { 73 74 if { $flag == "on" } { 75 $frame configure -foreground black 76 } else { 77 $frame configure -foreground grey 78 } 79} 80 81set NBheight 450 82set NBwidth 300 83 84set Wheight [expr $NBheight + 110] 85set Wwidth [expr $NBwidth + 270] 86 87set smallPad 4 88set mediumPad 8 89 90#create the font we will use 91set gedFont {Arial -12} 92 93set ww .axes 94catch {destroy $ww} 95 96toplevel $ww 97wm title $ww "Plot3d Object" 98wm iconname $ww "PE" 99wm geometry $ww [expr $Wwidth]x[expr $Wheight]$MAIN_WINDOW_POSITION 100wm maxsize $ww $Wwidth $Wheight 101wm protocol $ww WM_DELETE_WINDOW "DestroyGlobals; destroy $ww " 102 103set topf [frame $ww.topf] 104set titf1 [TitleFrame $topf.titf1 -text "Graphic Editor" -font $gedFont] 105 106set parent [$titf1 getframe] 107set pw1 [PanedWindow $parent.pw -side top] 108set pane3 $pw1 109 110 111 112# Make a frame scrollable 113 114set sw [ScrolledWindow $pane3.sw -relief sunken -borderwidth 2] 115# pack $sw -in .sw -fill both -expand true 116set sf [ScrollableFrame $sw.f] 117$sw setwidget $sf 118set uf [$sf getframe] 119 120 121 122set w $uf 123set fra [frame $w.frame -borderwidth 0] 124pack $fra -anchor w -fill both 125 126#------------------------------------------------ 127 128set theframe $fra 129 130#adding 15.06.2005 131set topflabel [frame $theframe.topflabel] 132set titf1label [TitleFrame $topflabel.titflabel1 -text "Objects Browser" -font $gedFont] 133set titf1axes [TitleFrame $topflabel.titfaxes1 -text "Object Properties" -font $gedFont] 134 135set w [$titf1label getframe] 136 137pack $titf1label -padx 4 -side left -fill both -expand yes 138pack $topflabel -fill x -pady 0 139pack $titf1axes -pady 0 -padx 4 -fill both -expand yes 140 141frame $w.frame -borderwidth 0 142pack $w.frame -anchor w -fill both 143#end adding 144 145 146set wfortree $w 147 148for {set i 1} {$i<=$ged_handle_list_size} {incr i} { 149 set OBJECTSARRAY($i) $SELOBJECT($i) 150} 151 152set curgedobject $SELOBJECT($curgedindex) 153 154set tree [Tree $wfortree.tree \ 155 -yscrollcommand {$wfortree.y set} -xscrollcommand {$wfortree.x set} \ 156 -width 20 -height 26 \ 157 -background white -opencmd {LemonTree::open $wfortree.tree} \ 158 -selectbackground blue -selectforeground white ] 159 160pack [scrollbar $wfortree.x -orient horiz -command {$wfortree.tree xview}] -side bottom -fill x 161pack [scrollbar $wfortree.y -command {$wfortree.tree yview}] -side right -fill y 162pack $tree -fill both -expand 1 -side left 163 164$tree bindText <1> {LemonTree::Info $tree} 165$tree bindImage <1> {LemonTree::Info $tree} 166 167LemonTree::add $tree root FIGURE currentfigure "Figure(1)" 168 169# I open the tree to browse all the nodes (to know what nodes I have and what their names are) 170$tree opentree n1 171 172set allnodes [$tree selection get] 173 174#I close quickly the tree because openreeatnode expanded the tree... 175$tree closetree n1 176 177 178# I directly point onto the current curgedobject (current Axes or Figure or picked entity) 179LemonTree::finddata $tree $allnodes $curgedobject 180 181 182#adding 15.06.2005 183set w [$titf1axes getframe] 184 185set uf $w 186#------------------------------------------------ 187 188set largeur 14 189 190Notebook:create $uf.n -pages {"Style" "Data"} -pad 0 -height $NBheight -width $NBwidth 191 192pack $uf.n -in $uf -fill both -expand yes 193 194########### Style onglet ########################################## 195################################################################### 196set w [Notebook:frame $uf.n "Style"] 197 198frame $w.frame -borderwidth 0 199pack $w.frame -anchor w -fill both 200 201#visibility 202frame $w.frame.vis -borderwidth 0 203pack $w.frame.vis -in $w.frame -side top -fill x 204label $w.frame.vislabel -text "Visibility:" -font $gedFont -anchor e -width $largeur 205checkbutton $w.frame.visib -text "on"\ 206 -variable curvis -onvalue "on" -offvalue "off" \ 207 -command "toggleVis $w.frame.visib" -font $gedFont 208OnOffForeground $w.frame.visib $curvis 209 210pack $w.frame.vislabel -in $w.frame.vis -side left 211pack $w.frame.visib -in $w.frame.vis -side left -padx $smallPad 212 213#Surface mode 214frame $w.frame.linelinemode -borderwidth 0 215pack $w.frame.linelinemode -in $w.frame -side top -fill x 216 217label $w.frame.linemodelabel -height 0 -text "Surface mode:" -width 0 -font $gedFont -anchor e -width $largeur 218checkbutton $w.frame.linemode -text "on" -indicatoron 1 \ 219 -variable curlinemode -onvalue "on" -offvalue "off" \ 220 -command "toggleLinemode $w.frame.linemode" -font $gedFont 221OnOffForeground $w.frame.linemode $curlinemode 222 223pack $w.frame.linemodelabel -in $w.frame.linelinemode -side left 224pack $w.frame.linemode -in $w.frame.linelinemode -side left -fill x -pady 0 -padx $smallPad 225 226#Color Mode 227frame $w.frame.clrm -borderwidth 0 228pack $w.frame.clrm -in $w.frame -side top -fill x 229 230label $w.frame.colorlabelm -height 0 -text "Color mode:" -width 0 -font $gedFont -anchor e -width $largeur 231scale $w.frame.colorm -orient horizontal -from -$ncolors -to $ncolors \ 232 -resolution 1.0 -command "setColorMode $w.frame.colorm" -tickinterval 0 -font $gedFont 233 234pack $w.frame.colorlabelm -in $w.frame.clrm -side left 235pack $w.frame.colorm -in $w.frame.clrm -side left -expand 1 -fill x -pady 0 -padx $smallPad 236$w.frame.colorm set $curcolormode 237 238#Foreground 239frame $w.frame.clrf -borderwidth 0 240pack $w.frame.clrf -in $w.frame -side top -fill x 241 242label $w.frame.colorlabel -height 0 -text "Foreground:" -width 0 -font $gedFont -anchor e -width $largeur 243scale $w.frame.color -orient horizontal -from -2 -to $ncolors \ 244 -resolution 1.0 -command "setForeground $w.frame.color" -tickinterval 0 -font $gedFont 245 246pack $w.frame.colorlabel -in $w.frame.clrf -side left 247pack $w.frame.color -in $w.frame.clrf -side left -expand 1 -fill x -pady 0 -padx $smallPad 248$w.frame.color set $curforeground 249 250#Hidden Color 251frame $w.frame.clrh -borderwidth 0 252pack $w.frame.clrh -in $w.frame -side top -fill x 253 254label $w.frame.colorlabelh -height 0 -text "Hidden color:" -width 0 -font $gedFont -anchor e -width $largeur 255scale $w.frame.colorh -orient horizontal -from -1 -to $ncolors \ 256 -resolution 1.0 -command "setHiddenColor $w.frame.colorh" -tickinterval 0 -font $gedFont 257 258pack $w.frame.colorlabelh -in $w.frame.clrh -side left 259pack $w.frame.colorh -in $w.frame.clrh -side left -expand 1 -fill x -pady 0 -padx $smallPad 260$w.frame.colorh set $curhiddencolor 261 262 263#Thickness 264frame $w.frame.thk -borderwidth 0 265pack $w.frame.thk -side top -fill x 266 267label $w.frame.thicklabel -height 0 -text "Thickness:" -width 0 -font $gedFont -anchor e -width $largeur 268combobox $w.frame.thickness \ 269 -borderwidth 1 \ 270 -highlightthickness 1 \ 271 -maxheight 0 \ 272 -width 3 \ 273 -textvariable curthick \ 274 -editable true \ 275 -command [list SelectThickness ] -font $gedFont 276eval $w.frame.thickness list insert end [list "0.0" "1.0" "2.0" "3.0" "4.0" "5.0" "6.0" "8.0" "10.0"] 277 278pack $w.frame.thicklabel -in $w.frame.thk -side left 279pack $w.frame.thickness -in $w.frame.thk -expand 1 -fill x -pady 0 -padx $mediumPad 280 281 282#Color Flag 283frame $w.frame.scalesw -borderwidth 0 284pack $w.frame.scalesw -in $w.frame -side top -fill x -pady 0 285 286label $w.frame.scalesw.label -height 0 -text "Color flag:" -width 0 -font $gedFont -anchor e -width $largeur 287radiobutton $w.frame.scalesw.radio0 -text "0" -variable colorflagToggle -value 0 -command "toggleColorFlag" -font $gedFont 288radiobutton $w.frame.scalesw.radio1 -text "1" -variable colorflagToggle -value 1 -command "toggleColorFlag" -font $gedFont 289 290pack $w.frame.scalesw.label -in $w.frame.scalesw -side left 291pack $w.frame.scalesw.radio0 -in $w.frame.scalesw -side left -padx $smallPad 292pack $w.frame.scalesw.radio1 -in $w.frame.scalesw -side left -padx $smallPad 293 294 295 296#Mark mode 297frame $w.frame.linemarkmode -borderwidth 0 298pack $w.frame.linemarkmode -in $w.frame -side top -fill x 299 300label $w.frame.markmodelabel -height 0 -text "Mark mode:" -width 0 -font $gedFont -anchor e -width $largeur 301checkbutton $w.frame.markmode -text "on" -indicatoron 1 \ 302 -variable curmarkmode -onvalue "on" -offvalue "off" \ 303 -command "toggleMarkmode $w.frame.markmode" -font $gedFont 304OnOffForeground $w.frame.markmode $curmarkmode 305 306pack $w.frame.markmodelabel -in $w.frame.linemarkmode -side left 307pack $w.frame.markmode -in $w.frame.linemarkmode -side left -fill x -pady 0 -padx $smallPad 308 309 310#Mark style 311frame $w.frame.linemarkst -borderwidth 0 312pack $w.frame.linemarkst -in $w.frame -side top -fill x 313 314label $w.frame.markstylelabel -height 0 -text "Mark style:" -width 0 -font $gedFont -anchor e -width $largeur 315combobox $w.frame.markstyle \ 316 -borderwidth 1 \ 317 -highlightthickness 1 \ 318 -maxheight 0 \ 319 -width 3 \ 320 -textvariable curmarkstyle \ 321 -editable false \ 322 -command [list SelectMarkStyle ] -font $gedFont 323eval $w.frame.markstyle list insert end [list "dot" "plus" "cross" "star" "filled diamond" "diamond" "triangle up" "triangle down" "diamond plus" "circle" "asterisk" "square" "triangle right" "triangle left" "pentagram"] 324 325 326pack $w.frame.markstylelabel -in $w.frame.linemarkst -side left 327pack $w.frame.markstyle -in $w.frame.linemarkst -expand 1 -fill x -pady 0 -padx $mediumPad 328 329 330#Mark size 331frame $w.frame.mksize -borderwidth 0 332pack $w.frame.mksize -side top -fill x 333 334label $w.frame.marksizelabel -height 0 -text "Mark size:" -width 0 -font $gedFont -anchor e -width $largeur 335combobox $w.frame.marksize \ 336 -borderwidth 1 \ 337 -highlightthickness 1 \ 338 -maxheight 0 \ 339 -width 3 \ 340 -textvariable curmarksize \ 341 -editable true \ 342 -command [list SelectMarkSize ] -font $gedFont 343eval $w.frame.marksize list insert end [list "0.5" "1.0" "2.0" "3.0" "4.0" "6.0" "8.0" "10.0" "15.0" "20.0" "25.0" "30.0"] 344 345 346#Add Mark size unit 347label $w.frame.marksizeunitlabel -height 0 -text "Mark size:" -width 0 -font $gedFont -anchor e -width $largeur 348combobox $w.frame.marksizeunit \ 349 -borderwidth 1 \ 350 -highlightthickness 1 \ 351 -maxheight 0 \ 352 -width 13 \ 353 -textvariable curmarksizeunit \ 354 -editable false \ 355 -command [list SelectMarkSizeUnit ] -font $gedFont 356eval $w.frame.marksizeunit list insert end [list "point" "tabulated"] 357 358pack $w.frame.marksizeunitlabel -in $w.frame.mksize -side left 359pack $w.frame.marksizeunit -in $w.frame.mksize -side left -padx $mediumPad 360pack $w.frame.marksize -in $w.frame.mksize -side left -fill x -expand 1 -pady 0 -padx $mediumPad 361 362 363#Mark foreground 364frame $w.frame.markf -borderwidth 0 365pack $w.frame.markf -in $w.frame -side top -fill x 366 367label $w.frame.markflabel -height 0 -text "Mark foreground:" -width 0 -font $gedFont -anchor e -width $largeur 368scale $w.frame.markforeground -orient horizontal -from -2 -to $ncolors \ 369 -resolution 1.0 -command "setMarkForeground $w.frame.markforeground" -tickinterval 0 -font $gedFont 370 371pack $w.frame.markflabel -in $w.frame.markf -side left 372pack $w.frame.markforeground -in $w.frame.markf -side left -expand 1 -fill x -pady 0 -padx $smallPad 373$w.frame.markforeground set $curmarkforeground 374 375 376#Mark background 377frame $w.frame.markb -borderwidth 0 378pack $w.frame.markb -in $w.frame -side top -fill x 379 380label $w.frame.markblabel -height 0 -text "Mark background:" -width 0 -font $gedFont -anchor e -width $largeur 381scale $w.frame.markbackground -orient horizontal -from -2 -to $ncolors \ 382 -resolution 1.0 -command "setMarkBackground $w.frame.markbackground" -tickinterval 0 -font $gedFont 383 384pack $w.frame.markblabel -in $w.frame.markb -side left 385pack $w.frame.markbackground -in $w.frame.markb -side left -expand 1 -fill x -pady 0 -padx $smallPad 386$w.frame.markbackground set $curmarkbackground 387 388 389#sep bar 390frame $w.sep -height 2 -borderwidth 1 -relief sunken 391pack $w.sep -fill both 392 393#exit button 394button $w.buttons -text Quit -command "DestroyGlobals; destroy $ww" -font $gedFont 395pack $w.buttons -side bottom 396 397 398 399 400########### Data onglet ########################################### 401################################################################### 402set w [Notebook:frame $uf.n "Data"] 403 404frame $w.frame -borderwidth 0 405pack $w.frame -anchor w -fill both 406 407############################## 408## DATA edit via sciGUI ###### 409############################## 410 411frame $w.frame.curdataframeX -borderwidth 0 412pack $w.frame.curdataframeX -in $w.frame -side top -fill x 413 414label $w.frame.polydatalabelX -height 0 -text "X Data:" -width 0 -font $gedFont -anchor e -width $largeur 415combobox $w.frame.polydataX \ 416 -borderwidth 1 \ 417 -highlightthickness 1 \ 418 -maxheight 0 \ 419 -width 3 \ 420 -textvariable curdata_x \ 421 -editable false \ 422 -command [list SelectDataX ] -font $gedFont 423eval $w.frame.polydataX list insert end [list $curdata_x "----" "Edit data..."] 424pack $w.frame.polydatalabelX -in $w.frame.curdataframeX -side left 425pack $w.frame.polydataX -in $w.frame.curdataframeX -expand 1 -fill x -pady 0 -padx $mediumPad 426 427 428frame $w.frame.curdataframeY -borderwidth 0 429pack $w.frame.curdataframeY -in $w.frame -side top -fill x 430 431label $w.frame.polydatalabelY -height 0 -text "Y Data:" -width 0 -font $gedFont -anchor e -width $largeur 432combobox $w.frame.polydataY \ 433 -borderwidth 1 \ 434 -highlightthickness 1 \ 435 -maxheight 0 \ 436 -width 3 \ 437 -textvariable curdata_y \ 438 -editable false \ 439 -command [list SelectDataY ] -font $gedFont 440eval $w.frame.polydataY list insert end [list $curdata_y "----" "Edit data..."] 441pack $w.frame.polydatalabelY -in $w.frame.curdataframeY -side left 442pack $w.frame.polydataY -in $w.frame.curdataframeY -expand 1 -fill x -pady 0 -padx $mediumPad 443 444frame $w.frame.curdataframeZ -borderwidth 0 445pack $w.frame.curdataframeZ -in $w.frame -side top -fill x 446 447label $w.frame.polydatalabelZ -height 0 -text "Z Data:" -width 0 -font $gedFont -anchor e -width $largeur 448combobox $w.frame.polydataZ \ 449 -borderwidth 1 \ 450 -highlightthickness 1 \ 451 -maxheight 0 \ 452 -width 3 \ 453 -textvariable curdata_z \ 454 -editable false \ 455 -command [list SelectDataZ ] -font $gedFont 456eval $w.frame.polydataZ list insert end [list $curdata_z "----" "Edit data..."] 457pack $w.frame.polydatalabelZ -in $w.frame.curdataframeZ -side left 458pack $w.frame.polydataZ -in $w.frame.curdataframeZ -expand 1 -fill x -pady 0 -padx $mediumPad 459 460if {$flagCOLOR == 1} { 461 frame $w.frame.curdataframeColor -borderwidth 0 462 pack $w.frame.curdataframeColor -in $w.frame -side top -fill x 463 464 label $w.frame.polydatalabelColor -height 0 -text "Color Data:" -width 0 -font $gedFont -anchor e -width $largeur 465 combobox $w.frame.polydataColor \ 466 -borderwidth 1 \ 467 -highlightthickness 1 \ 468 -maxheight 0 \ 469 -width 3 \ 470 -textvariable curdata_color \ 471 -editable false \ 472 -command [list SelectDataColor ] -font $gedFont 473 eval $w.frame.polydataColor list insert end [list $curdata_color "----" "Edit data..."] 474 pack $w.frame.polydatalabelColor -in $w.frame.curdataframeColor -side left 475 pack $w.frame.polydataColor -in $w.frame.curdataframeColor -expand 1 -fill x -pady 0 -padx $mediumPad 476 477 478 label $w.frame.warning -text "Color field is not yet taken into account with Plot3d entity. \nCreate a Fac3d entity to use color data." -font $gedFont 479 $w.frame.warning config -foreground red 480 pack $w.frame.warning -in $w.frame -side top -fill x 481} 482 483 484 485####################################################### 486## DATA edit via Scilab Command Interface sciGUI ###### 487####################################################### 488 489frame $w.scicom1 490pack $w.scicom1 -side top -fill x -pady 0 491 492label $w.scicom1.label1 -text "Scilab Command Interface for data:" -font $gedFont 493pack $w.scicom1.label1 -in $w.scicom1 -side left 494 495frame $w.scicomX 496pack $w.scicomX -side top -fill x -pady 0 497 498label $w.scicomX.label1 -text "X Data:" -font $gedFont -anchor e -width $largeur 499pack $w.scicomX.label1 -in $w.scicomX -side left 500 501entry $w.scicomX.text1 -relief sunken -textvariable scicomint_dataX -width 10 -font $gedFont 502set_balloon $w.scicomX.text1 "Enter a variable defined in Scilab Console representing\n a real vector or matrix or use a macro call (defining a vector or matrix)\n to initialize the \"X data\" field." 503bind $w.scicomX.text1 <Return> "sciCommandData" 504bind $w.scicomX.text1 <KP_Enter> "sciCommandData" 505 506pack $w.scicomX.text1 -side left -fill both -padx $mediumPad 507 508 509frame $w.scicomY 510pack $w.scicomY -side top -fill x -pady 0 511 512label $w.scicomY.label1 -text "Y Data:" -font $gedFont -anchor e -width $largeur 513pack $w.scicomY.label1 -in $w.scicomY -side left 514 515entry $w.scicomY.text1 -relief sunken -textvariable scicomint_dataY -width 10 -font $gedFont 516set_balloon $w.scicomY.text1 "Enter a variable defined in Scilab Console representing\n a real vector or matrix or use a macro call (defining a vector or matrix)\n to initialize the \"Y data\" field." 517bind $w.scicomY.text1 <Return> "sciCommandData" 518bind $w.scicomY.text1 <KP_Enter> "sciCommandData" 519 520pack $w.scicomY.text1 -side left -fill both -padx $mediumPad 521 522 523frame $w.scicomZ 524pack $w.scicomZ -side top -fill x -pady 0 525 526label $w.scicomZ.label1 -text "Z Data:" -font $gedFont -anchor e -width $largeur 527pack $w.scicomZ.label1 -in $w.scicomZ -side left 528 529entry $w.scicomZ.text1 -relief sunken -textvariable scicomint_dataZ -width 10 -font $gedFont 530set_balloon $w.scicomZ.text1 "Enter a variable defined in Scilab Console representing\n a real matrix or use a macro call (defining a matrix)\n to initialize the \"Z data\" field." 531bind $w.scicomZ.text1 <Return> "sciCommandData" 532bind $w.scicomZ.text1 <KP_Enter> "sciCommandData" 533 534pack $w.scicomZ.text1 -side left -fill both -padx $mediumPad 535 536 537frame $w.scicomCOLOR 538pack $w.scicomCOLOR -side top -fill x -pady 0 539 540label $w.scicomCOLOR.label1 -text "Color Data:" -font $gedFont -anchor e -width $largeur 541pack $w.scicomCOLOR.label1 -in $w.scicomCOLOR -side left 542 543entry $w.scicomCOLOR.text1 -relief sunken -textvariable scicomint_dataCOLOR -width 10 -font $gedFont 544set_balloon $w.scicomCOLOR.text1 "Enter a variable defined in Scilab Console representing\n an integer matrix or use a macro call (defining a matrix)\n to initialize the \"Color data\" field." 545bind $w.scicomCOLOR.text1 <Return> "sciCommandData" 546bind $w.scicomCOLOR.text1 <KP_Enter> "sciCommandData" 547 548pack $w.scicomCOLOR.text1 -side left -fill both -padx $mediumPad 549 550 551#sep bar 552frame $w.sep -height 2 -borderwidth 1 -relief sunken 553pack $w.sep -fill both 554 555 556#exit button 557frame $w.buttons 558button $w.b -text Quit -command "DestroyGlobals; destroy $ww" -font $gedFont 559pack $w.b -side bottom 560 561 562pack $sw $pw1 -fill both -expand yes 563pack $titf1 -padx 4 -side left -fill both -expand yes 564pack $topf -fill both -pady 2 -expand yes 565 566 567#proc associes 568proc toggleVis { frame } { 569 global curvis 570 ScilabEval "global ged_handle;ged_handle.visible='$curvis'" 571 572 OnOffForeground $frame $curvis 573} 574 575 576proc setColorMode {w index} { 577 global RED BLUE GREEN 578 variable REDCOL 579 variable GRECOL 580 variable BLUCOL 581 582 #ScilabEval "global ged_handle;" 583# if { $index == -2 } { 584# ScilabEval "global ged_handle; ged_handle.color_mode=$index;" 585# #like $index==-2: display white color 586# set color [format \#%02x%02x%02x 255 255 255] 587# $w config -activebackground $color -troughcolor $color 588# } else 589 if { $index == -1 } { 590 ScilabEval "global ged_handle; if ged_handle.color_mode <> $index then ged_handle.color_mode=$index; end;" 591 #like $index==-1: display black color 592 set color [format \#%02x%02x%02x 0 0 0] 593 $w config -activebackground $color -troughcolor $color 594 } elseif { $index == 0 } { 595 ScilabEval "global ged_handle; if ged_handle.color_mode <> $index then ged_handle.color_mode=$index; end;" 596 #like $index==-2: display white color 597 set color [format \#%02x%02x%02x 255 255 255] 598 $w config -activebackground $color -troughcolor $color 599 } else { 600 ScilabEval "global ged_handle; if ged_handle.color_mode <> $index then ged_handle.color_mode=$index; end;" 601 if { $index < 0} { 602 set index [expr -$index] 603 } 604 set REDCOL $RED($index) 605 set GRECOL $GREEN($index) 606 set BLUCOL $BLUE($index) 607 608 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 609 610 $w config -activebackground $color -troughcolor $color 611 612 } 613} 614 615 616 617proc setForeground {w index} { 618 global RED BLUE GREEN 619 variable REDCOL 620 variable GRECOL 621 variable BLUCOL 622 623 #ScilabEval "global ged_handle;" 624 if { $index == -2 } { 625 ScilabEval "global ged_handle; if ged_handle.foreground <> $index then ged_handle.foreground=$index; end;" 626 #like $index==-2: display white color 627 set color [format \#%02x%02x%02x 255 255 255] 628 $w config -activebackground $color -troughcolor $color 629 } elseif { $index == -1 } { 630 ScilabEval "global ged_handle; if ged_handle.foreground <> $index then ged_handle.foreground=$index; end;" 631 #like $index==-1: display black color 632 set color [format \#%02x%02x%02x 0 0 0] 633 $w config -activebackground $color -troughcolor $color 634 } elseif { $index == 0 } { 635 ScilabEval "global ged_handle; if ged_handle.foreground <> $index then ged_handle.foreground=$index; end;" 636 #like $index==1: display first color 637 set REDCOL $RED(1) 638 set GRECOL $GREEN(1) 639 set BLUCOL $BLUE(1) 640 641 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 642 643 $w config -activebackground $color -troughcolor $color 644 } else { 645 ScilabEval "global ged_handle; if ged_handle.foreground <> $index then ged_handle.foreground=$index; end;" 646 647 set REDCOL $RED($index) 648 set GRECOL $GREEN($index) 649 set BLUCOL $BLUE($index) 650 651 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 652 653 $w config -activebackground $color -troughcolor $color 654 655 } 656} 657 658 659 660proc setHiddenColor {w index} { 661 global RED BLUE GREEN 662 variable REDCOL 663 variable GRECOL 664 variable BLUCOL 665 666 #ScilabEval "global ged_handle;" 667 if { $index < 0 } { 668 ScilabEval "global ged_handle; if ged_handle.hiddencolor <> $index then ged_handle.hiddencolor=$index; end;" 669 670 set index [expr -$index] 671 672 set REDCOL $RED($index) 673 set GRECOL $GREEN($index) 674 set BLUCOL $BLUE($index) 675 676 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 677 678 $w config -activebackground $color -troughcolor $color 679 680 } elseif { $index == 0 } { 681 ScilabEval "global ged_handle; if ged_handle.hiddencolor <> $index then ged_handle.hiddencolor=$index; end;" 682 #like $index==1: display first color 683 set color [format \#%02x%02x%02x 255 255 255] 684 $w config -activebackground $color -troughcolor $color 685 } else { 686 ScilabEval "global ged_handle; if ged_handle.hiddencolor <> $index then ged_handle.hiddencolor=$index; end;" 687 688 set REDCOL $RED($index) 689 set GRECOL $GREEN($index) 690 set BLUCOL $BLUE($index) 691 692 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 693 694 $w config -activebackground $color -troughcolor $color 695 696 } 697} 698 699proc toggleColorFlag {} { 700 global colorflagToggle 701 global ged_handle 702 ScilabEval "global ged_handle;ged_handle.color_flag=$colorflagToggle" 703} 704 705 706proc setThickness {w thick} { 707 ScilabEval "global ged_handle;ged_handle.thickness=$thick;" 708} 709 710 711 712proc setXData { i } { 713global plot3dXVAL 714ScilabEval "execstr(\"global ged_handle; ged_handle.data.x($i)=$plot3dXVAL($i);\",\'errcatch\',\'n\');" 715} 716 717 718proc setYData { i } { 719global plot3dYVAL 720ScilabEval "execstr(\"global ged_handle; ged_handle.data.y($i)=$plot3dYVAL($i);\",\'errcatch\',\'n\');" 721} 722 723proc setZData { i j } { 724global plot3dZVAL 725ScilabEval "execstr(\"global ged_handle; ged_handle.data.z($i,$j)=$plot3dZVAL($i,$j);\",\'errcatch\',\'n\');" 726} 727 728 729proc setColorData { i j } { 730global plot3dCOLORVAL 731ScilabEval "execstr(\"global ged_handle; ged_handle.data.color($i,$j)=$plot3dCOLORVAL($i,$j);\",\'errcatch\',\'n\');" 732} 733 734proc sciCommandData {} { 735 global scicomint_dataX scicomint_dataY scicomint_dataZ scicomint_dataCOLOR 736 737 if { ($scicomint_dataX == "") || ($scicomint_dataY == "") || 738 ($scicomint_dataZ == "") } { 739 tk_messageBox -icon error -type ok -title "Incorrect input" -message "You must fill in all the fields (only color field is optional) using variables defined in Scilab Console\n to initialize the \"data\" field." 740 } else { 741 if { $scicomint_dataCOLOR == ""} { 742 ScilabEval "set3dtlistXYZ($scicomint_dataX,$scicomint_dataY,$scicomint_dataZ)" "seq" 743 #Refresh now ! 744 ScilabEval "tkged();" "seq" 745 } else { 746 ScilabEval "set3dtlistXYZC($scicomint_dataX,$scicomint_dataY,$scicomint_dataZ,$scicomint_dataCOLOR)" "seq" 747 #Refresh now ! 748 ScilabEval "tkged();" "seq" 749 } 750 } 751} 752 753proc SelectDataX {w args} { 754 global curdata_x 755 variable mycurdata 756 set mycurdata $curdata_x 757 set finddbarray -1 758 set dbarray "double array" 759 set finddbarray [expr [string first $dbarray $mycurdata]] 760# puts "finddbarray = $finddbarray" 761 762 if { ($mycurdata == "----") || ($finddbarray != -1) } { 763 # puts "nothing to do" 764 } else { 765 if { $mycurdata == "Edit data..." } { 766 ScilabEval "global ged_handle;EditData(ged_handle.data.x,\"ged_handle.data.x\")" "seq" 767 } 768 } 769} 770 771 772proc SelectDataY {w args} { 773 global curdata_y 774 variable mycurdata 775 set mycurdata $curdata_y 776 set finddbarray -1 777 set dbarray "double array" 778 set finddbarray [expr [string first $dbarray $mycurdata]] 779# puts "finddbarray = $finddbarray" 780 781 if { ($mycurdata == "----") || ($finddbarray != -1) } { 782 # puts "nothing to do" 783 } else { 784 if { $mycurdata == "Edit data..." } { 785 ScilabEval "global ged_handle;EditData(ged_handle.data.y,\"ged_handle.data.y\")" "seq" 786 } 787 } 788} 789 790proc SelectDataZ {w args} { 791 global curdata_z 792 variable mycurdata 793 set mycurdata $curdata_z 794 set finddbarray -1 795 set dbarray "double array" 796 set finddbarray [expr [string first $dbarray $mycurdata]] 797# puts "finddbarray = $finddbarray" 798 799 if { ($mycurdata == "----") || ($finddbarray != -1) } { 800 # puts "nothing to do" 801 } else { 802 if { $mycurdata == "Edit data..." } { 803 ScilabEval "global ged_handle;EditData(ged_handle.data.z,\"ged_handle.data.z\")" "seq" 804 } 805 } 806} 807 808proc SelectDataColor {w args} { 809 global curdata_color 810 variable mycurdata 811 set mycurdata $curdata_color 812 set finddbarray -1 813 set dbarray "double array" 814 set finddbarray [expr [string first $dbarray $mycurdata]] 815# puts "finddbarray = $finddbarray" 816 817 if { ($mycurdata == "----") || ($finddbarray != -1) } { 818 # puts "nothing to do" 819 } else { 820 if { $mycurdata == "Edit data..." } { 821 ScilabEval "global ged_handle;EditData(ged_handle.data.color,\"ged_handle.data.color\")" "seq" 822 } 823 } 824} 825 826proc SavePreferences { } { 827 global ged_listofpref 828 global envSCIHOME MAIN_WINDOW_POSITION TICK_WINDOW_POSITION 829 global ww msdos 830 831 ScilabEval "DestroyGlobals()" "seq" 832 833 if { $msdos == "F" } { 834#unix mandrake (at least) needs this offset 835#test other unix distribution to see (red hat, suse...) 836 set xoffset -5 837 set yoffset -26 838 } else { 839 set xoffset 0 840 set yoffset 0 841 } 842 843 set x [eval {winfo x $ww}] 844 set y [eval {winfo y $ww}] 845 set MAIN_WINDOW_POSITION "+[expr $x+$xoffset]+[expr $y+$yoffset]" 846 847 #save preferences (position...) 848 set preffilename [file join $envSCIHOME .GedPreferences.tcl] 849 catch { 850 set preffile [open $preffilename w] 851 foreach opt $ged_listofpref { 852 global $opt 853 puts $preffile [concat "set $opt " [set $opt]] 854 # puts [concat "set $opt" [set $opt]] 855 } 856 close $preffile 857 } 858} 859 860proc DestroyGlobals { } { 861 ScilabEval "DestroyGlobals()" "seq" 862 863 SavePreferences 864} 865 866 867proc setMarkForeground {w index} { 868 global RED BLUE GREEN 869 variable REDCOL 870 variable GRECOL 871 variable BLUCOL 872 873 #ScilabEval "global ged_handle;" 874 if { $index == -2 } { 875 ScilabEval "global ged_handle; if ged_handle.mark_foreground <> $index then ged_handle.mark_foreground=$index; end;" 876 #like $index==-2: display white color 877 set color [format \#%02x%02x%02x 255 255 255] 878 $w config -activebackground $color -troughcolor $color 879 } elseif { $index == -1 } { 880 ScilabEval "global ged_handle; if ged_handle.mark_foreground <> $index then ged_handle.mark_foreground=$index; end;" 881 #like $index==-1: display black color 882 set color [format \#%02x%02x%02x 0 0 0] 883 $w config -activebackground $color -troughcolor $color 884 } elseif { $index == 0 } { 885 ScilabEval "global ged_handle; if ged_handle.mark_foreground <> $index then ged_handle.mark_foreground=$index; end;" 886 #like $index==1: display first color 887 set REDCOL $RED(1) 888 set GRECOL $GREEN(1) 889 set BLUCOL $BLUE(1) 890 891 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 892 893 $w config -activebackground $color -troughcolor $color 894 } else { 895 ScilabEval "global ged_handle; if ged_handle.mark_foreground <> $index then ged_handle.mark_foreground=$index; end;" 896 897 set REDCOL $RED($index) 898 set GRECOL $GREEN($index) 899 set BLUCOL $BLUE($index) 900 901 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 902 903 $w config -activebackground $color -troughcolor $color 904 905 } 906} 907 908 909 910proc setMarkBackground {w index} { 911 global RED BLUE GREEN 912 variable REDCOL 913 variable GRECOL 914 variable BLUCOL 915 916 #ScilabEval "global ged_handle;" 917 if { $index == -2 } { 918 ScilabEval "global ged_handle; if ged_handle.mark_background <> $index then ged_handle.mark_background=$index; end;" 919 #like $index==-2: display white color 920 set color [format \#%02x%02x%02x 255 255 255] 921 $w config -activebackground $color -troughcolor $color 922 } elseif { $index == -1 } { 923 ScilabEval "global ged_handle; if ged_handle.mark_background <> $index then ged_handle.mark_background=$index; end;" 924 #like $index==-1: display black color 925 set color [format \#%02x%02x%02x 0 0 0] 926 $w config -activebackground $color -troughcolor $color 927 } elseif { $index == 0 } { 928 ScilabEval "global ged_handle; if ged_handle.mark_background <> $index then ged_handle.mark_background=$index; end;" 929 #like $index==1: display first color 930 set REDCOL $RED(1) 931 set GRECOL $GREEN(1) 932 set BLUCOL $BLUE(1) 933 934 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 935 936 $w config -activebackground $color -troughcolor $color 937 } else { 938 ScilabEval "global ged_handle; if ged_handle.mark_background <> $index then ged_handle.mark_background=$index; end;" 939 940 set REDCOL $RED($index) 941 set GRECOL $GREEN($index) 942 set BLUCOL $BLUE($index) 943 944 set color [format \#%02x%02x%02x [expr int($REDCOL*255)] [expr int($GRECOL*255)] [expr int($BLUCOL*255)]] 945 946 $w config -activebackground $color -troughcolor $color 947 948 } 949} 950 951 952proc toggleMarkmode { frame } { 953 global curmarkmode 954 ScilabEval "global ged_handle;ged_handle.mark_mode='$curmarkmode'" 955 956 OnOffForeground $frame $curmarkmode 957} 958 959proc toggleLinemode { frame } { 960 global curlinemode 961 ScilabEval "global ged_handle;ged_handle.surface_mode='$curlinemode'" 962 963 OnOffForeground $frame $curlinemode 964} 965 966 967proc SelectMarkStyle {w args} { 968global curmarkstyle 969global curmarkmode 970ScilabEval "setMarkStyle('$curmarkstyle')" 971 972set curmarkmode "on" 973#ScilabEval "global ged_handle;ged_handle.mark_mode='$curmarkmode'" 974 975} 976 977proc SelectMarkSizeUnit {w args} { 978 global curmarksizeunit 979 ScilabEval "global ged_handle;ged_handle.mark_size_unit='$curmarksizeunit'" 980} 981 982 983 984proc SelectMarkSize {w args} { 985 global curmarksize 986 ScilabEval "global ged_handle;ged_handle.mark_size=$curmarksize" 987} 988 989 990proc SelectThickness {w args} { 991 global curthick 992 ScilabEval "global ged_handle;ged_handle.thickness=$curthick;" 993} 994