Function:xs2spp

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:53, 6 January 2009
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 1: Line 1:
==xs2spp== ==xs2spp==
 +Set panel frame properties.
==Prototype== ==Prototype==
<code><pre> <code><pre>
 +void xs2spp(COLOUR active, COLOUR inactive, float width);
</pre></code> </pre></code>
==Description== ==Description==
 +Set panel frame properties.
 +
 +==See Also==
 +<table>
 +<tr><td>[[Function:xs2ap | xs2ap]]</td><td>Add a new panel</td><td> </td></tr>
 +<tr><td>[[Function:xs2mp | xs2mp]]</td><td>Modify location of existing panel.</td><td> </td></tr>
 +<tr><td>[[Function:xs2cp | xs2cp]]</td><td>Select a panel for subsequent geometry calls</td><td> </td></tr>
 +<tr><td>[[Function:xs2tp | xs2tp]]</td><td>Toggle visibility of panel</td><td> </td></tr>
 +<tr><td>[[Function:xs2lpc | xs2lpc]]</td><td>Link panel cameras together</td><td> </td></tr>
 +</table>
==Code Example== ==Code Example==
<code><pre> <code><pre>
-</pre></code>+#include <stdio.h>
 +#include <stdlib.h>
 +#include "s2plot.h"
-[[S2PLOT:Function List | Back]] to S2PLOT function list.+/* Global variales used in callback */
 +int master_panel = 0; /* Default ID of main panel */
 +int slave_panel; /* ID of newly created panel */
 +void cb(double *t, int *kc)
 +{
 + static int lkc = 0; /* Keep count of keypress state */
 + if (*kc == 1) {
 + xs2lpc(master_panel, slave_panel); /* Link panels together */
 + } else if ((*kc > 1) && (*kc != lkc)) {
 + xs2tp(slave_panel); /* Toggle panel visiblity */
 + }
 + lkc = *kc; /* Update count of keypress state */
 +}
-__NOTOC__ 
-__NOEDITSECTION__ 
 +int main(int argc, char *argv[])
 +{
 + s2opend("/s2mono", argc, argv); /* Open in mono mode */
 + s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
 + s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
-Back to [[Function:Template | template]] page.+ xs2mp(master_panel, 0.0, 0.5, 0.5, 1.0); /* Move to top left */
 + 
 + 
 + slave_panel = xs2ap(0.5, 0.0, 1.0, 0.5); /* Create panel in bottom right */
 + xs2cp(slave_panel); /* Choose this panel */
 + s2swin(-2.,2., -2.,2., -2.,2.); /* Set the window coordinates */
 + s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0); /* Draw coordinate box */
 + 
 + xs2cp(master_panel); /* Go back to main panel */
 + cs2scb(cb); /* Install dynamic callback */
 + 
 + COLOUR inactive = { 0.3, 0.2, 0.8 }; /* Inactive frame colour */
 + COLOUR active = { 0.1, 1.0, 0.1 }; /* Active frame colour */
 + float width = 2.0; /* Frame border width */
 + xs2spp(active, inactive, width); /* Set panel properties */
 + 
 + fprintf(stderr,"Press <tab> to switch between panels\n");
 + fprintf(stderr,"Press <spacebar> to link cameras together - cannot be undone\n");
 + fprintf(stderr,"Futher presses of <spacebar> toggle panel visiblity\n");
 + 
 + s2show(1); /* Open the s2plot window */
 + 
 + return 1;
 +}
 +</pre></code>
 + 
 +[[S2PLOT:Function List | Back]] to S2PLOT function list.
 + 
 +__NOTOC__
 +__NOEDITSECTION__

Current revision

xs2spp

Set panel frame properties.

Prototype

void xs2spp(COLOUR active, COLOUR inactive, float width);

Description

Set panel frame properties.

See Also

xs2apAdd a new panel
xs2mpModify location of existing panel.
xs2cpSelect a panel for subsequent geometry calls
xs2tpToggle visibility of panel
xs2lpcLink panel cameras together

Code Example

#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"

/* Global variales used in callback */
int master_panel = 0;                   /* Default ID of main panel */
int slave_panel;                        /* ID of newly created panel */

void cb(double *t, int *kc)
{
   static int lkc = 0;                  /* Keep count of keypress state */
   if (*kc == 1) {
      xs2lpc(master_panel, slave_panel);        /* Link panels together */
   } else if ((*kc > 1) && (*kc != lkc)) {
      xs2tp(slave_panel);               /* Toggle panel visiblity */
   }

   lkc = *kc;                           /* Update count of keypress state */
}


int main(int argc, char *argv[])
{
   s2opend("/s2mono", argc, argv);              /* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   xs2mp(master_panel, 0.0, 0.5, 0.5, 1.0);     /* Move to top left */


   slave_panel = xs2ap(0.5, 0.0, 1.0, 0.5);     /* Create panel in bottom right */
   xs2cp(slave_panel);                          /* Choose this panel */
   s2swin(-2.,2., -2.,2., -2.,2.);              /* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw coordinate box */

   xs2cp(master_panel);                         /* Go back to main panel */
   cs2scb(cb);                                  /* Install dynamic callback */

   COLOUR inactive = { 0.3, 0.2, 0.8 };         /* Inactive frame colour */
   COLOUR active   = { 0.1, 1.0, 0.1 };         /* Active frame colour */
   float width = 2.0;                           /* Frame border width */
   xs2spp(active, inactive, width);             /* Set panel properties */

   fprintf(stderr,"Press <tab> to switch between panels\n");
   fprintf(stderr,"Press <spacebar> to link cameras together - cannot be undone\n");
   fprintf(stderr,"Futher presses of <spacebar> toggle panel visiblity\n");

   s2show(1);                                   /* Open the s2plot window */

   return 1;
}

Back to S2PLOT function list.


Personal tools