Re: Inconsistent colors in X11, ncgm, ctrans from LLU+HLU

From: Mary Haley (haley AT unknown)
Date: Wed Feb 26 2003 - 08:52:40 MST

  • Next message: Dr. John W. (Jack) Glendening: "Re: Inconsistent colors in X11, ncgm, ctrans from LLU+HLU"

    >
    > In a program which utilizes both LLU and HLU, I have found I do not
    > get a consistent color representation from: (1) X11, (2) an ncgm file,
    > and (3) a ctrans conversion of the ncgm file. I have been able to
    > demonstrate this in a one line modification to the NCAR example
    > cn11f.f, which first uses LLU (to draw contours, by opening and
    > closing a GKS workstation) and then uses HLU (to draw axes).
    >
    > I would like to find a way to get the same plot in all cases !
    >
    > I am running NCARG version 4.2.0.a023 on a Linux box (RH 7.3).
    > I modify cn11f.f by adding a call to set foreground to red in the LLU
    > section
    > call gscr( gkswid, 1, 1.,0.,0. )
    > (immediately following opening of GKS workstation with "call gacwk")
    >
    > When this is run I get following results (all with black background):
    >
    > X11 workstation: Red contours & red axes
    >
    > NCGM workstation: Red contours & white axes
    >
    > CTRANS of NCGM file: White contours & white axes
    >
    > (latter obtained from "ctrans -d sun cn11f.ncgm -outfile cn11f.sun"
    > which gives message:
    > ctrans: WARNING - Error processing CGM element(class=4, id=1,
    > name="Polyline")
    > [ Background color changes ignored after drawing has begun ]
    > (the .sun file is then displayed using ImageMagick "display")
    >
    > Dr. John W. (Jack) Glendening, Meteorologist

    Dear Dr. Glendening,

    Whenever you use the HLUs, it is best to use HLU type calls to
    manipulate your graphics where possible. Mixing HLU and LLU calls
    (GSCR is an LLU call) is doable, but as you saw, it doesn't always
    work as expected.

    If all you want to do is set the foreground color to red, I would
    recommend using the HLU method to do this, and that is by setting the
    "wkForeground" resource.

    When you open an workstation in the HLUs, this is where you want to do
    your color table manipulation. You can either set the whole color
    table, or you can just set the foreground and/or background color. So,
    using "cn11f.f" as an example, below is a code snippet showing how you
    would set the foreground color for each type of workstation:

          if (NCGM.eq.1) then
    C
    C Create an NCGM workstation.
    C
             call NhlFRLClear(rlist)
             call NhlFRLSetString(rlist,'wkMetaName','./cn11f.ncgm',ierr)
    C
    C Set foreground color.
    C
             call NhlFRLSetString(rlist,'wkForegroundColor','red',ierr)
             call NhlFCreate(wid,'cn11Work',
         1 NhlFNcgmWorkstationClass,0,rlist,ierr)
          else if (X11.eq.1) then
    C
    C Create an X workstation.
    C
             call NhlFRLClear(rlist)
             call NhlFRLSetstring(rlist,'wkPause','True',ierr)
    C
    C Set foreground color.
    C
             call NhlFRLSetString(rlist,'wkForegroundColor','red',ierr)
             call NhlFCreate(wid,'cn11Work',NhlFXWorkstationClass,
         1 0,rlist,ierr)
          else if (PS.eq.1) then
    C
    C Create a PS workstation.
    C
             call NhlFRLClear(rlist)
             call NhlFRLSetstring(rlist,'wkPSFileName','./cn11f.ps',ierr)
    C
    C Set foreground color.
    C
             call NhlFRLSetString(rlist,'wkForegroundColor','red',ierr)
             call NhlFCreate(wid,'cn11Work',
         1 NhlFPSWorkstationClass,0,rlist,ierr)
          endif

    You could also set the foreground color *after* the workstation is
    created, by using an NhlFSetValues call. This way, you only need to
    set the "wkForegroundColor" resource once. It is important to do all
    of your color table manipulation before you generate any graphics, so
    the following code snippet should be placed right after the big "IF"
    statement for creating the workstations:

          call NhlFRLClear(rlist)
          call NhlFRLSetString(rlist,'wkForegroundColor','red',ierr)
          call NhlFSetValues(wid,rlist,ierr)

    --Mary
    _______________________________________________
    ncarg-talk mailing list
    ncarg-talk AT unknown
    http://mailman.ucar.edu/mailman/listinfo/ncarg-talk



    This archive was generated by hypermail 2b29 : Wed Feb 26 2003 - 08:58:50 MST