예제 #1
0
int
makeLightingPanel(void)
{

    int i;
    XSetWindowAttributes cwAttrib, controlAttrib;
    XSizeHints sizehint;
    Pixmap lightbits,lightmask;
    XColor foreColor, backColor;

    lightbits = XCreateBitmapFromData(dsply,rtWindow, lightBitmap_bits,
                                      lightBitmap_width,lightBitmap_height);
    lightmask = XCreateBitmapFromData(dsply,rtWindow, lightMask_bits,
                                      lightMask_width,lightMask_height);
    cwAttrib.background_pixel = backgroundColor;
    cwAttrib.border_pixel = foregroundColor;
    cwAttrib.event_mask = lightMASK;
    cwAttrib.colormap = colorMap;
    cwAttrib.override_redirect = overrideManager;
    foreColor.pixel = lightCursorForeground;
    XQueryColor(dsply,colorMap,&foreColor);
    backColor.pixel = lightCursorBackground;
    XQueryColor(dsply,colorMap,&backColor);
    cwAttrib.cursor = XCreatePixmapCursor(dsply,lightbits,lightmask,
                                          &foreColor,&backColor,
                                          lightBitmap_x_hot,lightBitmap_y_hot);
    lightingWindow = XCreateWindow(dsply,control->controlWindow,
                                   -3,-3,controlWidth,controlHeight,3,
                                   CopyFromParent,InputOutput,CopyFromParent,
                                   controlCreateMASK,&cwAttrib);

    sizehint.flags  = USPosition | USSize;
    sizehint.x      = 0;
    sizehint.y      = 0;
    sizehint.width  = controlWidth;
    sizehint.height = controlHeight;
    /*** the None stands for icon pixmap. ***/
    XSetNormalHints(dsply,lightingWindow,&sizehint);
    XSetStandardProperties(dsply,lightingWindow,"Lighting Panel 3D",
                           "Lighting Panel",None,NULL,0,&sizehint);

    /*** lighting axes window ***/
    cwAttrib.event_mask = 0;
    lightingAxes = XCreateWindow(dsply,lightingWindow,
                                 lightingAxesX,lightingAxesY,
                                 lightingAxesSize,lightingAxesSize,
                                 0,CopyFromParent,InputOutput,CopyFromParent,
                                 controlCreateMASK,&cwAttrib);

    sizehint.flags  = USPosition | USSize;
    sizehint.x      = lightingAxesX;
    sizehint.y      = lightingAxesY;
    sizehint.width  = lightingAxesSize;
    sizehint.height = lightingAxesSize;
    /*** the None stands for icon pixmap ***/
    XSetNormalHints(dsply,lightingAxes,&sizehint);
    XSetStandardProperties(dsply,lightingAxes,"Lighting Axes","Lighting Axes",
                           None,NULL,0,&sizehint);
    XMapWindow(dsply,lightingAxes);

    /*** draw lighting buttons ***/
    initLightButtons(control->buttonQueue);
    /*
      controlAttrib.event_mask = (control->buttonQueue[lightingButtonsStart]).mask;
      (control->buttonQueue[lightingButtonsStart]).self =
                      XCreateWindow(dsply, lightingWindow,
                        (control->buttonQueue[lightingButtonsStart]).buttonX,
                        (control->buttonQueue[lightingButtonsStart]).buttonY,
                        (control->buttonQueue[lightingButtonsStart]).buttonWidth,
                        (control->buttonQueue[lightingButtonsStart]).buttonHeight,
                        0,0,InputOnly,CopyFromParent,
                        buttonCreateMASK,&controlAttrib);
      XMakeAssoc(dsply,table,(control->buttonQueue[lightingButtonsStart]).self,
                 &((control->buttonQueue[lightingButtonsStart]).buttonKey));
      XMapWindow(dsply,(control->buttonQueue[lightingButtonsStart]).self);
    */
    for (i=(lightingButtonsStart + 1); i<(lightingButtonsEnd); i++) {
        controlAttrib.event_mask = (control->buttonQueue[i]).mask;
        (control->buttonQueue[i]).self =
            XCreateWindow(dsply,lightingWindow,
                          (control->buttonQueue[i]).buttonX,
                          (control->buttonQueue[i]).buttonY,
                          (control->buttonQueue[i]).buttonWidth,
                          (control->buttonQueue[i]).buttonHeight,
                          0,0,InputOnly,CopyFromParent,
                          buttonCreateMASK,&controlAttrib);
        XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
                   &((control->buttonQueue[i]).buttonKey));
        XMapWindow(dsply,(control->buttonQueue[i]).self);
    }

    /* assign global direction variables for light projections */
    sinTheta  = sin(-viewport->theta);
    cosTheta  = cos(-viewport->theta);
    sinPhi    = sin(viewport->phi);
    cosPhi    = cos(viewport->phi);

    return(0);

}  /* makeLightingPanel() */
예제 #2
0
void
makeVolumePanel (void)
{

  int i;
  XSetWindowAttributes cwAttrib, controlAttrib;
  XSizeHints sizehint;
  Pixmap volumebits, volumemask;
  XColor foreColor, backColor;

  volumebits = XCreateBitmapFromData(dsply,rtWindow,volumeBitmap_bits,
                                     volumeBitmap_width,volumeBitmap_height);
  volumemask = XCreateBitmapFromData(dsply,rtWindow,volumeMask_bits,
                                     volumeMask_width,volumeMask_height);
  cwAttrib.background_pixel = backgroundColor;
  cwAttrib.border_pixel = foregroundColor;
  cwAttrib.event_mask = volumeMASK;
  cwAttrib.colormap = colorMap;
  cwAttrib.override_redirect = overrideManager;
  foreColor.pixel = volumeCursorForeground;
  XQueryColor(dsply,colorMap,&foreColor);
  backColor.pixel = volumeCursorBackground;
  XQueryColor(dsply,colorMap,&backColor);
  cwAttrib.cursor = XCreatePixmapCursor(dsply,volumebits,volumemask,
                                        &foreColor,&backColor,
                                        volumeBitmap_x_hot,
                                        volumeBitmap_y_hot);
  volumeWindow = XCreateWindow(dsply,control->controlWindow,
                               -3,-3,controlWidth,controlHeight,3,
                               CopyFromParent,InputOutput,CopyFromParent,
                               controlCreateMASK,&cwAttrib);

  sizehint.flags  = USPosition | USSize;
  sizehint.x      = 0;
  sizehint.y      = 0;
  sizehint.width  = controlWidth;
  sizehint.height = controlHeight;
          /*** the None stands for icon pixmap ***/
  XSetNormalHints(dsply,volumeWindow,&sizehint);
  XSetStandardProperties(dsply,volumeWindow,"Volume Panel 3D",
                         "View Volume",None,NULL,0,&sizehint);

      /*** volume frustrum window ***/

    /*** do volume buttons ***/
  initVolumeButtons(control->buttonQueue);
  for (i=volumeButtonsStart; i<(volumeButtonsEnd); i++) {
    controlAttrib.event_mask = (control->buttonQueue[i]).mask;
    (control->buttonQueue[i]).self =
                XCreateWindow(dsply,volumeWindow,
                              (control->buttonQueue[i]).buttonX,
                              (control->buttonQueue[i]).buttonY,
                              (control->buttonQueue[i]).buttonWidth,
                              (control->buttonQueue[i]).buttonHeight,
                              0,0,InputOnly,CopyFromParent,
                              buttonCreateMASK,&controlAttrib);
    XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
               &((control->buttonQueue[i]).buttonKey));
    XMapWindow(dsply,(control->buttonQueue[i]).self);
  }

}  /* makeVolumePanel() */
예제 #3
0
int
makeSavePanel(void)
{

  int i;
  XSetWindowAttributes saver,SaverAttrib;
  XSizeHints sizeh;
  Pixmap savebits, savemask;
  XColor saveColor,sColor;

  savebits = XCreateBitmapFromData(dsply,rtWindow,
                                   (const char*) volumeBitmap_bits,
                                   volumeBitmap_width,volumeBitmap_height);
  savemask = XCreateBitmapFromData(dsply,rtWindow,
                                   (const char*) volumeMask_bits,
                                   volumeMask_width,volumeMask_height);
  saver.background_pixel = backgroundColor;
  saver.border_pixel = foregroundColor;
  saver.event_mask = saveMASK;
  saver.colormap = colorMap;
  saver.override_redirect = overrideManager;
  saveColor.pixel = saveCursorForeground;
  XQueryColor(dsply,colorMap,&saveColor);
  sColor.pixel = saveCursorBackground;
  XQueryColor(dsply,colorMap,&sColor);
  saver.cursor = XCreatePixmapCursor(dsply,savebits,savemask,
                                     &saveColor,&sColor,
                                     volumeBitmap_x_hot,volumeBitmap_y_hot);

  saveWindow = XCreateWindow(dsply,control->controlWindow,
                             controlWidth-saveWidth-2, controlHeight-saveHeight-2,
                             saveWidth-2,saveHeight-2,2,
                             CopyFromParent,InputOutput,CopyFromParent,
                             controlCreateMASK,&saver);

  sizeh.flags  = USPosition | USSize;
  sizeh.x      = 0;
  sizeh.y      = 0;
  sizeh.width  = saveWidth-2;
  sizeh.height = saveHeight-2;

  XSetNormalHints(dsply,saveWindow,&sizeh);
  XSetStandardProperties(dsply,saveWindow,"Save Panel","Save Panel",
                         None,NULL,0,&sizeh);

  /*** Create save buttons ***/
  initSaveButtons(control->buttonQueue);
  for (i=saveButtonsStart; i<(saveButtonsEnd); i++) {
    SaverAttrib.event_mask = (control->buttonQueue[i]).mask;
    (control->buttonQueue[i]).self =
                XCreateWindow(dsply,saveWindow,
                              (control->buttonQueue[i]).buttonX,
                              (control->buttonQueue[i]).buttonY,
                              (control->buttonQueue[i]).buttonWidth,
                              (control->buttonQueue[i]).buttonHeight,
                              0,0,InputOnly,CopyFromParent,
                              buttonCreateMASK,&SaverAttrib);
    XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
               &((control->buttonQueue[i]).buttonKey));
    XMapWindow(dsply,(control->buttonQueue[i]).self);
  }

  return(0);

}  /* makeSavePanel() */
예제 #4
0
controlPanelStruct *
makeControlPanel(void)
{

  Window cw;
  int                  i,num;
  controlPanelStruct   *control;
  buttonStruct         *buttons;
  controlXY            cXY;
  XSetWindowAttributes cwAttrib, controlAttrib;
  XSizeHints           sizehints;
  Pixmap               mousebits,mousemask;
  XColor               foreColor, backColor;

  if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) {
    fprintf(stderr,"Ran out of memory trying to create a control panel.\n");
    exitWithAck(RootWindow(dsply,scrn),Window,-1);
  }

  cXY = getControlXY(0);

  /* Define and assign a mouse cursor. */
  mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits,
                                    mouseBitmap_width,mouseBitmap_height);
  mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits,
                                    mouseMask_width,mouseMask_height);
  cwAttrib.background_pixel = backgroundColor; /* controlBackground; */
  cwAttrib.border_pixel = foregroundColor;
  cwAttrib.backing_store = WhenMapped;
  cwAttrib.event_mask = controlMASK;
  cwAttrib.colormap = colorMap;
  cwAttrib.override_redirect = overrideManager;
  foreColor.pixel = controlCursorForeground;
  XQueryColor(dsply,colorMap,&foreColor);
  backColor.pixel = controlCursorBackground;
  XQueryColor(dsply,colorMap,&backColor);
  cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask,
                                        &foreColor,&backColor,
                                        mouseBitmap_x_hot,mouseBitmap_y_hot);

  cw = XCreateWindow(dsply,rtWindow,
                     cXY.putX,cXY.putY,controlWidth,controlHeight,3,
                     CopyFromParent,InputOutput,CopyFromParent,
                     controlCreateMASK,&cwAttrib);

  sizehints.flags  = PPosition | PSize;
  sizehints.x      = cXY.putX;
  sizehints.y      = cXY.putY;
  sizehints.width  = controlWidth;
  sizehints.height = controlHeight;

  /*** the None stands for icon pixmap...change.... ***/

  XSetNormalHints(dsply,cw,&sizehints);
  XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel",
                         None,NULL,0,&sizehints);

  control->controlWindow = cw;
  num = initButtons(control->buttonQueue);
  control->numOfButtons = num;
  buttons = control->buttonQueue;

  for (i=0; i<num; i++) {
    controlAttrib.event_mask = (control->buttonQueue[i]).mask;
    (control->buttonQueue[i]).self = XCreateWindow(dsply,cw,
                                       (control->buttonQueue[i]).buttonX,
                                       (control->buttonQueue[i]).buttonY,
                                       (control->buttonQueue[i]).buttonWidth,
                                       (control->buttonQueue[i]).buttonHeight,
                                       0,0,InputOnly,CopyFromParent,
                                       buttonCreateMASK,&controlAttrib);

    XMakeAssoc(dsply,table,(control->buttonQueue[i]).self,
               &((control->buttonQueue[i]).buttonKey));
   /* Use buttonKey instead of i because buttonKey has a permanent address */
    XMapWindow(dsply,(control->buttonQueue[i]).self);
  }

           /* Create message window */
  control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY,
                                         controlWidth,controlMessageHeight,
                                         0,0,InputOnly,CopyFromParent,
                                         messageCreateMASK,&cwAttrib);
  XMapWindow(dsply,control->messageWindow);

  for (i=0; i<scaleArrowN; i++) {
    scaleArrow[i].x += buttons[scale2D].buttonX;
    scaleArrow[i].y += buttons[scale2D].buttonY;
  }
  for (i=0; i<translateArrowN; i++) {
    translateArrow[i].x += buttons[translate2D].buttonX;
    translateArrow[i].y += buttons[translate2D].buttonY;
  }

  viewport->justMadeControl = yes;
  return(control);

} /* makeControlPanel() */