Commit a493c38c authored by Russ Fish's avatar Russ Fish

Fix two things in the hypview GUI:

 . Allow typing in a node name, go to it when Enter is pressed.
 . Get node name after the GoToTop button is pressed.
parent 3d2bb7b2
......@@ -57,7 +57,7 @@ _hv.cpp hv.py win32/_hv.cpp win32/hv.py: hv.i
_hv.o: _hv.cpp
g++ -fpic -c ${CFLAGS} ${INCDIRS} _hv.cpp
_hv.so: hvmain.o _hv.o ${HVLIB}
gcc -shared hvmain.o _hv.o ${LDLIBS} -o _hv.so
gcc -g -shared hvmain.o _hv.o ${LDLIBS} -o _hv.so
hvlib: ${HVLIB}
${HVLIB}: checkhv
......
......@@ -742,6 +742,7 @@ NAMESPACEHACK
extern HypView *hvmain(int,char *[],int,int,int);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char *getGraphCenter();
#define SWIG_MemoryError 1
#define SWIG_IOError 2
......@@ -875,6 +876,20 @@ static PyObject *_wrap_getSelected(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_getGraphCenter(PyObject *self, PyObject *args) {
PyObject *resultobj;
char *result;
if(!PyArg_ParseTuple(args,(char *)":getGraphCenter")) goto fail;
result = (char *)getGraphCenter();
resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_new_HypView(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *result;
......@@ -1190,6 +1205,27 @@ static PyObject *_wrap_HypView_setGraphCenter(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_HypView_getGraphCenter(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
string result;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:HypView_getGraphCenter",&obj0)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_HypView,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
result = (arg1)->getGraphCenter();
{
string * resultptr;
resultptr = new string((string &) result);
resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_string, 1);
}
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_HypView_setGraph(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
......@@ -3159,6 +3195,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"hvmain", _wrap_hvmain, METH_VARARGS },
{ (char *)"hvReadFile", _wrap_hvReadFile, METH_VARARGS },
{ (char *)"getSelected", _wrap_getSelected, METH_VARARGS },
{ (char *)"getGraphCenter", _wrap_getGraphCenter, METH_VARARGS },
{ (char *)"new_HypView", _wrap_new_HypView, METH_VARARGS },
{ (char *)"HypView_afterRealize", _wrap_HypView_afterRealize, METH_VARARGS },
{ (char *)"delete_HypView", _wrap_delete_HypView, METH_VARARGS },
......@@ -3172,6 +3209,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"HypView_saveGraph", _wrap_HypView_saveGraph, METH_VARARGS },
{ (char *)"HypView_setCurrentCenter", _wrap_HypView_setCurrentCenter, METH_VARARGS },
{ (char *)"HypView_setGraphCenter", _wrap_HypView_setGraphCenter, METH_VARARGS },
{ (char *)"HypView_getGraphCenter", _wrap_HypView_getGraphCenter, METH_VARARGS },
{ (char *)"HypView_setGraph", _wrap_HypView_setGraph, METH_VARARGS },
{ (char *)"HypView_initGraph", _wrap_HypView_initGraph, METH_VARARGS },
{ (char *)"HypView_setDisableGroup", _wrap_HypView_setDisableGroup, METH_VARARGS },
......
......@@ -63,6 +63,9 @@ extern int hvReadFile(char *fname, int width, int height);
// Get the node id string last selected by the selectCB function.
extern char *getSelected();
// Get the node id string at the graph center.
extern char *getGraphCenter();
// std::string is used for INPUT args to HypView methods.
%include "std_string.i"
// How come %apply doesn't work for std::string? Workaround with sed instead.
......@@ -570,6 +573,10 @@ public:
// the gotoCenterNode() reset function.
void setGraphCenter(const std::string & INPUT);
/// Get the name of the root node of the tree, which may have been
// set by the gotoCenterNode() reset function.
string getGraphCenter();
/// Load a graph into the viewer. The string can either be a
// filename or the actual data: if the string length is < 256
// characters and a file by that name exists, assume it is a filename.
......
......@@ -63,6 +63,9 @@ extern int hvReadFile(char *fname, int width, int height);
// Get the node id string last selected by the selectCB function.
extern char *getSelected();
// Get the node id string at the graph center.
extern char *getGraphCenter();
// std::string is used for INPUT args to HypView methods.
%include "std_string.i"
// How come %apply doesn't work for std::string? Workaround with sed instead.
......
......@@ -36,6 +36,8 @@ hvmain = _hv.hvmain
hvReadFile = _hv.hvReadFile
getSelected = _hv.getSelected
getGraphCenter = _hv.getGraphCenter
class HypView(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, HypView, name, value)
......@@ -61,6 +63,7 @@ class HypView(_object):
def saveGraph(*args): return _hv.HypView_saveGraph(*args)
def setCurrentCenter(*args): return _hv.HypView_setCurrentCenter(*args)
def setGraphCenter(*args): return _hv.HypView_setGraphCenter(*args)
def getGraphCenter(*args): return _hv.HypView_getGraphCenter(*args)
def setGraph(*args): return _hv.HypView_setGraph(*args)
def initGraph(*args): return _hv.HypView_initGraph(*args)
def setDisableGroup(*args): return _hv.HypView_setDisableGroup(*args)
......
......@@ -138,7 +138,7 @@ class hvFrameUI(wxFrame):
self.hypView = hvGLCanvas(self.panel_1, -1)
self.GoToTop = wxButton(self.Controls, -1, "go to top")
self.LabelNodeName = wxStaticText(self.Controls, -1, "Node name:")
self.NodeName = wxTextCtrl(self.Controls, -1, "")
self.NodeName = wxTextCtrl(self.Controls, -1, "", style=wxTE_PROCESS_ENTER)
self.LabelChildCount = wxStaticText(self.Controls, -1, "Child count: ")
self.ChildCount = wxStaticText(self.Controls, -1, " 0")
self.LabelLinksIn = wxStaticText(self.Controls, -1, "Non-tree Links in: 0")
......
<?xml version="1.0"?>
<!-- generated by wxGlade 0.3.1 on Thu Jul 29 18:15:56 2004 -->
<!-- generated by wxGlade 0.3.1 on Fri Jul 30 09:08: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">
......@@ -96,6 +96,7 @@
<border>5</border>
<option>1</option>
<object class="wxTextCtrl" name="NodeName" base="EditTextCtrl">
<style>wxTE_PROCESS_ENTER</style>
</object>
</object>
</object>
......
......@@ -49,6 +49,12 @@ char *getSelected(){
return prevsel;
}
// I guess I don't know how to handle a "string" returned by the SWIG Python wrapper.
char *getGraphCenter(){
string * result = new string(hv->getGraphCenter());
return (char *)result->c_str();
}
void selectCB(const string & id, int shift, int control) {
//printf("selectCB id=%s, prevsel=%s\n", id.c_str(), prevsel);
hv->setSelected(id, 1);
......
......@@ -24,6 +24,9 @@ import sys
import types
import hv
# Constants from HypData.h
HV_ANIMATE = 0
import exptToHv
from hvFrameUI import *
from OpenGL.GL import *
......@@ -119,7 +122,9 @@ class hvFrame(hvFrameUI):
self.vwr = None # Load data under the File menu now.
# Control events. (HyperViewer events are connected after loading data.)
# (These EVT_ handler functions are defined in site-packages/wxPython/wx.py .)
# EVT_ handler-setting functions are defined in site-packages/wxPython/wx.py .
# See http://www.wxwindows.org/manuals/2.4.2/wx470.htm#eventhandlingoverview .
EVT_TEXT_ENTER(self.NodeName, -1, self.OnNodeName)
EVT_CHECKBOX(self.DrawSphere, -1, self.OnDrawSphere)
EVT_CHECKBOX(self.DrawNodes, -1, self.OnDrawNodes)
EVT_CHECKBOX(self.DrawLinks, -1, self.OnDrawLinks)
......@@ -167,12 +172,18 @@ class hvFrame(hvFrameUI):
# Select the OpenGL Graphics Context from the wxGLCanvas in the hvFrameUI.
self.hypView.SetCurrent()
# Instantiate and initialize the SWIG'ed C++ HypView object, loading graph data.
# 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()
# 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.
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:
if self.vwr is None: # Must have been a problem....
return False
# Initial drawing.
......@@ -222,6 +233,14 @@ class hvFrame(hvFrameUI):
##
# Event handling for the HyperViewer canvas.
# Go to a node when its name is typed and Enter is pressed.
def OnNodeName(self, cmdEvent):
if self.vwr is None:
return
node = self.NodeName.GetValue()
self.vwr.gotoNode(node, HV_ANIMATE)
self.vwr.setSelected(node, True)
self.SelectedNode(node)
# Check boxes control boolean state.
def OnDrawSphere(self, cmdEvent):
self.vwr.setSphere(self.DrawSphere.IsChecked())
......@@ -242,22 +261,42 @@ class hvFrame(hvFrameUI):
##
# Buttons issue commands.
def OnGoToTop(self, buttonEvent):
self.vwr.gotoCenterNode(0)
self.SelectedNode(hv.getSelected())
if self.vwr is None:
return
# Tell the HypView to reset.
self.vwr.gotoCenterNode(HV_ANIMATE)
# Unselect a previously picked node.
prevsel = hv.getSelected()
if prevsel != "":
self.vwr.setSelected(prevsel, 0);
# Update the node info and draw.
##ctr = self.vwr.getGraphCenter()
ctr = hv.getGraphCenter()
#print "center node", ctr
self.SelectedNode(ctr)
self.DrawGL()
pass
def OnShowLinksIn(self, buttonEvent):
self.vwr.setDrawBackTo(hv.getSelected(), 1, self.DescendLinksIn.IsChecked())
self.DrawGL()
pass
def OnHideLinksIn(self, buttonEvent):
self.vwr.setDrawBackTo(hv.getSelected(), 0, self.DescendLinksIn.IsChecked())
self.DrawGL()
pass
def OnShowLinksOut(self, buttonEvent):
self.vwr.setDrawBackFrom(hv.getSelected(), 1, self.DescendLinksOut.IsChecked())
self.DrawGL()
pass
def OnHideLinksOut(self, buttonEvent):
self.vwr.setDrawBackFrom(hv.getSelected(), 0, self.DescendLinksOut.IsChecked())
self.DrawGL()
pass
##
# Combo boxes select between alternatives.
def OnLabelsMode(self, cmdEvent):
......
......@@ -496,6 +496,10 @@ public:
// the gotoCenterNode() reset function.
void setGraphCenter(const string & id);
/// Get the name of the root node of the tree, which may have been
// set by the gotoCenterNode() reset function.
string getGraphCenter();
/// Load a graph into the viewer. The string can either be a
// filename or the actual data: if the string length is < 256
// characters and a file by that name exists, assume it is a filename.
......
......@@ -417,6 +417,23 @@ void HypView::setGraphCenter(const string & id)
return;
}
//----------------------------------------------------------------------------
// string HypView::getGraphCenter()
//............................................................................
//
//----------------------------------------------------------------------------
string HypView::getGraphCenter()
{
if (!hypGraph)
return string("");
HypNode *n = hypGraph->getNodeFromIndex(hypData->centerindex);
if (n)
return n->getId();
else
return string("");
}
//----------------------------------------------------------------------------
// string HypView::getCenter()
//............................................................................
......
......@@ -745,6 +745,7 @@ NAMESPACEHACK
extern HypView *hvmain(int,char *[],int,int,int);
extern int hvReadFile(char *,int,int);
extern char *getSelected();
extern char *getGraphCenter();
#define SWIG_MemoryError 1
#define SWIG_IOError 2
......@@ -878,6 +879,20 @@ static PyObject *_wrap_getSelected(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_getGraphCenter(PyObject *self, PyObject *args) {
PyObject *resultobj;
char *result;
if(!PyArg_ParseTuple(args,(char *)":getGraphCenter")) goto fail;
result = (char *)getGraphCenter();
resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_new_HypView(PyObject *self, PyObject *args) {
PyObject *resultobj;
HDC arg1 ;
......@@ -1231,6 +1246,27 @@ static PyObject *_wrap_HypView_setGraphCenter(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_HypView_getGraphCenter(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
string result;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:HypView_getGraphCenter",&obj0)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_HypView,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
result = (arg1)->getGraphCenter();
{
string * resultptr;
resultptr = new string((string &) result);
resultobj = SWIG_NewPointerObj((void *) resultptr, SWIGTYPE_p_string, 1);
}
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_HypView_setGraph(PyObject *self, PyObject *args) {
PyObject *resultobj;
HypView *arg1 = (HypView *) 0 ;
......@@ -3218,6 +3254,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"hvmain", _wrap_hvmain, METH_VARARGS },
{ (char *)"hvReadFile", _wrap_hvReadFile, METH_VARARGS },
{ (char *)"getSelected", _wrap_getSelected, METH_VARARGS },
{ (char *)"getGraphCenter", _wrap_getGraphCenter, METH_VARARGS },
{ (char *)"new_HypView", _wrap_new_HypView, METH_VARARGS },
{ (char *)"HypView_afterRealize", _wrap_HypView_afterRealize, METH_VARARGS },
{ (char *)"HypView_getWidget", _wrap_HypView_getWidget, METH_VARARGS },
......@@ -3232,6 +3269,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"HypView_saveGraph", _wrap_HypView_saveGraph, METH_VARARGS },
{ (char *)"HypView_setCurrentCenter", _wrap_HypView_setCurrentCenter, METH_VARARGS },
{ (char *)"HypView_setGraphCenter", _wrap_HypView_setGraphCenter, METH_VARARGS },
{ (char *)"HypView_getGraphCenter", _wrap_HypView_getGraphCenter, METH_VARARGS },
{ (char *)"HypView_setGraph", _wrap_HypView_setGraph, METH_VARARGS },
{ (char *)"HypView_initGraph", _wrap_HypView_initGraph, METH_VARARGS },
{ (char *)"HypView_setDisableGroup", _wrap_HypView_setDisableGroup, METH_VARARGS },
......
......@@ -61,6 +61,7 @@ class HypView(_object):
def saveGraph(*args): return _hv.HypView_saveGraph(*args)
def setCurrentCenter(*args): return _hv.HypView_setCurrentCenter(*args)
def setGraphCenter(*args): return _hv.HypView_setGraphCenter(*args)
def getGraphCenter(*args): return _hv.HypView_getGraphCenter(*args)
def setGraph(*args): return _hv.HypView_setGraph(*args)
def initGraph(*args): return _hv.HypView_initGraph(*args)
def setDisableGroup(*args): return _hv.HypView_setDisableGroup(*args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment