Update the changelog
[opencv] / apps / vmdemotk / VMDemoTkInit.cpp
1 #include "VMDemoTkInit.h"
2 #include "VMDemoTk.h"
3 #include "NewTclCommands.h"     
4 #include <highgui.h>
5
6 int VMDemoTkInit ( Tcl_Interp *interp, int argc, char **argv)
7 {
8     // creating the interpreter for tcl application
9     if(!interp)
10         interp = Tcl_CreateInterp();    
11     if(!interp)
12     {
13         printf("No interpretator\n");
14         return 1;
15     }
16     
17     // finding out application location
18     Tcl_FindExecutable(argv[0]);    
19     
20     // Here begins the first step on C and TCL
21     // integration: The Tcl/Tk initialization.
22     if (Tcl_Init(interp) == TCL_ERROR)          
23     {
24         fprintf(stderr, "Tcl_Init failed: %s\n",
25             interp->result);
26         return 1;
27     }
28     
29     if (Tk_Init(interp) == TCL_ERROR)
30     {
31         fprintf(stderr, "Tk_Init failed: %s\n",
32             interp->result);
33         return 1;
34     }
35     
36     
37     //The second step, creating new Tcl commands for user interface widgets.
38     
39     // procedure for "set original windows position" button
40     Tcl_CreateCommand (interp, "CSetpos", TKVMDemo_Setposition, 
41         (ClientData *) NULL, (Tcl_CmdDeleteProc *) NULL);  
42     
43     // fileopen dialog and procedure
44     Tcl_CreateCommand (interp, "Cfileopen", TKVMDemo_fileopen,
45         (ClientData *) NULL, (Tcl_CmdDeleteProc *) NULL);
46     
47     // Command for slider
48     Tcl_CreateCommand( interp, "Cscale", TKVMDemo_scale,
49                        (ClientData *) NULL, (Tcl_CmdDeleteProc *) NULL);
50     
51     // Command for showscanlines checkbutton
52     Tcl_CreateCommand( interp, "CShowScanlines", TKVMDemo_ShowScanlines,
53                        (ClientData *) NULL, (Tcl_CmdDeleteProc *) NULL);
54     
55     Tcl_CreateThreadExitHandler(OnExit, (ClientData *) NULL);
56     
57     //Now we evaluate the user interface script
58     if(Tcl_EvalFile(interp, "interface.tcl") == TCL_ERROR)
59     {
60         printf("%s\nline %d\n", interp->result, interp->errorLine);
61         return 1;
62     }
63     
64     //Setting windows to the original position
65     Tcl_Eval(interp, "CSetpos");
66     
67     cvvInitSystem(argc, argv);
68     cvvNamedWindow( "left", 0 );
69     cvvNamedWindow( "right", 0 );
70     cvvNamedWindow( "result", 0 );
71     
72     return 0;
73 }