tcledit: Fix some logic errors.

This commit is contained in:
Gregory Nutt 2016-11-12 07:56:59 -06:00
parent 307bb794a8
commit 104d743c2a
7 changed files with 329 additions and 286 deletions

View File

@ -397,7 +397,7 @@ static uint8_t wld_read_filename(INIHANDLE handle,
* Description:
************************************************************************/
uint8_t wld_create_world(char *wldfile)
uint8_t wld_create_world(const char *wldfile)
{
INIHANDLE handle;
uint8_t result;

View File

@ -101,7 +101,8 @@ extern "C"
/* World file return codes */
enum {
enum
{
WORLD_SUCCESS = 0,
WORLD_FILE_OPEN_ERROR = 100,
WORLD_INTEGER_OUT_OF_RANGE,
@ -112,20 +113,23 @@ enum {
WORLD_BITMAP_FILE_NAME_ERROR
};
/* The following structure contains all information necessary to define
* a point-of-view
*/
typedef struct {
struct wld_camer_s
{
wld_coord_t x; /* Camera position */
wld_coord_t y;
wld_coord_t z;
int16_t yaw; /* Camera orientation */
int16_t pitch;
};
wld_coord_t x, y, z; /* Camera position */
int16_t yaw, pitch; /* Camera orientation */
} wld_camera_t;
typedef struct wld_camer_s wld_camera_t;
/*************************************************************************
* Global Data
* Public Data
*************************************************************************/
/* This is the starting position and orientation of the camera in the world */
@ -150,7 +154,7 @@ extern wld_coord_t g_run_stepheight;
* Global Function Prototypes
*************************************************************************/
uint8_t wld_create_world(char *mapfile);
uint8_t wld_create_world(const char *mapfile);
void wld_deallocate_world(void);
#ifdef __cplusplus

View File

@ -1,6 +1,9 @@
Build instuctions
=================
tcledit is a world editor for the traveler. You should be able to build it
under Linux or Cygwin. It needs X11 and Tcl/Tk.
At the time of 'make', you must have a valid Traveler configuration instantiated
in the NuttX directory. This is because the build will depend on certain
configurations (such as color format).
@ -40,6 +43,8 @@ Build instuctions
10b. make tcledit DEBUG_LEVEL=1
On Cygwin, the make target will be tcledit.exe, not tcledit.
Usage
=====
@ -54,3 +59,6 @@ Usage
like:
./tcledit -D ../../world transfrm.wld
On Cywgin, the correct name of the program will be tcledit.exe and must also
remember to start the X11 server before trying run the applications.

View File

@ -40,6 +40,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@ -58,8 +59,9 @@
static Tcl_Interp *g_tcledit_interp;
static const char *g_in_filename;
static const char *g_out_filename;
static const char g_default_filename[] = "planes.pll";
static char *g_out_filename;
static char g_tcledit_filename[] = "tcl_edit.tk";
static char *g_tcledit_path = g_tcledit_filename;
/****************************************************************************
* Public Variables
@ -166,12 +168,12 @@ static void tcledit_update_newmode_display(void)
}
}
/* Called in response to the "seteditmode" Tcl command to set the
/* Called in response to the "tcl_seteditmode" Tcl command to set the
* current edit mode
*/
static int tcledit_setmode(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
@ -237,10 +239,10 @@ static int tcledit_setmode(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "position" Tcl command */
/* Called in response to the "tcl_position" Tcl command */
static int tcledit_new_position(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
@ -261,10 +263,10 @@ static int tcledit_new_position(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "zoom" Tcl command */
/* Called in response to the "tcl_zoom" Tcl command */
static int tcledit_new_zoom(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
@ -331,10 +333,10 @@ static int tcledit_new_zoom(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "edit" Tcl command */
/* Called in response to the "tcl_edit" Tcl command */
static int tcledit_new_edit(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
int start;
int end;
@ -446,10 +448,10 @@ static int tcledit_new_edit(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "attributes" Tcl command */
/* Called in response to the "tcl_attributes" Tcl command */
static int tcledit_new_attributes(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
const char *attributes;
int tmp;
@ -527,10 +529,10 @@ static int tcledit_new_attributes(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "addrectangle" Tcl command */
/* Called in response to the "tcl_addrectangle" Tcl command */
static int tcledit_add_rectangle(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
@ -574,10 +576,10 @@ static int tcledit_add_rectangle(ClientData clientData,
return TCL_OK;
}
/* Called in response to the "save" Tcl command */
/* Called in response to the "tcl_save" Tcl command */
static int tcledit_save_rectangles(ClientData clientData,
Tcl_Interp * interp, int argc, const char *argv[])
Tcl_Interp *interp, int argc, const char *argv[])
{
ginfo("Processing command: %s\n", argv[0]);
@ -607,17 +609,33 @@ int main(int argc, char **argv, char **envp)
{
char *directory;
int option;
int len;
int ret;
/* Parse command line options */
g_out_filename = g_default_filename;
g_out_filename = NULL;
while ((option = getopt(argc, argv, "D:o:")) != EOF)
{
switch (option)
{
case 'D':
/* Save the current working directory */
g_tcledit_path = (char *)malloc(PATH_MAX);
getcwd(g_tcledit_path, PATH_MAX);
len = strlen(g_tcledit_path);
g_tcledit_path[len] = '/';
g_tcledit_path[len+1] = '\0';
len++;
strcat(&g_tcledit_path[len], g_tcledit_filename);
g_tcledit_path = (char *)realloc(g_tcledit_path, strlen(g_tcledit_path) + 1);
/* Change to the new directory */
directory = optarg;
ret = chdir(directory);
if (ret < 0)
@ -650,6 +668,19 @@ int main(int argc, char **argv, char **envp)
g_in_filename = argv[optind];
/* The output file name defaults to the same as the input file name but
* with the extension .pll.
*/
if (g_out_filename == NULL)
{
char *ptr;
g_out_filename = strdup(g_in_filename + 5);
for (ptr = g_out_filename; *ptr != '.' && *ptr != '\0'; ptr++);
sprintf(ptr, ".pll");
}
/* Read the world files now so that we can be certain that it is a valid
* world file.
*/
@ -680,8 +711,9 @@ int do_tcl_action(const char *script)
* is entered.
*/
int Tcl_AppInit(Tcl_Interp * interp)
int Tcl_AppInit(Tcl_Interp *interp)
{
int ret;
int i;
/* Save the interpreter for later */
@ -692,48 +724,46 @@ int Tcl_AppInit(Tcl_Interp * interp)
for (i = 0; i < NUM_PLANES; i++)
{
x11_initilaize_graphics(&g_windows[i]);
x11_initialize_graphics(&g_windows[i]);
}
/* Tcl_Init() sets up the Tcl library factility */
if (Tcl_Init(interp) == TCL_ERROR)
{
return TCL_ERROR;
}
if (Tk_Init(interp) == TCL_ERROR)
ret = Tcl_Init(interp);
if (ret == TCL_ERROR)
{
return TCL_ERROR;
}
/* Define application-specific commands */
Tcl_CreateCommand(g_tcledit_interp, "seteditmode", tcledit_setmode,
Tcl_CreateCommand(g_tcledit_interp, "tcl_seteditmode", tcledit_setmode,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "position", tcledit_new_position,
Tcl_CreateCommand(g_tcledit_interp, "tcl_position", tcledit_new_position,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "zoom", tcledit_new_zoom,
Tcl_CreateCommand(g_tcledit_interp, "tcl_zoom", tcledit_new_zoom,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "edit", tcledit_new_edit,
Tcl_CreateCommand(g_tcledit_interp, "tcl_edit", tcledit_new_edit,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "attributes", tcledit_new_attributes,
Tcl_CreateCommand(g_tcledit_interp, "tcl_attributes", tcledit_new_attributes,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "addrectangle", tcledit_add_rectangle,
Tcl_CreateCommand(g_tcledit_interp, "tcl_addrectangle", tcledit_add_rectangle,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(g_tcledit_interp, "save", tcledit_save_rectangles,
Tcl_CreateCommand(g_tcledit_interp, "tcl_save", tcledit_save_rectangles,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
/* Initialize the Tcl parser */
if (Tcl_EvalFile(g_tcledit_interp, "tcledit.tk") != TCL_OK)
ret = Tcl_EvalFile(g_tcledit_interp, g_tcledit_path);
if (ret != TCL_OK)
{
fprintf(stderr, "%s\n", Tcl_GetVar(g_tcledit_interp, "errorCode", 0));
fprintf(stderr, "%s\n", Tcl_GetVar(g_tcledit_interp, "errorInfo", 0));
fprintf(stderr, "Tcl_EvalFile failed: %d\n", ret);
fprintf(stderr, " %s\n", Tcl_GetVar(g_tcledit_interp, "errorCode", 0));
fprintf(stderr, " %s\n", Tcl_GetVar(g_tcledit_interp, "errorInfo", 0));
exit(1);
}
return TCL_OK;
return ret;
}
void wld_fatal_error(char *message, ...)

View File

@ -35,6 +35,7 @@
#############################################################################
# Control features for each element
proc configentry {w option items} {
foreach i $items {
$w.$i configure -state $option
@ -44,43 +45,43 @@ proc configentry {w option items} {
proc configeditplane { w } {
global editplane editpoint
if {$editplane == "x"} {
$w.x configure -state disabled
if {($editpoint == "1") || ($editpoint == "2")} {
$w.y configure -state normal
} else {
$w.y configure -state disabled
}
if {($editpoint == "1") || ($editpoint == "3")} {
$w.z configure -state normal
} else {
$w.z configure -state disabled
}
$w.x configure -state disabled
if {($editpoint == "1") || ($editpoint == "2")} {
$w.y configure -state normal
} else {
$w.y configure -state disabled
}
if {($editpoint == "1") || ($editpoint == "3")} {
$w.z configure -state normal
} else {
$w.z configure -state disabled
}
}
if {$editplane == "y"} {
if {($editpoint == "1") || ($editpoint == "2")} {
$w.x configure -state normal
} else {
$w.x configure -state disabled
}
$w.y configure -state disabled
if {($editpoint == "1") || ($editpoint == "3")} {
$w.z configure -state normal
} else {
$w.z configure -state disabled
}
if {($editpoint == "1") || ($editpoint == "2")} {
$w.x configure -state normal
} else {
$w.x configure -state disabled
}
$w.y configure -state disabled
if {($editpoint == "1") || ($editpoint == "3")} {
$w.z configure -state normal
} else {
$w.z configure -state disabled
}
}
if {$editplane == "z"} {
if {($editpoint == "1") || ($editpoint == "2")} {
$w.x configure -state normal
} else {
$w.x configure -state disabled
}
if {($editpoint == "1") || ($editpoint == "3")} {
$w.y configure -state normal
} else {
$w.y configure -state disabled
}
$w.z configure -state disabled
if {($editpoint == "1") || ($editpoint == "2")} {
$w.x configure -state normal
} else {
$w.x configure -state disabled
}
if {($editpoint == "1") || ($editpoint == "3")} {
$w.y configure -state normal
} else {
$w.y configure -state disabled
}
$w.z configure -state disabled
}
}
@ -113,7 +114,7 @@ proc int {w text variable command} {
proc minimenu {w text variable} {
frame $w
menubutton $w.x -relief raised -borderwidth 2 -textvariable $variable \
-menu $w.x.menu -anchor w -width 8
-menu $w.x.menu -anchor w -width 8
button $w.l -text "$text" -relief groove -anchor w -width 8
$w.l configure -activefore [cget $w.l -fg] -activeback [cget $w.l -bg]
pack $w.l -anchor w -side right -fill y
@ -142,9 +143,9 @@ proc seteditmode {mode plane} {
set editmode $mode; set editplane $plane
tcl_seteditmode $mode $plane
if {($editmode == "NEW") || ($editmode == "EDIT")} {
set xpt1 $xpos; set xpt2 $xpos; set xpt3 $xpos; set xpt4 $xpos
set ypt1 $ypos; set ypt2 $ypos; set ypt3 $ypos; set ypt4 $ypos
set zpt1 $zpos; set zpt2 $zpos; set zpt3 $zpos; set zpt4 $zpos
set xpt1 $xpos; set xpt2 $xpos; set xpt3 $xpos; set xpt4 $xpos
set ypt1 $ypos; set ypt2 $ypos; set ypt3 $ypos; set ypt4 $ypos
set zpt1 $zpos; set zpt2 $zpos; set zpt3 $zpos; set zpt4 $zpos
}
set editwidth 0; set editheight 0
set shaded 0; set transparent 0; set door 0
@ -169,14 +170,14 @@ proc getxscale { xvalue } {
set xoffset [expr $xvalue * $screenwidth / 32768]
return [expr $xoffset + $xmin]
}
proc clipx { xvalue } {
global xmin xmax
if {$xvalue > $xmax} {
set xvalue $xmax
set xvalue $xmax
}
if {$xvalue < $xmin} {
set xvalue $xmin
set xvalue $xmin
}
setxscale $xvalue
return $xvalue
@ -186,29 +187,29 @@ proc neweditx { xvalue } {
global editmode editpoint editwidth
global xpt1 xpt2 xpt3 xpt4
if {($editmode == "NEW") || ($editmode == "EDIT")} {
if {$editpoint == "1"} {
if {$xvalue > $xpt2} {
set xvalue $xpt2
setxscale $xvalue
}
set xpt1 $xvalue
set xpt3 $xvalue
} else {
if {$xvalue < $xpt1} {
set xvalue $xpt1
setxscale $xvalue
}
set xpt2 $xvalue
set xpt4 $xvalue
}
set editwidth [expr $xpt2 - $xpt1]
tcl_edit "x" $xpt1 $editwidth
if {$editpoint == "1"} {
if {$xvalue > $xpt2} {
set xvalue $xpt2
setxscale $xvalue
}
set xpt1 $xvalue
set xpt3 $xvalue
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set xpos $xvalue
tcl_position $xpos $ypos $zpos
}
if {$xvalue < $xpt1} {
set xvalue $xpt1
setxscale $xvalue
}
set xpt2 $xvalue
set xpt4 $xvalue
}
set editwidth [expr $xpt2 - $xpt1]
tcl_edit "x" $xpt1 $editwidth
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set xpos $xvalue
tcl_position $xpos $ypos $zpos
}
}
}
@ -238,14 +239,14 @@ proc getyscale { yvalue } {
set yoffset [expr $yvalue * $screenwidth / 32768]
return [expr $yoffset + $ymin]
}
proc clipy { yvalue } {
global ymin ymax
if {$yvalue > $ymax} {
set yvalue $ymax
set yvalue $ymax
}
if {$yvalue < $ymin} {
set yvalue $ymin
set yvalue $ymin
}
setyscale $yvalue
return $yvalue
@ -255,49 +256,49 @@ proc newedity { yvalue } {
global editmode editplane editpoint editwidth editheight
global ypt1 ypt2 ypt3 ypt4
if {($editmode == "NEW") || ($editmode == "EDIT")} {
if {$editplane == "x"} {
if {$editpoint == "1"} {
if {$yvalue > $ypt2} {
set yvalue $ypt2
setyscale $yvalue
}
set ypt1 $yvalue
set ypt3 $yvalue
} else {
if {$yvalue < $ypt1} {
set yvalue $ypt1
setyscale $yvalue
}
set ypt2 $yvalue
set ypt4 $yvalue
}
set editwidth [expr $ypt2 - $ypt1]
tcl_edit "y" $ypt1 $editwidth
} else {
if {$editpoint == "1"} {
if {$yvalue > $ypt3} {
set yvalue $ypt3
setyscale $yvalue
}
set ypt1 $yvalue
set ypt2 $yvalue
} else {
if {$yvalue < $ypt1} {
set yvalue $ypt1
setyscale $yvalue
}
set ypt3 $yvalue
set ypt4 $yvalue
}
set editheight [expr $ypt3 - $ypt1]
tcl_edit "y" $ypt1 $editheight
}
if {$editplane == "x"} {
if {$editpoint == "1"} {
if {$yvalue > $ypt2} {
set yvalue $ypt2
setyscale $yvalue
}
set ypt1 $yvalue
set ypt3 $yvalue
} else {
if {$yvalue < $ypt1} {
set yvalue $ypt1
setyscale $yvalue
}
set ypt2 $yvalue
set ypt4 $yvalue
}
set editwidth [expr $ypt2 - $ypt1]
tcl_edit "y" $ypt1 $editwidth
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set ypos $yvalue
tcl_position $xpos $ypos $zpos
}
if {$editpoint == "1"} {
if {$yvalue > $ypt3} {
set yvalue $ypt3
setyscale $yvalue
}
set ypt1 $yvalue
set ypt2 $yvalue
} else {
if {$yvalue < $ypt1} {
set yvalue $ypt1
setyscale $yvalue
}
set ypt3 $yvalue
set ypt4 $yvalue
}
set editheight [expr $ypt3 - $ypt1]
tcl_edit "y" $ypt1 $editheight
}
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set ypos $yvalue
tcl_position $xpos $ypos $zpos
}
}
}
@ -327,14 +328,14 @@ proc getzscale { zvalue } {
set zoffset [expr $zvalue * $screenwidth / 32768]
return [expr $zoffset + $zmin]
}
proc clipz { zvalue } {
global zmin zmax
if {$zvalue > $zmax} {
set zvalue $zmax
set zvalue $zmax
}
if {$zvalue < $zmin} {
set zvalue $zmin
set zvalue $zmin
}
setzscale $zvalue
return $zvalue
@ -344,29 +345,29 @@ proc neweditz { zvalue } {
global editmode editpoint editheight
global zpt1 zpt2 zpt3 zpt4
if {($editmode == "NEW") || ($editmode == "EDIT")} {
if {$editpoint == "1"} {
if {$zvalue > $zpt3} {
set zvalue $zpt3
setzscale $zvalue
}
set zpt1 $zvalue
set zpt2 $zvalue
} else {
if {$zvalue < $zpt1} {
set zvalue $zpt1
setzscale $zvalue
}
set zpt3 $zvalue
set zpt4 $zvalue
}
set editheight [expr $zpt3 - $zpt1]
tcl_edit "z" $zpt1 $editheight
if {$editpoint == "1"} {
if {$zvalue > $zpt3} {
set zvalue $zpt3
setzscale $zvalue
}
set zpt1 $zvalue
set zpt2 $zvalue
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set zpos $zvalue
tcl_position $xpos $ypos $zpos
}
if {$zvalue < $zpt1} {
set zvalue $zpt1
setzscale $zvalue
}
set zpt3 $zvalue
set zpt4 $zvalue
}
set editheight [expr $zpt3 - $zpt1]
tcl_edit "z" $zpt1 $editheight
} else {
if {$editmode == "POS"} {
global xpos ypos zpos
set zpos $zvalue
tcl_position $xpos $ypos $zpos
}
}
}
@ -389,38 +390,38 @@ proc newwidth { width } {
global xmax xpt1 xpt2 xpt3 xpt4
global ymax ypt1 ypt2 ypt3 ypt4
if {($editmode == "NEW") || ($editmode == "EDIT")} {
if {$width < 0} {
set editwidth 0
set width 0
}
switch -exact -- $editplane {
x {
set ypt2 [expr $ypt1 + $width]
if {$ypt2 > $ymax} {
set ypt2 $ymax
set editwidth [expr $ypt2 - $ypt1]
}
set ypt3 $ypt1
set ypt4 $ypt2
if {$editpoint == "2"} {
setyscale $ypt2
}
tcl_edit "y" $ypt1 $editwidth
}
default {
set xpt2 [expr $xpt1 + $width]
if {$xpt2 > $xmax} {
set xpt2 $xmax
set editwidth [expr $xpt2 - $xpt1]
}
set xpt3 $xpt1
set xpt4 $xpt2
if {$editpoint == "2"} {
setxscale $xpt2
}
tcl_edit "x" $xpt1 $editwidth
}
}
if {$width < 0} {
set editwidth 0
set width 0
}
switch -exact -- $editplane {
x {
set ypt2 [expr $ypt1 + $width]
if {$ypt2 > $ymax} {
set ypt2 $ymax
set editwidth [expr $ypt2 - $ypt1]
}
set ypt3 $ypt1
set ypt4 $ypt2
if {$editpoint == "2"} {
setyscale $ypt2
}
tcl_edit "y" $ypt1 $editwidth
}
default {
set xpt2 [expr $xpt1 + $width]
if {$xpt2 > $xmax} {
set xpt2 $xmax
set editwidth [expr $xpt2 - $xpt1]
}
set xpt3 $xpt1
set xpt4 $xpt2
if {$editpoint == "2"} {
setxscale $xpt2
}
tcl_edit "x" $xpt1 $editwidth
}
}
}
}
@ -430,38 +431,38 @@ proc newheight { height } {
global ymax ypt1 ypt2 ypt3 ypt4
global zmax zpt1 zpt2 zpt3 zpt4
if {($editmode == "NEW") || ($editmode == "EDIT")} {
if {$height < 0} {
set editheight 0
set height 0
}
switch -exact -- $editplane {
z {
set ypt3 [expr $ypt1 + $height]
if {$ypt3 > $ymax} {
set ypt3 $ymax
set editheight [expr $ypt3 - $ypt1]
}
set ypt2 $ypt1
set ypt4 $ypt3
if {$editpoint == "3"} {
setyscale $ypt3
}
tcl_edit "y" $ypt1 $editheight
}
default {
set zpt3 [expr $zpt1 + $height]
if {$zpt3 > $zmax} {
set zpt3 $zmax
set editheight [expr $zpt3 - $zpt1]
}
set zpt2 $zpt1
set zpt4 $zpt3
if {$editpoint == "3"} {
setzscale $zpt3
}
tcl_edit "z" $zpt1 $editheight
}
}
if {$height < 0} {
set editheight 0
set height 0
}
switch -exact -- $editplane {
z {
set ypt3 [expr $ypt1 + $height]
if {$ypt3 > $ymax} {
set ypt3 $ymax
set editheight [expr $ypt3 - $ypt1]
}
set ypt2 $ypt1
set ypt4 $ypt3
if {$editpoint == "3"} {
setyscale $ypt3
}
tcl_edit "y" $ypt1 $editheight
}
default {
set zpt3 [expr $zpt1 + $height]
if {$zpt3 > $zmax} {
set zpt3 $zmax
set editheight [expr $zpt3 - $zpt1]
}
set zpt2 $zpt1
set zpt4 $zpt3
if {$editpoint == "3"} {
setzscale $zpt3
}
tcl_edit "z" $zpt1 $editheight
}
}
}
}
@ -485,40 +486,40 @@ proc newzoom { newzoom } {
set screenwidth [expr 32768 / $newzoom]
set halfwidth [expr $screenwidth / 2]
if { $xpos < $halfwidth } {
set xmin 0
set xmax [expr $screenwidth - 1]
set xmin 0
set xmax [expr $screenwidth - 1]
} else {
if { [expr $xpos + $halfwidth] > 32767 } {
set xmax 32767
set xmin [expr $xmax - $screenwidth]
} else {
set xmin [expr $xpos - $halfwidth]
set xmax [expr $xmin + $screenwidth - 1]
}
if { [expr $xpos + $halfwidth] > 32767 } {
set xmax 32767
set xmin [expr $xmax - $screenwidth]
} else {
set xmin [expr $xpos - $halfwidth]
set xmax [expr $xmin + $screenwidth - 1]
}
}
if { $ypos < $halfwidth } {
set ymin 0
set ymax [expr $screenwidth - 1]
set ymin 0
set ymax [expr $screenwidth - 1]
} else {
if { [expr $ypos + $halfwidth] > 32767 } {
set ymax 32767
set ymin [expr $ymax - $screenwidth]
} else {
set ymin [expr $ypos - $halfwidth]
set ymax [expr $ymin + $screenwidth - 1]
}
if { [expr $ypos + $halfwidth] > 32767 } {
set ymax 32767
set ymin [expr $ymax - $screenwidth]
} else {
set ymin [expr $ypos - $halfwidth]
set ymax [expr $ymin + $screenwidth - 1]
}
}
if { $zpos < $halfwidth } {
set zmin 0
set zmax [expr $screenwidth - 1]
set zmin 0
set zmax [expr $screenwidth - 1]
} else {
if { [expr $zpos + $halfwidth] > 32767 } {
set zmax 32767
set zmin [expr $zmax - $screenwidth]
} else {
set zmin [expr $zpos - $halfwidth]
set zmax [expr $zmin + $screenwidth - 1]
}
if { [expr $zpos + $halfwidth] > 32767 } {
set zmax 32767
set zmin [expr $zmax - $screenwidth]
} else {
set zmin [expr $zpos - $halfwidth]
set zmax [expr $zmin + $screenwidth - 1]
}
}
setxscale $tmpxscale
setyscale $tmpyscale
@ -735,29 +736,29 @@ proc edit5 { w } {
minimenu $w.scale "Scale" scaling
menu $w.scale.x.menu -title "Scaling"
$w.scale.x.menu add radiobutton -label "1x" -variable scaling \
-value "1x" -command "newscale 0"
-value "1x" -command "newscale 0"
$w.scale.x.menu add radiobutton -label "2x" -variable scaling \
-value "2x" -command "newscale 1"
-value "2x" -command "newscale 1"
$w.scale.x.menu add radiobutton -label "4x" -variable scaling \
-value "4x" -command "newscale 2"
-value "4x" -command "newscale 2"
minimenu $w.zoom "Zoom" zoom
menu $w.zoom.x.menu -title "Zoom"
$w.zoom.x.menu add radiobutton -label "1x" -variable zoom \
-value "1x" -command "newzoom 1"
-value "1x" -command "newzoom 1"
$w.zoom.x.menu add radiobutton -label "2x" -variable zoom \
-value "2x" -command "newzoom 2"
-value "2x" -command "newzoom 2"
$w.zoom.x.menu add radiobutton -label "4x" -variable zoom \
-value "4x" -command "newzoom 4"
-value "4x" -command "newzoom 4"
$w.zoom.x.menu add radiobutton -label "8x" -variable zoom \
-value "8x" -command "newzoom 8"
-value "8x" -command "newzoom 8"
$w.zoom.x.menu add radiobutton -label "16x" -variable zoom \
-value "16x" -command "newzoom 16"
-value "16x" -command "newzoom 16"
$w.zoom.x.menu add radiobutton -label "32x" -variable zoom \
-value "32x" -command "newzoom 32"
-value "32x" -command "newzoom 32"
$w.zoom.x.menu add radiobutton -label "64x" -variable zoom \
-value "64x" -command "newzoom 64"
-value "64x" -command "newzoom 64"
$w.zoom.x.menu add radiobutton -label "128x" -variable zoom \
-value "128x" -command "newzoom 128"
-value "128x" -command "newzoom 128"
int $w.texture "Texture" texture newtexture
pack $w.scale -anchor w -side top -fill y
pack $w.zoom -anchor w -side top -fill y
@ -807,11 +808,11 @@ proc xyzscale { w } {
global xscale yscale zscale
frame $w
scale $w.x -from 0 -to 32767 -length 512 -variable xscale \
-orient horizontal -showvalue false -command "newxscale"
-orient horizontal -showvalue false -command "newxscale"
scale $w.y -from 0 -to 32767 -length 512 -variable yscale \
-orient horizontal -showvalue false -command "newyscale"
-orient horizontal -showvalue false -command "newyscale"
scale $w.z -from 0 -to 32767 -length 512 -variable zscale \
-orient horizontal -showvalue false -command "newzscale"
-orient horizontal -showvalue false -command "newzscale"
pack $w.x -anchor w -side top -fill y
pack $w.y -anchor w -side top -fill y
pack $w.z -anchor w -side top -fill y

View File

@ -436,11 +436,11 @@ void x11_UpdateScreen(tcl_window_t * w)
****************************************************************************/
/****************************************************************************
* Name: x11_initilaize_graphics
* Name: x11_initialize_graphics
* Description:
***************************************************************************/
void x11_initilaize_graphics(tcl_window_t * w)
void x11_initialize_graphics(tcl_window_t * w)
{
XWindowAttributes windowAttributes;

View File

@ -166,7 +166,7 @@ extern rect_data_t g_edit_rect;
* Public Function Prototypes
****************************************************************************/
void x11_initilaize_graphics(tcl_window_t *w);
void x11_initialize_graphics(tcl_window_t *w);
void x11_end_graphics(tcl_window_t *w);
void x11_update_screen(tcl_window_t *w);