Commit f0af4526 authored by David Llewellyn-Jones's avatar David Llewellyn-Jones

Converted to single-window (workbench-style) UI from multple window (toolbox-based) UI.

parent 37810427
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,6 +49,7 @@ typedef enum {
FILESAVETAG_EXPORTTIMESTART,
FILESAVETAG_EXPORTTIMEEND,
FILESAVETAG_EXPORTFRAMES,
FILESAVETAG_USESHADERS,
FILESAVETAG_RADIUS,
FILESAVETAG_ROTATION,
......@@ -58,6 +59,7 @@ typedef enum {
FILESAVETAG_WIDTH,
FILESAVETAG_COORD,
FILESAVETAG_NAME,
FILESAVETAG_EQUATION,
FILESAVETAG_RED,
FILESAVETAG_GREEN,
......@@ -182,11 +184,11 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
// System info
fprintf(fhFile, "\t<settings>\n");
boValue = GetDrawAxes (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<show-axes bool=\"%d\"/>\n", boValue);
fprintf (fhFile, "\t\t<show-axes bool=\"%d\"/>\n", boValue);
boValue = GetClearWhite (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<invert bool=\"%d\"/>\n", boValue);
fprintf (fhFile, "\t\t<invert bool=\"%d\"/>\n", boValue);
boValue = GetWireframe (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<wireframe bool=\"%d\"/>\n", boValue);
fprintf (fhFile, "\t\t<wireframe bool=\"%d\"/>\n", boValue);
if (boConfigure) {
boValue = GetSpin (psFunctyData->psVisData);
......@@ -195,17 +197,20 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
fprintf(fhFile, "\t\t<fullscreen bool=\"%d\"/>\n", boValue);
GetView (& fRadius, & fRotation, & fElevation, psFunctyData->psVisData);
fprintf(fhFile, "\t\t<radius double=\"%f\"/>\n", fRadius);
fprintf(fhFile, "\t\t<rotation double=\"%f\"/>\n", fRotation);
fprintf(fhFile, "\t\t<elevation double=\"%f\"/>\n", fElevation);
fprintf(fhFile, "\t\t<exportbinary bool=\"%d\"/>\n", psFunctyData->boBinary);
fprintf(fhFile, "\t\t<exportmultiplier double=\"%f\"/>\n", psFunctyData->fExportMultiplier);
fprintf(fhFile, "\t\t<exportscale double=\"%f\"/>\n", psFunctyData->fExportScale);
fprintf(fhFile, "\t\t<exportscreen bool=\"%d\"/>\n", psFunctyData->boExportScreen);
fprintf(fhFile, "\t\t<exportalpha bool=\"%d\"/>\n", psFunctyData->boExportAlpha);
fprintf(fhFile, "\t\t<exporttimestart double=\"%f\"/>\n", psFunctyData->fExportTimeStart);
fprintf(fhFile, "\t\t<exporttimeend double=\"%f\"/>\n", psFunctyData->fExportTimeEnd);
fprintf(fhFile, "\t\t<exportframes int=\"%d\"/>\n", psFunctyData->nExportFrames);
fprintf (fhFile, "\t\t<radius double=\"%f\"/>\n", fRadius);
fprintf (fhFile, "\t\t<rotation double=\"%f\"/>\n", fRotation);
fprintf (fhFile, "\t\t<elevation double=\"%f\"/>\n", fElevation);
fprintf (fhFile, "\t\t<exportbinary bool=\"%d\"/>\n", psFunctyData->boBinary);
fprintf (fhFile, "\t\t<exportmultiplier double=\"%f\"/>\n", psFunctyData->fExportMultiplier);
fprintf (fhFile, "\t\t<exportscale double=\"%f\"/>\n", psFunctyData->fExportScale);
fprintf (fhFile, "\t\t<exportscreen bool=\"%d\"/>\n", psFunctyData->boExportScreen);
fprintf (fhFile, "\t\t<exportalpha bool=\"%d\"/>\n", psFunctyData->boExportAlpha);
fprintf (fhFile, "\t\t<exporttimestart double=\"%f\"/>\n", psFunctyData->fExportTimeStart);
fprintf (fhFile, "\t\t<exporttimeend double=\"%f\"/>\n", psFunctyData->fExportTimeEnd);
fprintf (fhFile, "\t\t<exportframes int=\"%d\"/>\n", psFunctyData->nExportFrames);
boValue = GetShadersActive (psFunctyData->psVisData);
fprintf (fhFile, "\t\t<useshaders bool=\"%d\"/>\n", boValue);
}
fprintf(fhFile, "\t</settings>\n");
......@@ -213,13 +218,13 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
fprintf(fhFile, "\t<range>\n");
GetVisRange (afRange, psFunctyData->psVisData);
fprintf(fhFile, "\t\t<min>\n");
fprintf(fhFile, "\t\t\t<coord x=\"%f\" y=\"%f\" z=\"%f\"/>\n", afRange[0], afRange[1], afRange[2]);
fprintf(fhFile, "\t\t</min>\n");
fprintf(fhFile, "\t\t<width>\n");
fprintf(fhFile, "\t\t\t<coord x=\"%f\" y=\"%f\" z=\"%f\"/>\n", afRange[3], afRange[4], afRange[5]);
fprintf(fhFile, "\t\t</width>\n");
fprintf(fhFile, "\t</range>\n");
fprintf (fhFile, "\t\t<min>\n");
fprintf (fhFile, "\t\t\t<coord x=\"%f\" y=\"%f\" z=\"%f\"/>\n", afRange[0], afRange[1], afRange[2]);
fprintf (fhFile, "\t\t</min>\n");
fprintf (fhFile, "\t\t<width>\n");
fprintf (fhFile, "\t\t\t<coord x=\"%f\" y=\"%f\" z=\"%f\"/>\n", afRange[3], afRange[4], afRange[5]);
fprintf (fhFile, "\t\t</width>\n");
fprintf (fhFile, "\t</range>\n");
// Control variables
psFnControlData = GetControlVarList (psFunctyData->psVisData);
......@@ -237,7 +242,7 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
fprintf(fhFile, "%s", szEscaped);
g_free (szEscaped);
fprintf(fhFile, "\t</controlvar>\n");
fprintf (fhFile, "\t</controlvar>\n");
psControlvarList = g_slist_next (psControlvarList);
}
......@@ -262,6 +267,11 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
break;
}
szValue = GetFunctionName ((FuncPersist *)(psFuncList->data));
szEscaped = g_markup_printf_escaped ("\t\t<name>%s</name>\n", szValue);
fprintf(fhFile, "%s", szEscaped);
g_free (szEscaped);
szValue = GetFunctionString ((FuncPersist *)(psFuncList->data));
szEscaped = g_markup_printf_escaped ("\t\t<equation>%s</equation>\n", szValue);
fprintf(fhFile, "%s", szEscaped);
......@@ -483,6 +493,9 @@ void StartElementFuncty (GMarkupParseContext * psContext, gchar const * szElemen
else if (strcmp (szElementName, "fullscreen") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_FULLSCREEN;
}
else if (strcmp (szElementName, "useshaders") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_USESHADERS;
}
else if (strcmp (szElementName, "radius") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_RADIUS;
}
......@@ -513,6 +526,9 @@ void StartElementFuncty (GMarkupParseContext * psContext, gchar const * szElemen
else if (strcmp (szElementName, "exportframes") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_EXPORTFRAMES;
}
else if (strcmp (szElementName, "name") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_NAME;
}
else if (strcmp (szElementName, "equation") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_EQUATION;
}
......@@ -604,12 +620,15 @@ void StartElementFuncty (GMarkupParseContext * psContext, gchar const * szElemen
void EndElementFuncty (GMarkupParseContext * psContext, gchar const * szElementName, gpointer psData, GError * * ppsError) {
FilesavePersist * psFilesaveData = (FilesavePersist *)psData;
bool boShaderActive;
if ((psFilesaveData->nLevel >= 0) && (psFilesaveData->nLevel < MAX_LEVELS)) {
switch (psFilesaveData->eTag[0]) {
case FILESAVETAG_FUNCTION:
if (psFilesaveData->nLevel == 0) {
TransferFunctionRange (psFilesaveData->psFuncData, psFilesaveData->psFunctyData->psVisData);
boShaderActive = GetShadersActive (psFilesaveData->psFunctyData->psVisData);
SetFunctionShaderActive (boShaderActive, psFilesaveData->psFuncData);
FunctionShadersRegenerate (psFilesaveData->psFuncData);
}
if (psFilesaveData->nLevel == 1) {
......@@ -697,6 +716,11 @@ void StartElementSettings (FILESAVETAG eTag, gchar const * * aszAttributeNames,
SetFullScreenWindow (boValue, psFilesaveData->psFunctyData);
}
break;
case FILESAVETAG_USESHADERS:
if (psFilesaveData->boConfigure) {
SetShadersActive (boValue, psFilesaveData->psFunctyData->psVisData);
}
break;
case FILESAVETAG_EXPORTBINARY:
if (psFilesaveData->boConfigure) {
SetExportBinary (boValue, psFilesaveData->psFunctyData);
......@@ -920,6 +944,9 @@ void EndElementFunction (FILESAVETAG eTag, FilesavePersist * psFilesaveData) {
if (psFilesaveData->psFuncData) {
switch (eTag) {
case FILESAVETAG_NAME:
SetFunctionName (psFilesaveData->szText->str, psFilesaveData->psFuncData);
break;
case FILESAVETAG_EQUATION:
SetFunction (psFilesaveData->szText->str, psFilesaveData->psFuncData);
break;
......
......@@ -98,6 +98,7 @@ FuncPersist * NewFuncPersist (FUNCTYPE eType) {
psFuncData->szTexXOffset = g_string_new ("0.0");
psFuncData->szTexYOffset = g_string_new ("0.0");
psFuncData->szName = g_string_new ("");
psFuncData->szFunction = g_string_new ("");
psFuncData->szRed = g_string_new ("1.0");
psFuncData->szGreen = g_string_new ("0.5");
......@@ -169,6 +170,9 @@ void DeleteFuncPersist (FuncPersist * psFuncData) {
psFuncData->psVariables = FreeVariables (psFuncData->psVariables);
// Free up the handy UI-related data
if (psFuncData->szName) {
g_string_free (psFuncData->szName, TRUE);
}
if (psFuncData->szFunction) {
g_string_free (psFuncData->szFunction, TRUE);
}
......@@ -410,6 +414,11 @@ void SetFunction (char const * const szFunction, FuncPersist * psFuncData) {
AddUndefinedControlVars (psFuncData->psVariables, psFuncData->psFnControlData);
}
void SetFunctionName (char const * const szName, FuncPersist * psFuncData) {
// Set up the handy UI-related data
g_string_assign (psFuncData->szName, szName);
}
void SetFunctionColours (char const * const szRed, char const * const szGreen, char const * const szBlue, char const * const szAlpha, FuncPersist * psFuncData) {
switch (psFuncData->eType) {
case FUNCTYPE_CARTESIAN:
......@@ -479,7 +488,6 @@ void FunctionShadersRegenerate (FuncPersist * psFuncData) {
g_free (szShader);
szShader = NULL;
}
printf ("Shaders regenerated.\n");
}
if (psFuncData->psShaderShadowData) {
......@@ -528,10 +536,13 @@ void FunctionShadersRegenerate (FuncPersist * psFuncData) {
g_free (szShader);
szShader = NULL;
}
printf ("Shadow shaders regenerated.\n");
}
}
char const * GetFunctionName (FuncPersist * psFuncData) {
return psFuncData->szName->str;
}
char const * GetFunctionString (FuncPersist * psFuncData) {
return psFuncData->szFunction->str;
}
......
......@@ -50,7 +50,9 @@ void DeleteFuncPersist (FuncPersist * psFuncData);
FUNCTYPE GetFunctionType (FuncPersist * psFuncData);
void SetFunction (char const * const szFunction, FuncPersist * psFuncData);
void SetFunctionName (char const * const szName, FuncPersist * psFuncData);
void SetFunctionColours (char const * const szRed, char const * const szGreen, char const * const szBlue, char const * const szAlpha, FuncPersist * psFuncData);
char const * GetFunctionName (FuncPersist * psFuncData);
char const * GetFunctionString (FuncPersist * psFuncData);
char const * GetRedString (FuncPersist * psFuncData);
char const * GetGreenString (FuncPersist * psFuncData);
......
......@@ -73,6 +73,7 @@ struct _FuncPersist {
GString * szTexYOffset;
// Handy data to help with the UI
GString * szName;
GString * szFunction;
GString * szRed;
GString * szGreen;
......
This diff is collapsed.
......@@ -200,6 +200,7 @@ bool Intersect (float fX0, float fY0, float fX1, float fY1, float fA0, float fB0
void inline swap (float * pfVar1, float * pfVar2);
void inline order (float * pfVar1, float * pfVar2);
void DrawAxes (VisPersist * psVisData);
void DrawAxesNumbers (VisPersist * psVisData);
void DrawGraphs (VisPersist * psVisData);
void DrawGraphsShadow (VisPersist * psVisData);
GLfloat SelectFunction (int nXPos, int nYPos, VisPersist * psVisData);
......@@ -217,7 +218,7 @@ void AnimateFunction (VisPersist * psVisData);
void SetFunctionPositionCallback (gpointer data, gpointer user_data);
void CalculateGridScale (VisPersist * psVisData);
//void InitShaders (VisPersist * psVisData);
void ToggleShader (VisPersist * psVisData);
void ToggleShaders (VisPersist * psVisData);
void AssignControlVarsCallback (gpointer data, gpointer user_data);
void FramebufferCreate (VisPersist * psVisData);
GLenum CheckFramebufferStatus ();
......@@ -975,7 +976,6 @@ void DrawAxes (VisPersist * psVisData) {
//int nXSize;
//int nYSize;
//int nZSize;
int nOctant;
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
......@@ -997,6 +997,16 @@ void DrawAxes (VisPersist * psVisData) {
DrawWallY (AXIS_YHSIZE, GL_CCW, -1.0f, psVisData);
DrawWallY (-AXIS_YHSIZE, GL_CW, 1.0f, psVisData);
glMaterialfv (GL_FRONT, GL_SPECULAR, gBoardSpecular);
glMaterialfv (GL_FRONT, GL_SHININESS, gBoardShininess);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gGridColour);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
}
void DrawAxesNumbers (VisPersist * psVisData) {
int nOctant;
// Draw the numbers
if (psVisData->boClearWhite) {
glColor3f (NUMBERTEXT_COLINV);
......@@ -1041,11 +1051,6 @@ void DrawAxes (VisPersist * psVisData) {
}
glEnable (GL_DEPTH_TEST);
glMaterialfv (GL_FRONT, GL_SPECULAR, gBoardSpecular);
glMaterialfv (GL_FRONT, GL_SHININESS, gBoardShininess);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gGridColour);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
}
void DrawFloor (VisPersist * psVisData) {
......@@ -1720,16 +1725,20 @@ void Reshape (int nWidth, int nHeight, VisPersist * psVisData) {
}
void Redraw (VisPersist * psVisData) {
// Render to the shadow buffer
RenderToShadowBuffer (psVisData);
if (psVisData->boShader) {
// Render to the shadow buffer
RenderToShadowBuffer (psVisData);
}
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
RenderShadow (psVisData);
glPopMatrix ();
// Render to the framebuffer
RenderToFrameBuffer (psVisData);
if (psVisData->boShader) {
// Render to the framebuffer
RenderToFrameBuffer (psVisData);
}
if (psVisData->boClearWhite) {
glClearColor (1.0f, 1.0f, 1.0f, 0.0f);
......@@ -1744,17 +1753,25 @@ void Redraw (VisPersist * psVisData) {
Render (psVisData);
DrawTextOverlay (psVisData);
glPopMatrix ();
// Finally render to the screenbuffer
RenderToScreenBuffer (psVisData);
if (psVisData->boShader) {
// Finally render to the screenbuffer
RenderToScreenBuffer (psVisData);
// Render the framebuffer to screen
RenderFramebufferToScreen (psVisData);
// Render the framebuffer to screen
RenderFramebufferToScreen (psVisData);
}
// Render the debug texture overlay to the screen
//RenderDebugOverlay (psVisData);
glLoadIdentity ();
gluLookAt ((psVisData->fViewRadius) * psVisData->vCamera.fX, (psVisData->fViewRadius) * psVisData->vCamera.fY, (psVisData->fViewRadius) * psVisData->vCamera.fZ, 0.0, 0.0, 0.0, psVisData->vUp.fX, psVisData->vUp.fY, psVisData->vUp.fZ);
DrawTextOverlay (psVisData);
if (psVisData->boDrawAxes) {
DrawAxesNumbers (psVisData);
}
glFlush ();
//glutSwapBuffers();
......@@ -1915,25 +1932,8 @@ void ToggleSpin (VisPersist * psVisData) {
psVisData->boSpin = !psVisData->boSpin;
}
void ToggleShader (VisPersist * psVisData) {
GSList * psFuncList;
psVisData->boShader = !psVisData->boShader;
// Cycle through all of the functions
psFuncList = psVisData->psFuncList;
while (psFuncList) {
SetFunctionShaderActive (psVisData->boShader, (FuncPersist *)(psFuncList->data));
psFuncList = g_slist_next (psFuncList);
}
if (psVisData->boShader) {
printf ("Shader: on\n");
}
else {
printf ("Shader: off\n");
}
void ToggleShaders (VisPersist * psVisData) {
SetShadersActive (!psVisData->boShader, psVisData);
}
void ToggleWireframe (VisPersist * psVisData) {
......@@ -1976,6 +1976,26 @@ bool GetWireframe (VisPersist * psVisData) {
return psVisData->boWireframe;
}
bool GetShadersActive (VisPersist * psVisData) {
return psVisData->boShader;
}
void SetShadersActive (bool boShaderActive, VisPersist * psVisData) {
GSList * psFuncList;
if (boShaderActive != psVisData->boShader) {
psVisData->boShader = boShaderActive;
// Cycle through all of the functions
psFuncList = psVisData->psFuncList;
while (psFuncList) {
SetFunctionShaderActive (psVisData->boShader, (FuncPersist *)(psFuncList->data));
psFuncList = g_slist_next (psFuncList);
}
}
}
void GetDisplayProperties (float * pfViewRadius, float * pfLinkLen, float * pfCentring, float * pfRigidity, float * pfForce, float * pfResistance, VisPersist * psVisData) {
if (pfViewRadius) {
* pfViewRadius = psVisData->fViewRadius;
......@@ -2000,7 +2020,6 @@ void Key (unsigned int key, int x, int y, unsigned int uKeyModifiers, VisPersist
//case '\r':
// if (uKeyModifiers & GLUT_ACTIVE_ALT) ToggleFullScreen (VisPersist * psVisData);
// break;
case GDK_Escape:
case 'q':
gtk_main_quit ();
break;
......@@ -2022,7 +2041,7 @@ void Key (unsigned int key, int x, int y, unsigned int uKeyModifiers, VisPersist
case 'm':
break;
case 's':
ToggleShader (psVisData);
ToggleShaders (psVisData);
break;
case ' ':
PauseAnimation ((!psVisData->boPaused), psVisData);
......
......@@ -87,6 +87,8 @@ void SetDrawAxes (bool boDrawAxes, VisPersist * psVisData);
bool GetDrawAxes (VisPersist * psVisData);
void SetWireframe (bool boWireframe, VisPersist * psVisData);
bool GetWireframe (VisPersist * psVisData);
void SetShadersActive (bool boShaderActive, VisPersist * psVisData);
bool GetShadersActive (VisPersist * psVisData);
void RenderBitmapString (float fX, float fY, void * pFont, char const * szString);
void RenderBitmapStringCursor (float fX, float fY, void * pFont, char const * szString, int nCursorPos);
void RenderCursor (float fX, float fY, void * pFont, char const * szString, int nCursorPos);
......
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