Commit 676d3f9a authored by Russ Fish's avatar Russ Fish

Two hypview client fixes:

  . Make the AnimationFrames GUI control work on Windows and FreeBSD.

  . Make animated moves work in HyperViewer on FreeBSD.

    - Add setFrameEndCB to HypView{,er}.{h,cpp}, frameEndCB to hvmain.cpp .

    - Pass the wxGLCanvas pointer from the Python app all the way down to
      frameEndCB to call wxGLCanvas->SwapBuffers().
      The pointer comes through "encrypted" from Python, hack around that.

    - hvMain now needs to be compiled and linked against the
      wx_gtk2-2.4 includes and libs so it can call SwapBuffers.
parent 924998ca
......@@ -18,10 +18,17 @@ HVLIBDIR = ${HVSRC}/${ARCH}
HVLIBNAME = ${LIBRARY}${ARCH}
HVLIB = ${HVLIBDIR}/lib${HVLIBNAME}.a
CFLAGS = -DHYPGLUT -DHYPFREE -DGL_GLEXT_LEGACY -g -DNAMESPACEHACK=
INCDIRS = -I${HVINC} -I/usr/X11R6/include -I/usr/local/include/python2.3
# From wxgtk2-2.4-config --cxxflags
WXCFLAGS = -DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
XI = /usr/X11R6/include
WXIFLAGS = -I${XI}/wx/gtk2-2.4 -I${XI}
# From wxgtk2-2.4-config --libs --gl-libs
WXLIBS = -lwx_gtk2-2.4 -lwx_gtk2_gl-2.4
CFLAGS = -DHYPGLUT -DHYPFREE -DGL_GLEXT_LEGACY -g -DNAMESPACEHACK= ${WXCFLAGS}
INCDIRS = -I${HVINC} ${WXIFLAGS} -I/usr/local/include/python2.3
###STATIC = -static
LDLIBS = ${HVLIB} ${STATIC} -L/usr/X11R6/lib -lGLU -lGL -lXmu -lXext -lX11 -lm
LDLIBS = ${HVLIB} ${STATIC} -L/usr/X11R6/lib ${WXLIBS} -lGLU -lGL -lXmu -lXext -lX11 -lm
# Distribute the Python scripts, sources, shared library, sample input files, and user doc.
PYFILES = hypview.py exptToHv.py sshxmlrpc.py emulabclient.py hvFrameUI.py hv.py hv_win32.py
......
......@@ -701,13 +701,14 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
/* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_f_r_q_const__string_int_int__void swig_types[0]
#define SWIGTYPE_p_timeval swig_types[1]
#define SWIGTYPE_p_HypGraph swig_types[2]
#define SWIGTYPE_p_HypView swig_types[3]
#define SWIGTYPE_p_p_char swig_types[4]
#define SWIGTYPE_p_string swig_types[5]
#define SWIGTYPE_p_istream swig_types[6]
static swig_type_info *swig_types[8];
#define SWIGTYPE_p_f_int__void swig_types[1]
#define SWIGTYPE_p_timeval swig_types[2]
#define SWIGTYPE_p_HypGraph swig_types[3]
#define SWIGTYPE_p_HypView swig_types[4]
#define SWIGTYPE_p_p_char swig_types[5]
#define SWIGTYPE_p_string swig_types[6]
#define SWIGTYPE_p_istream swig_types[7]
static swig_type_info *swig_types[9];
/* -------- TYPES TABLE (END) -------- */
......@@ -739,8 +740,8 @@ NAMESPACEHACK
#include "HypView.h"
extern HypView *hvmain(int,char *[],int,int,int);
extern void hvkill(HypView *);
extern HypView *hvMain(int,char *[],void *,int,int);
extern void hvKill(HypView *);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char *getGraphCenter();
......@@ -805,17 +806,18 @@ extern void selectCB(std::string const &,int,int);
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_hvmain(PyObject *self, PyObject *args) {
static PyObject *_wrap_hvMain(PyObject *self, PyObject *args) {
PyObject *resultobj;
int arg1 ;
char **arg2 ;
int arg3 ;
void *arg3 = (void *) 0 ;
int arg4 ;
int arg5 ;
HypView *result;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"Oiii:hvmain",&obj0,&arg3,&arg4,&arg5)) goto fail;
if(!PyArg_ParseTuple(args,(char *)"OOii:hvMain",&obj0,&obj1,&arg4,&arg5)) goto fail;
{
/* Check if is a list */
if (PyList_Check(obj0)) {
......@@ -838,8 +840,9 @@ static PyObject *_wrap_hvmain(PyObject *self, PyObject *args) {
return NULL;
}
}
result = (HypView *)hvmain(arg1,arg2,arg3,arg4,arg5);
//printf("hvmain %d 0x%x\n", result, result);
if ((SWIG_ConvertPtr(obj1,(void **) &arg3, 0, SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
result = (HypView *)hvMain(arg1,arg2,arg3,arg4,arg5);
resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_HypView, 0);
return resultobj;
fail:
......@@ -847,15 +850,14 @@ static PyObject *_wrap_hvmain(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_hvkill(PyObject *self, PyObject *args) {
static PyObject *_wrap_hvKill(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:hvkill",&obj0)) goto fail;
if(!PyArg_ParseTuple(args,(char *)"O:hvKill",&obj0)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_HypView,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
//printf("hvkill %d 0x%x\n", arg1, arg1);
hvkill(arg1);
hvKill(arg1);
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
......@@ -2334,6 +2336,25 @@ static PyObject *_wrap_HypView_setPickCallback(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_HypView_setFrameEndCallback(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
void (*arg2)(int) = (void (*)(int)) 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OO:HypView_setFrameEndCallback",&obj0,&obj1)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_HypView,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_f_int__void,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
(arg1)->setFrameEndCallback(arg2);
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_HypView_addSpanPolicy(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
......@@ -3238,8 +3259,8 @@ static PyObject * HypView_swigregister(PyObject *self, PyObject *args) {
return Py_BuildValue((char *)"");
}
static PyMethodDef SwigMethods[] = {
{ (char *)"hvmain", _wrap_hvmain, METH_VARARGS },
{ (char *)"hvkill", _wrap_hvkill, METH_VARARGS },
{ (char *)"hvMain", _wrap_hvMain, METH_VARARGS },
{ (char *)"hvKill", _wrap_hvKill, METH_VARARGS },
{ (char *)"hvReadFile", _wrap_hvReadFile, METH_VARARGS },
{ (char *)"getSelected", _wrap_getSelected, METH_VARARGS },
{ (char *)"getGraphCenter", _wrap_getGraphCenter, METH_VARARGS },
......@@ -3294,6 +3315,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"HypView_setHiliteCallback", _wrap_HypView_setHiliteCallback, METH_VARARGS },
{ (char *)"HypView_setLabelToRight", _wrap_HypView_setLabelToRight, METH_VARARGS },
{ (char *)"HypView_setPickCallback", _wrap_HypView_setPickCallback, METH_VARARGS },
{ (char *)"HypView_setFrameEndCallback", _wrap_HypView_setFrameEndCallback, METH_VARARGS },
{ (char *)"HypView_addSpanPolicy", _wrap_HypView_addSpanPolicy, METH_VARARGS },
{ (char *)"HypView_clearSpanPolicy", _wrap_HypView_clearSpanPolicy, METH_VARARGS },
{ (char *)"HypView_getDynamicFrameTime", _wrap_HypView_getDynamicFrameTime, METH_VARARGS },
......@@ -3351,6 +3373,7 @@ static PyMethodDef SwigMethods[] = {
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
static swig_type_info _swigt__p_f_r_q_const__string_int_int__void[] = {{"_p_f_r_q_const__string_int_int__void", 0, "void (*)(string const &,int,int)", 0},{"_p_f_r_q_const__string_int_int__void"},{0}};
static swig_type_info _swigt__p_f_int__void[] = {{"_p_f_int__void", 0, "void (*)(int)", 0},{"_p_f_int__void"},{0}};
static swig_type_info _swigt__p_timeval[] = {{"_p_timeval", 0, "timeval *", 0},{"_p_timeval"},{0}};
static swig_type_info _swigt__p_HypGraph[] = {{"_p_HypGraph", 0, "HypGraph *", 0},{"_p_HypGraph"},{0}};
static swig_type_info _swigt__p_HypView[] = {{"_p_HypView", 0, "HypView *", 0},{"_p_HypView"},{0}};
......@@ -3360,6 +3383,7 @@ static swig_type_info _swigt__p_istream[] = {{"_p_istream", 0, "istream *", 0},{
static swig_type_info *swig_types_initial[] = {
_swigt__p_f_r_q_const__string_int_int__void,
_swigt__p_f_int__void,
_swigt__p_timeval,
_swigt__p_HypGraph,
_swigt__p_HypView,
......
......@@ -9,6 +9,7 @@ import sets
import string
import fnmatch
import os
import os.path
from sshxmlrpc import *
from emulabclient import *
......@@ -17,7 +18,9 @@ from emulabclient import *
PACKAGE_VERSION = 0.1 # The package version number
XMLRPC_SERVER = "boss.emulab.net" # Default server
xmlrpc_server = XMLRPC_SERVER # User supplied server name.
if os.environ.has_key("USER"): # User login ID to use.
if os.environ.has_key("EMULAB_USER"): # Emulab user login ID to use.
login_id = os.environ["EMULAB_USER"]
elif os.environ.has_key("USER"): # User login ID to use.
login_id = os.environ["USER"] # Unix shells.
elif os.environ.has_key("USERNAME"):
login_id = os.environ["USERNAME"] # Windows.
......@@ -52,12 +55,15 @@ def addConnection(graph, h1, h2):
graph[h1].add(h2)
else:
graph[h1] = sets.Set([h2])
pass
# Make back-connections as well for an undirected (bi-directed) graph.
if h2 in graph:
graph[h2].add(h1)
else:
graph[h2] = sets.Set([h1])
pass
pass
## getExperiment - Make the request from the server. Reconstitute a topology graph
## from the host interface list, and traverse it to write HyperViewer .hyp file.
......@@ -119,7 +125,6 @@ def getExperiment(project, experiment, root=""):
hosts.add(h1)
hosts.add(h2)
addConnection(graph, h1, h2)
pass
else:
# Lan nodes are are links with more than two interfaces as members.
lans.add(link)
......@@ -133,7 +138,6 @@ def getExperiment(project, experiment, root=""):
if root == "":
if len(lans) > 0:
root = lans.copy().pop()
pass
else:
root = hosts.copy().pop()
pass
......@@ -178,10 +182,11 @@ def getExperiment(project, experiment, root=""):
if os.name == "nt":
tmpdir = "C:\\temp\\"
pass
else:
tmpdir = "/tmp/"
pass
if not os.path.exists(tmpdir):
tmpdir = "" # Default to the current directory.
hypfile = tmpdir + experiment + '.hyp'
outfile = file(hypfile, 'w')
graph2 = {}
......
......@@ -51,13 +51,20 @@ NAMESPACEHACK
}
// It's easier to return the pointer to the HypView object rather than access the global.
extern HypView *hvmain(int argc, char *argv[], int window, int width, int height);
extern void hvkill(HypView *hv);
//extern HypView *hvmain(int argc, char *argv[], int window, int width, int height);
#ifndef WIN32
extern HypView *hvMain(int argc, char *argv[], void *window, int width, int height);
#else
extern HypView *hvMain(int argc, char *argv[], int window, int width, int height);
#endif
//extern int hvmain(int argc, char *argv[]);
//%include "cpointer.i"
//%pointer_class(HypView,hvp)
//extern HypView *hv;
extern void hvKill(HypView *hv);
// Separate out file reading from the main program.
extern int hvReadFile(char *fname, int width, int height);
......@@ -874,6 +881,10 @@ public:
// bindCallback() documentation for more details.
void setPickCallback(void (*fp)(const string &,int,int));
/// Set the highlight callback to a function pointer. Windowing system
// interface code may call this in HypViewer::FrameEnd().
void setFrameEndCallback(void (*fp)(int));
// GROUP: HypData
//
......
......@@ -51,13 +51,20 @@ NAMESPACEHACK
}
// It's easier to return the pointer to the HypView object rather than access the global.
extern HypView *hvmain(int argc, char *argv[], int window, int width, int height);
extern void hvkill(HypView *hv);
//extern HypView *hvmain(int argc, char *argv[], int window, int width, int height);
#ifndef WIN32
extern HypView *hvMain(int argc, char *argv[], void *window, int width, int height);
#else
extern HypView *hvMain(int argc, char *argv[], int window, int width, int height);
#endif
//extern int hvmain(int argc, char *argv[]);
//%include "cpointer.i"
//%pointer_class(HypView,hvp)
//extern HypView *hv;
extern void hvKill(HypView *hv);
// Separate out file reading from the main program.
extern int hvReadFile(char *fname, int width, int height);
......
......@@ -31,9 +31,9 @@ del types
hvmain = _hv.hvmain
hvMain = _hv.hvMain
hvkill = _hv.hvkill
hvKill = _hv.hvKill
hvReadFile = _hv.hvReadFile
......@@ -104,6 +104,7 @@ class HypView(_object):
def setHiliteCallback(*args): return _hv.HypView_setHiliteCallback(*args)
def setLabelToRight(*args): return _hv.HypView_setLabelToRight(*args)
def setPickCallback(*args): return _hv.HypView_setPickCallback(*args)
def setFrameEndCallback(*args): return _hv.HypView_setFrameEndCallback(*args)
def addSpanPolicy(*args): return _hv.HypView_addSpanPolicy(*args)
def clearSpanPolicy(*args): return _hv.HypView_clearSpanPolicy(*args)
def getDynamicFrameTime(*args): return _hv.HypView_getDynamicFrameTime(*args)
......
......@@ -74,7 +74,7 @@ class OpenDialogUI(wxDialog):
self.label_8 = wxStaticText(self, -1, "Root (optional):")
self.ExperimentRoot = wxTextCtrl(self, -1, "", style=wxTE_PROCESS_ENTER)
self.OpenExperiment = wxButton(self, -1, "Retrieve experiment")
self.ExperimentMsg = wxStaticText(self, -1, "")
self.ExperimentMsg = wxStaticText(self, -1, " \n ")
self.__set_properties()
self.__do_layout()
......@@ -83,7 +83,7 @@ class OpenDialogUI(wxDialog):
def __set_properties(self):
# begin wxGlade: OpenDialogUI.__set_properties
self.SetTitle("Open HyperViewer Data")
self.SetSize((387, 310))
self.SetSize((387, 351))
self.FileToOpen.SetFocus()
# end wxGlade
......@@ -162,7 +162,7 @@ class hvFrameUI(wxFrame):
self.label_4 = wxStaticText(self.Controls, -1, " Node depth")
self.CountGenLink = wxSpinCtrl(self.Controls, -1, "30", min=1, max=30)
self.label_5 = wxStaticText(self.Controls, -1, " Link depth")
self.AnimStepCount = wxSlider(self.Controls, -1, 12, 1, 100)
self.AnimStepCount = wxSlider(self.Controls, -1, 12, 1, 100, style=wxSL_HORIZONTAL|wxSL_LABELS)
self.label_6 = wxStaticText(self.Controls, -1, " Animation frames")
self.static_line_2 = wxStaticLine(self.Controls, -1)
self.HelpButton = wxButton(self.Controls, -1, "Help")
......@@ -198,7 +198,7 @@ class hvFrameUI(wxFrame):
self.CountGenLink.SetToolTipString("Generation Link Limit")
self.label_5.SetToolTipString("Generation Link Limit")
self.AnimStepCount.SetSize((150, 40))
self.AnimStepCount.SetToolTipString("Number of frames per animation")
self.AnimStepCount.SetToolTipString("Number of frames per second in animated moves")
self.label_6.SetToolTipString("Number of frames per animation")
self.window_1.SetSize((760, 619))
self.window_1.SplitVertically(self.panel_1, self.Controls)
......
<?xml version="1.0"?>
<!-- generated by wxGlade 0.3.1 on Mon Aug 2 10:20:56 2004 -->
<!-- generated by wxGlade 0.3.1 on Tue Aug 3 11:22:36 2004 -->
<application path="hvFrameUI.py" name="hvGui" class="hvApp" option="0" language="python" top_window="" encoding="US-ASCII" use_gettext="0" overwrite="0">
<object class="hvFrameUI" name="MainWindow" base="EditFrame">
......@@ -359,8 +359,8 @@
<border>0</border>
<option>0</option>
<object class="wxSlider" name="AnimStepCount" base="EditSlider">
<style>wxSL_HORIZONTAL</style>
<tooltip>Number of frames per animation</tooltip>
<style>wxSL_HORIZONTAL|wxSL_LABELS</style>
<tooltip>Number of frames per second in animated moves</tooltip>
<range>1, 100</range>
<value>12</value>
<size>150, 40</size>
......@@ -405,7 +405,7 @@
<object class="OpenDialogUI" name="OpenDialog" base="EditDialog">
<style>wxCAPTION|wxRESIZE_BORDER|wxTHICK_FRAME</style>
<title>Open HyperViewer Data</title>
<size>387, 310</size>
<size>387, 351</size>
<object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
......@@ -523,7 +523,7 @@
<option>0</option>
<object class="wxStaticText" name="ExperimentMsg" base="EditStaticText">
<attribute>1</attribute>
<label> </label>
<label> \n </label>
</object>
</object>
</object>
......
......@@ -21,19 +21,28 @@
#include <iostream>
NAMESPACEHACK
#if 1
#include "wx/setup.h"
#include "wx/glcanvas.h"
#endif
extern "C" {
#include <stdlib.h>
#if 0
#include <GL/glut.h>
#endif
#ifndef WIN32
#include <ieeefp.h>
#endif
#ifdef HYPFREE
#include <floatingpoint.h>
#endif
#include <errno.h>
}
#ifdef HYPIRIX
#include <fstream.h>
#else
......@@ -46,7 +55,8 @@ extern "C" {
//char prevsel[1024];
string prevsel;
auto_ptr<HypView> hv;
auto_ptr<HypView> hv; // We own this; make sure the pointed-to HypView will be deleted.
wxGLCanvas *glcanvas; // We don't own this, so don't wrap it in an auto_ptr.
char const *getSelected(){
return prevsel.c_str();
......@@ -68,6 +78,11 @@ void selectCB(const string & id, int shift, int control) {
prevsel = id;
}
void frameEndCB(int) {
//printf("frameEndCB glcanvas=0x%x\n", glcanvas);
glcanvas->SwapBuffers();
}
void display() { hv->drawFrame(); }
void mouse(int b, int s, int x, int y) { hv->mouse(b,s,x,y,0,0); }
void motion(int x, int y) { hv->motion(x,y,0,0); }
......@@ -130,11 +145,7 @@ void PrintAllocations()
#if 0
int main(int argc, char *argv[]) {
#else
void hvkill(HypView * /*hv*/) {
// delete( hv );
}
HypView *hvmain(int argc, char *argv[], int window, int width, int height) {
HypView *hvMain(int argc, char *argv[], void * window, int width, int height) {
#endif
char *fname;
if (argc > 1)
......@@ -187,7 +198,13 @@ HypView *hvmain(int argc, char *argv[], int window, int width, int height) {
inFile.close();
#endif
#ifndef WIN32
//printf("hvmain width=%d, height=%d\n", width, height);
// OK, this is nuts... The canvas pointer comes through byte-swapped and shifted 4 bits!
int canvas; char *w = (char *)&window, *c = (char *)&canvas; int *ic = (int *)&canvas;
c[0] = w[3]; c[3] = w[0]; c[1] = w[2]; c[2] = w[1]; *ic = (*ic >> 4) & 0xfffffff;
glcanvas = (wxGLCanvas *)canvas;
//printf("hvmain window=0x%x, canvas=0x%x, width=%d, height=%d\n", window, canvas, width, height);
hv->setFrameEndCallback(frameEndCB);
hv->afterRealize();
#else
//printf("hvmain ctx=0x%x, width=%d, height=%d\n", width, height);
......@@ -262,7 +279,9 @@ HypView *hvmain(int argc, char *argv[], int window, int width, int height) {
#endif
}
void hvKill(HypView * /*hv*/) {
delete hv.get();
}
int hvReadFile(char *fname, int width, int height) {
ifstream inFile(fname);
......
......@@ -22,6 +22,7 @@
import string
import sys
import types
import os
import hv
# Constants from HypData.h
......@@ -110,7 +111,6 @@ class hvApp(wxApp):
exptError = '%s %s\n%s' % tuple(filename[1:4])
print exptError
self.frame.shutdown()
pass
else:
if not self.frame.ReadTopFile("wxHyperViewer", filename):
#print "Could not open ", filename # Already printed error in C++.
......@@ -156,7 +156,9 @@ class hvFrame(hvFrameUI):
EVT_CHAR(self.CountGenNode, self.OnCountGenNode_CHAR)
EVT_SPINCTRL(self.CountGenLink, -1, self.OnCountGenLink)
EVT_CHAR(self.CountGenLink, self.OnCountGenLink_CHAR)
EVT_SCROLL_ENDSCROLL(self.AnimStepCount, self.OnAnimStepCount) # Windows
EVT_SLIDER(self.AnimStepCount, -1, self.OnAnimStepCount) # GTK
# Other events.
EVT_CLOSE(self, self.OnExit)
# These do nothing until the vwr is instantiated below.
......@@ -185,26 +187,32 @@ class hvFrame(hvFrameUI):
self.hypView.SetCurrent()
# Get window info from the wxWindow base class of the wxGLCanvas object.
# GetHandler returns the platform-specific handle of the physical window:
# HWND for Windows, Widget for Motif or GtkWidget for GTK.
window = self.hypView.GetHandle()
if os.name == 'nt':
# GetHandler returns the platform-specific handle of the physical window:
# HWND for Windows, Widget for Motif or GtkWidget for GTK.
window = self.hypView.GetHandle()
else:
# The wxGLCanvas has the graphics context and does the SwapBuffers for us on GTK.
window = self.hypView.this
pass
##print "self.hypView", self.hypView, "window", window
# GetSizeTuple is the wxPython version of GetSize. Returns size of the
# entire window in pixels, including title bar, border, scrollbars, etc.
width, height = self.hypView.GetSizeTuple()
# Instantiate and initialize the SWIG'ed C++ HypView object, loading graph data.
if self.vwr is not None:
# Give up on hvReadFile; the cleanup logic is busted. Always make a new HypView.
### Give up on hvReadFile; the cleanup logic is busted. Always make a new HypView.
##print "hvkill", self.vwr
hv.hvkill(self.vwr)
##hv.hvKill(self.vwr) ## And don't even clean up the old one.
# This is *really* evil... It fails every other time, so do it twice.
self.vwr = hv.hvmain([str(name), str(file)], # Must be non-unicode strings.
# This is *really* evil... It still fails every other time, so do it twice. :-(
self.vwr = hv.hvMain([str(name), str(file)], # Must be non-unicode strings.
window, width, height) # Win32 needs the window info.
hv.hvkill(self.vwr)
##hv.hvKill(self.vwr)
self.vwr = None
self.vwr = hv.hvmain([str(name), str(file)], # Must be non-unicode strings.
self.vwr = hv.hvMain([str(name), str(file)], # Must be non-unicode strings.
window, width, height) # Win32 needs the window info.
if self.vwr is None: # Must have been a problem....
return False
......@@ -214,7 +222,7 @@ class hvFrame(hvFrameUI):
self.DrawGL() # Show the graph.
# Don't connect up the mouse events before the HyperView data is loaded!
EVT_LEFT_DOWN(self.hypView, self.OnClick)
EVT_LEFT_DOWN(self.hypView, self.OnClick)
EVT_LEFT_UP(self.hypView, self.OnClick)
EVT_MIDDLE_DOWN(self.hypView, self.OnClick)
EVT_MIDDLE_UP(self.hypView, self.OnClick)
......@@ -390,7 +398,20 @@ class hvFrame(hvFrameUI):
key = keyEvent.GetKeyCode()
if ord('0') <= key <= ord('9') or key in (WXK_BACK, WXK_TAB) or key >= WXK_DELETE:
keyEvent.Skip() # Skip actually means to process the event...
pass
pass
##
# Handle changes in the number of steps per second in animated moves.
def OnAnimStepCount(self, scrollEvent):
if self.vwr is None:
return
# Convert from steps/second to fraction-of-a-second-per-step.
stepsPerSec = self.AnimStepCount.GetValue()
self.vwr.setGotoStepSize(1.0 / stepsPerSec)
##print "OnAnimStepCount", stepsPerSec, self.vwr.getGotoStepSize()
pass
##
# Menu items issue commands from the menu bar.
def OnExit(self, cmdEvent):
......@@ -410,7 +431,6 @@ class hvFrame(hvFrameUI):
if mouseEvent.LeftDown():
btnNum = 0
btnState = 0
pass
elif mouseEvent.LeftUp():
btnNum = 0
btnState = 1
......@@ -420,7 +440,6 @@ class hvFrame(hvFrameUI):
elif mouseEvent.MiddleDown():
btnNum = 1
btnState = 0
pass
elif mouseEvent.MiddleUp():
btnNum = 1
btnState = 1
......@@ -449,7 +468,6 @@ class hvFrame(hvFrameUI):
# Hyperviewer calls motion when a mouse button is clicked "active"
if mouseEvent.LeftIsDown() or mouseEvent.MiddleIsDown():
self.vwr.motion(mouseEvent.GetX(), mouseEvent.GetY(), 0, 0)
pass
else:
# "passive" mouse motion is when there is no button clicked.
##print "passive", mouseEvent.GetX(), mouseEvent.GetY()
......@@ -515,6 +533,7 @@ class hvOpen(OpenDialogUI):
else:
fileError = "Could not open " + file
self.FileMsg.SetLabel(fileError)
pass
pass
##
......@@ -528,6 +547,7 @@ class hvOpen(OpenDialogUI):
msg = "Enter a project name and experiment."
else:
msg = 'Getting experiment %s/%s.' % (project, experiment)
pass
print msg
self.ExperimentMsg.SetLabel(msg)
self.Refresh()
......@@ -544,7 +564,6 @@ class hvOpen(OpenDialogUI):
elif self.app.frame.ReadTopFile("wxHyperViewer", hypfile):
self.Hide(); # Success.
self.ExperimentMsg.SetLabel(" ")
pass
else:
fileError = "Could not open " + hypfile
print fileError
......
......@@ -793,6 +793,10 @@ public:
// bindCallback() documentation for more details.
void setPickCallback(void (*fp)(const string &,int,int));
/// Set the highlight callback to a function pointer. Windowing system
// interface code may call this in HypViewer::FrameEnd().
void setFrameEndCallback(void (*fp)(int));
// GROUP: HypData
//
......
......@@ -159,6 +159,7 @@ public:
void newSphereColor();
void setPickCallback(void (*fp)(const string &,int,int));
void setHiliteCallback(void (*fp)(const string &,int,int));
void setFrameEndCallback(void (*fp)(int));
void setSelected(HypNode *n, bool on);
//--------------------------------------------------------------------------
......@@ -277,6 +278,7 @@ private:
void (*pickCallback)(const string &,int,int);
void (*hiliteCallback)(const string &,int,int);
void (*frameEndCallback)(int);
void frameBegin();
void frameContinue();
......
......@@ -808,6 +808,17 @@ void HypView::setHiliteCallback(void (*fp)(const string &,int,int))
return;
}
//----------------------------------------------------------------------------
// void HypView::setFrameEndCallback(void (*fp)(int))
//............................................................................
//
//----------------------------------------------------------------------------
void HypView::setFrameEndCallback(void (*fp)(int))
{
hypViewer->setFrameEndCallback(fp);
return;
}
//----------------------------------------------------------------------------
// void HypView::drawFrame()
//............................................................................
......
......@@ -1174,6 +1174,17 @@ void HypViewer::setHiliteCallback(void (*fp)(const string &,int,int))
return;
}
//----------------------------------------------------------------------------
// void HypViewer::setFrameEndCallback(void (*fp)(int))
//............................................................................
//
//----------------------------------------------------------------------------
void HypViewer::setFrameEndCallback(void (*fp)(int))
{
frameEndCallback = fp;
return;
}
//----------------------------------------------------------------------------
// void HypViewer::mouse(int btn, int state, int x, int y,
// int shift, int control)
......@@ -1981,6 +1992,9 @@ int HypViewer::flashLink(HypNode *fromnode, HypNode *tonode)
#ifndef PyHack
if (!pick && !idleframe)
glutSwapBuffers();
#else
// No need to drag all of wxGLCanvas in here. Call a simple function above.
(*frameEndCallback)(0);
#endif
return;
}
......
......@@ -701,16 +701,17 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
/* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_f_r_q_const__string_int_int__void swig_types[0]
#define SWIGTYPE_p_timeval swig_types[1]
#define SWIGTYPE_p_HypGraph swig_types[2]
#define SWIGTYPE_p_HypView swig_types[3]
#define SWIGTYPE_p_HWND swig_types[4]
#define SWIGTYPE_p_HGLRC swig_types[5]
#define SWIGTYPE_p_p_char swig_types[6]
#define SWIGTYPE_p_HDC swig_types[7]
#define SWIGTYPE_p_string swig_types[8]
#define SWIGTYPE_p_istream swig_types[9]
static swig_type_info *swig_types[11];
#define SWIGTYPE_p_f_int__void swig_types[1]
#define SWIGTYPE_p_timeval swig_types[2]
#define SWIGTYPE_p_HypGraph swig_types[3]
#define SWIGTYPE_p_HypView swig_types[4]
#define SWIGTYPE_p_HWND swig_types[5]
#define SWIGTYPE_p_HGLRC swig_types[6]
#define SWIGTYPE_p_p_char swig_types[7]
#define SWIGTYPE_p_HDC swig_types[8]
#define SWIGTYPE_p_string swig_types[9]
#define SWIGTYPE_p_istream swig_types[10]
static swig_type_info *swig_types[12];
/* -------- TYPES TABLE (END) -------- */
......@@ -742,8 +743,8 @@ NAMESPACEHACK
#include "HypView.h"
extern HypView *hvmain(int,char *[],int,int,int);
extern void hvkill(HypView *);
extern HypView *hvMain(int,char *[],int,int,int);
extern void hvKill(HypView *);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char *getGraphCenter();
......@@ -808,7 +809,7 @@ extern void selectCB(std::string const &,int,int);
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_hvmain(PyObject *self, PyObject *args) {
static PyObject *_wrap_hvMain(PyObject *self, PyObject *args) {
PyObject *resultobj;
int arg1 ;
char **arg2 ;
......@@ -818,7 +819,7 @@ static PyObject *_wrap_hvmain(PyObject *self, PyObject *args) {
HypView *result;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"Oiii:hvmain",&obj0,&arg3,&arg4,&arg5)) goto fail;