Exemple #1
0
void create_split_dialog(Widget parent)
{
    XmString message;
    Widget temp_widget = parent;

    /* Ensure the parent of the dialog is a shell widget */
    while ( !XtIsShell(temp_widget) ) {
	temp_widget = XtParent(temp_widget);
    }
    message = XmStringLtoRCreate(SPLIT_MESSAGE, XmSTRING_DEFAULT_CHARSET);
    argcount = 0;
    XtSetArg(args[argcount], XmNselectionLabelString, message); argcount++;
    split_dialog = XmCreatePromptDialog(temp_widget, "split dialog",
				args, argcount);
    /* Remove the help button from the dialog */
    temp_widget = XmSelectionBoxGetChild(split_dialog, XmDIALOG_HELP_BUTTON);
    XtUnmanageChild(temp_widget);
    /* Add the actions to the buttons */
    XtAddCallback(split_dialog, XmNokCallback,
		(XtCallbackProc) start_split, (XtPointer) NULL);
    XtAddCallback(split_dialog, XmNokCallback,
		(XtCallbackProc) activate_merge_dialog, (XtPointer) NULL);
    XmStringFree(message);
    create_merge_dialog(main_window);
}
Exemple #2
0
void
SetVPMacro ( KeyListType *fdf, char *file )
{
/*
 * The current FDF is a macro so change GUI to reflect a different mode.
 */
	GuiVertProfileObjectType	*vpt;
	XmString			xmstr;
	char				*buf="MACRO";


	vpt = GetGuiVertProfileDialog();

/*
 *	Set function textfield widget.
 */
        FreeFunctionVP ( vpt );
	SetFunctionVP ( vpt, buf );
	XmTextSetString ( GetFunctionVPW ( vpt ), GetFunctionVP ( vpt ) );

/*
 *	Set label.
 */
	FreeModelFdfVP ( vpt );
	SetModelFdfVP ( vpt, file );

	xmstr = XmStringLtoRCreate ( buf, XmSTRING_DEFAULT_CHARSET );
	XtVaSetValues ( GetModelFdfVPW ( vpt ),
			XmNlabelString, xmstr,
			NULL);
	XmStringFree ( xmstr );

}
Exemple #3
0
/* Procedure to create de dialog. */
void create_sigma_dialog(Widget parent){
  
  XmString message;
  Widget temp_widget = parent;

  /* Ensure the parent of the dialog is a shell widget */
  while ( !XtIsShell(temp_widget) ) {
    temp_widget = XtParent(temp_widget);
  }

  message = XmStringLtoRCreate(SIGMA_MESSAGE, XmSTRING_DEFAULT_CHARSET);

  argcount = 0;
  XtSetArg(args[argcount], XmNselectionLabelString, message); argcount++;
  sigma_dialog = XmCreatePromptDialog(temp_widget, "gaussian dialog",
					args, argcount);

  /* Remove the help button from the dialog */
  temp_widget = XmSelectionBoxGetChild(sigma_dialog, XmDIALOG_HELP_BUTTON);
  XtUnmanageChild(temp_widget);

  /* Add the actions to the buttons */
  XtAddCallback(sigma_dialog, XmNokCallback,
		(XtCallbackProc) ok_sigmabutton_callback, (XtPointer) NULL);
  XtAddCallback(sigma_dialog, XmNcancelCallback,
		(XtCallbackProc) cancel_sigmabutton_callback, (XtPointer) NULL);

  XmStringFree(message);

}/*end create_sigma_dialog*/
Exemple #4
0
XmString 
XmStringCreateLtoR(
        char *text,
        XmStringTag tag )
{
  return (XmStringLtoRCreate (text, tag));
}
Exemple #5
0
void
UpdateFrameCounterWidgets ( WindowObjectType *wo )

{

	char			string [20];
	GuiFrameCounterType	*frm;
	XmString		label;
	Widget			counterW, currentW;
	int			index, frame, total_frames;

/*
 *	Update the frame counter widget first. (eg; "5 of 10")
 */
 	frm = GetGuiFrameCounter();
	counterW = GetFrameCounterW ( frm );

	index = GetActivePixmapObjectIndex (wo);
	frame = index + 1;
	total_frames = GetWindowObjectNumPixmapObjects (wo);

	if ( frame > total_frames ) frame = total_frames;
	
	sprintf (string, "%d\nof\n%d", frame, total_frames);
	label = XmStringLtoRCreate ( string,
	        (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );

	XtVaSetValues ( counterW, XmNlabelString, label, NULL );
	RefreshWidgetNow ( counterW );
	XmStringFree ( label );

/*
 *	Update the current frame widget in the frame button pop-up if
 *	it is currently managed (visible)
 */
	currentW = GetCurrentFrameLabelW ( frm );
	if ( ! XtIsManaged (currentW )) return;

	sprintf (string, "%d", frame);
	label = XmStringLtoRCreate ( string,
	        (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	
	XtVaSetValues ( currentW, XmNlabelString, label, NULL );
	RefreshWidgetNow ( currentW );
	XmStringFree ( label );

}
Exemple #6
0
static Widget CreateToggle(char *label, Widget parent)
{
  Widget widget;
  register int n;
  Arg args[MAX_ARGS];
  XmString tcs;

  n = 0;
  tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET);
  XtSetArg(args[n], XmNlabelString, tcs);  n++;
  widget = XmCreateToggleButton(parent, label, args, n);
  XtManageChild(widget);
  XmStringFree(tcs);
  return(widget);
}
Exemple #7
0
static Widget CreateCascade(char *label, char mnemonic, Widget submenu,
                            Widget parent)
{
    Widget widget;
    register int  n;
    Arg args[MAX_ARGS];
    XmString tcs;

    n = 0;
    tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tcs);
    n++;
    XtSetArg(args[n], XmNmnemonic, mnemonic);
    n++;
    XtSetArg(args[n], XmNsubMenuId, submenu);
    n++;
    widget = XmCreateCascadeButton(parent, label, args, n);
    XtManageChild(widget);
    XmStringFree(tcs);
    return(widget);
}
Exemple #8
0
void
SetGridWidgets ( KeyListType *fdf, char *file )
{
/*
 * Driver program for setting widget states according to FDF input.
 */
	Widget			w;
	XmString		xmstr;

	GuiScalarGridDialogType	*grd;
	ModelInfoType		*mdl;

	char			*function, *description;
	char			*layer,	*fline, *vcoord;
	int			verbose;

	grd = GetGuiScalarGridDialog();
	mdl = GetGuiModelInfo();
	verbose = GetVerboseLevel();

	if( verbose > VERBOSE_0 )
	    printf ( "SetGridWidgets\n" );

	function		= GetFdfKeyValue ( fdf, "function" );
	layer			= GetFdfKeyValue ( fdf, "layer" );
	description		= GetFdfKeyValue ( fdf, "description" );
	fline			= GetFdfKeyValue ( fdf, "fline" );
	vcoord			= strdup ( GetModelVCoord ( mdl ) );

/*
 *	Use FDF keys to obtain values and set corresponding widget values.
 */
						/* function */
	FreeFunctionHS ( grd );
	SetFunctionHS ( grd, function );
	XmTextSetString ( GetFunctionHSW ( grd ), GetFunctionHS ( grd ) );
	if ( function != NULL ) Free ( function );

						/* description */
	FreeFieldInfoHS ( grd );
	SetFieldInfoHS ( grd, description );
	XmTextSetString ( GetFieldInfoHSW ( grd ), GetFieldInfoHS ( grd ) );
	if ( description != NULL ) Free ( description );

/*
 *	Set level textfields.
 */
	XmTextSetString ( GetModelLevel1HSW ( mdl ), GetModelLevel1 ( mdl ) );
	XmTextSetString ( GetModelLevel2HSW ( mdl ), GetModelLevel2 ( mdl ) );

	if ( fline != NULL ) {			/* fline */
	    FreeFillColorsHS ( grd );
	    SetFillColorsHS ( grd, fline );
	    Free ( fline );
	}

/*
 *      Set level/layer radio button.
 */
	if ( layer != NULL ) {
            SetModelLevelTypeCB ( w, (XtPointer) layer,
                              	     (XtPointer) NULL );
	    Free ( layer );
	}

/*
 *	Set fdf name in main dialog.
 */
	FreeModelFdfHS ( grd );
	SetModelFdfHS ( grd, file );

        xmstr = XmStringLtoRCreate ( GetModelFdfHS ( grd ),
					XmSTRING_DEFAULT_CHARSET );
        XtVaSetValues ( GetModelFdfHSW ( grd ),
			XmNlabelString, xmstr,
			NULL);
        XmStringFree ( xmstr );

/*
 *	Set scale factor textfield.
 */
	XmTextSetString ( GetScaleFactorHSW ( grd ), GetScaleFactorHS ( grd ) );

/*
 *	Plot contour lines and/or color fill and/or symbols.
 */
	SetGridPlotType ( fdf );

/*
 *	Set line and fill intervals.
 */
	SetContourLineInfo ( fdf, vcoord, GetModelLevel1 ( mdl ) );

/*
 *	Set option menu buttons.
 */
	SetGridOptionMenuButtons ( fdf );

	Free ( vcoord );
}
Exemple #9
0
void writesdm(char *filename)
{
  cdmObjectHandle ds, mesh, meshref;
  cdmObjectHandle PtVec3C, PtScalarT, ZoneScalarT, FldHandle;
  cdm_int64 status;

  short flag;
  long i, j, nvect;
  char str2[] = "Error - cannot open file: ";
  XmString string, string1, string2;
  double *temparray, *tempvect1, *tempvect2, *tempvect3;


   /*  Create the dataset that contains the field data. */
   printf("\nStoring Field data in CDM file \"%s\".\n", filename);
   ds = cdmDataset_Create(cdmHDF5, cdmCreate, filename);

   if (ds < 0)
     {
      errorfile = 0;
      string1 = XmStringLtoRCreate(str2,
                                  XmSTRING_DEFAULT_CHARSET);
      string2 = XmStringLtoRCreate(filnam,
                                  XmSTRING_DEFAULT_CHARSET);
      string = XmStringConcat(string1,string2);
      XtVaSetValues(objerrlab,XmNlabelString,string,NULL);
      XmStringFree(string);
      XmStringFree(string1);
      XmStringFree(string2);
      MyManageChild(errorform);
      return;
     }

   mesh = cdmGenPolyhedralMesh_Create(ds, 3, 3, nnodes, "XCMUPoly3DMesh");
   if (mesh < 0)
     {
      printf("Cannot create mesh.\n");
      cdmDataset_Delete(ds);
      return;
     }

   status = cdmGenPolyhedralMesh_Commit(mesh);

   /*  Write velocities.  */
   flag = -1;
   if (nvectin > -1) flag = 1;
   else if (cvectin > -1) flag = 0;
   if (flag > -1)
     {

      /*  Define velocity field template.  */
      PtVec3C = cdmGenPolyhedralMeshFieldTemplate_Create(ds, mesh, 3, 
                    "ThreeCompPtVector");
      if (PtVec3C < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefCellCategory(PtVec3C, 1, 
                    cdm0Cell);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefDataType(PtVec3C, 1, 
                    cdmFloat64);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefCellCategory(PtVec3C, 2, 
                  cdm0Cell);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
        }

      status = cdmGenPolyhedralMeshFieldTemplate_DefDataType(PtVec3C, 2, 
                  cdmFloat64);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefCellCategory(PtVec3C, 3, 
                  cdm0Cell);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefDataType(PtVec3C, 3, 
                  cdmFloat64);
      if (status < 0)
        {
	 printf("Cannot create ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_Commit(PtVec3C);
      if (status < 0)
        {
	 printf("Cannot commit ThreeCompPtVector template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      /*  Fill vector arrays.  */
      if (flag == 1)
        {
         nvect = nnodes;
         tempvect1 = (double *)malloc((nnodes+1)*sizeof(double));
         tempvect2 = (double *)malloc((nnodes+1)*sizeof(double));
         tempvect3 = (double *)malloc((nnodes+1)*sizeof(double));
         fillnodevalue(vectfldx,tempvect1);
         fillnodevalue(vectfldy,tempvect2);
         fillnodevalue(vectfldz,tempvect3);
        }
      else
        {
         nvect = ncells;
         tempvect1 = (double *)malloc((ncells+1)*sizeof(double));
         tempvect2 = (double *)malloc((ncells+1)*sizeof(double));
         tempvect3 = (double *)malloc((ncells+1)*sizeof(double));
         fillcellvalue(cvectfldx,tempvect1+1);
         fillcellvalue(cvectfldy,tempvect2+1);
         fillcellvalue(cvectfldz,tempvect3+1);
        }

      /*  Store vector data.  */
      FldHandle = cdmGenPolyhedralMeshField_Create(ds, PtVec3C, "Velocity");
      if (FldHandle < 0)
	{
	 printf("Cannot create Velocity field.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      printf("\nStoring first velocity component with %ld values.\n",nvect);
      status = cdmGenPolyhedralMeshField_DefFieldVals(FldHandle,1,1,nvect,1, 
                  tempvect1+1);
      if (status < 0)
        {
	 printf("Cannot create Velocity field.\n");
	 cdmGenPolyhedralMeshField_Delete(FldHandle);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      printf("\nStoring second velocity component with %ld values.\n",nvect);
      status = cdmGenPolyhedralMeshField_DefFieldVals(FldHandle,1,1,nvect,1, 
                  tempvect2+1);
      if (status < 0)
        {
	 printf("Cannot create Velocity field.\n");
	 cdmGenPolyhedralMeshField_Delete(FldHandle);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      printf("\nStoring third velocity component with %ld values.\n",nvect);
      status = cdmGenPolyhedralMeshField_DefFieldVals(FldHandle,1,1,nvect,1, 
                  tempvect3+1);
      if (status < 0)
        {
	 printf("Cannot create Velocity field.\n");
	 cdmGenPolyhedralMeshField_Delete(FldHandle);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      free(tempvect1);  free(tempvect2);  free(tempvect3);

      status = cdmGenPolyhedralMeshField_Commit(FldHandle);
      if (status < 0)
        {
	 printf("Cannot create Velocity field.\n");
	 cdmGenPolyhedralMeshField_Delete(FldHandle);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
        }

      cdmGenPolyhedralMeshField_Delete(FldHandle);
      cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
     }


   /*  Define point scalar field template, if field data exists.  */
   flag = 0; 
   for (i = 0; i < MAXFIELDS; i++) flag += nvars_to_write[i];
   if (flag > 0) 
     {
      PtScalarT = cdmGenPolyhedralMeshFieldTemplate_Create(ds, mesh, 1, 
                     "PointScalarT");
      if (PtScalarT < 0)
        {
	 printf("Cannot create PointScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefCellCategory(PtScalarT, 1, 
                  cdm0Cell);
      if (status < 0)
        {
	 printf("Cannot create PointScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefDataType(PtScalarT, 1, 
                  cdmFloat64);
      if (status < 0)
        {
	 printf("Cannot create PointScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_Commit(PtScalarT);
      if (status < 0)
        {
	 printf("Cannot commit PointScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      /*  Loop through node fields and store data.  */
      temparray = (double *)malloc((nnodes+1)*sizeof(double));
      for (i = 0; i < MAXFIELDS; i++)
        {
         if (nvars_to_write[i])
           {
	    FldHandle = cdmGenPolyhedralMeshField_Create(ds, PtScalarT, 
                           fieldname[i]);
	    if (FldHandle < 0)
              {
	       printf("Cannot create point scalar field \"%s\".\n", 
                      fieldname[i]);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }

            fillnodevalue(i,temparray);
            printf("\nStoring point component %s with %ld values.\n", 
                   fieldname[i], nnodes);
	    status = cdmGenPolyhedralMeshField_DefFieldVals(FldHandle, 1, 1, 
                        nnodes, 1, temparray+1);
	    if (status < 0)
              {
	       printf("Cannot create point scalar field \"%s\".\n",
                      fieldname[i]);
	       cdmGenPolyhedralMeshField_Delete(FldHandle);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }

            status = cdmGenPolyhedralMeshField_Commit(FldHandle);
	    if (status < 0)
	      {
	       printf("Cannot create point scalar field \"%s\".\n", 
                      fieldname[i]);
	       cdmGenPolyhedralMeshField_Delete(FldHandle);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }
	    cdmGenPolyhedralMeshField_Delete(FldHandle);
           }
        }
      cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
      free(temparray);
     }

   /*  Define cell scalar field template, if field data exists.  */
   flag = 0; 
   for (i = 0; i < MAXFIELDS; i++) flag += cvars_to_write[i];
   if (flag > 0) 
     {
      ZoneScalarT = cdmGenPolyhedralMeshFieldTemplate_Create(ds, mesh, 1, 
                       "ZoneScalarT");
      if (ZoneScalarT < 0)
        {
	 printf("Cannot create ZoneScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefCellCategory(ZoneScalarT, 1,
                  cdm0Cell);
      if (status < 0)
        {
	 printf("Cannot create ZoneScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_DefDataType(ZoneScalarT, 1, 
                  cdmFloat64);
      if (status < 0)
        {
	 printf("Cannot create ZoneScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      status = cdmGenPolyhedralMeshFieldTemplate_Commit(ZoneScalarT);
      if (status < 0)
        {
	 printf("Cannot commit ZoneScalarT template.\n");
	 cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	 cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	 cdmGenPolyhedralMesh_Delete(mesh);
	 cdmDataset_Delete(ds);
	 return;
	}

      /*  Loop through cell fields and store data.  */
      temparray = (double *)malloc((ncells)*sizeof(double));
      for (i = 0; i < MAXFIELDS; i++)
        {
         if (cvars_to_write[i])
           {
	    FldHandle = cdmGenPolyhedralMeshField_Create(ds, ZoneScalarT, 
                           cfieldname[i]);
	    if (FldHandle < 0)
	      {
	       printf("Cannot create zone scalar field \"%s\".\n", 
                      cfieldname[i]);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }

            fillcellvalue(i,temparray);
	    printf("\nStoring zone component %s with %ld values.\n", 
                   cfieldname[i], ncells);
	    status = cdmGenPolyhedralMeshField_DefFieldVals(FldHandle, 1, 1, 
                     ncells, 1, temparray);
	    if (status < 0)
	      {
	       printf("Cannot create zone scalar field \"%s\".\n", 
                      cfieldname[i]);
	       cdmGenPolyhedralMeshField_Delete(FldHandle);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }

	    status = cdmGenPolyhedralMeshField_Commit(FldHandle);
	    if (status < 0)
	      {
	       printf("Cannot create zone scalar field \"%s\".\n", 
                      cfieldname[i]);
	       cdmGenPolyhedralMeshField_Delete(FldHandle);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtScalarT);
	       cdmGenPolyhedralMeshFieldTemplate_Delete(PtVec3C);
	       cdmGenPolyhedralMesh_Delete(mesh);
	       cdmDataset_Delete(ds);
	       return;
	      }

	    cdmGenPolyhedralMeshField_Delete(FldHandle);
           }
        }
      free(temparray);
      cdmGenPolyhedralMeshFieldTemplate_Delete(ZoneScalarT);
     }

   /*  Cleanup.  */
   cdmGenPolyhedralMesh_Delete(mesh);
   cdmDataset_Delete(ds);
}
Exemple #10
0
int 
main (int argc, char **argv)
{
   XtAppContext ParmApp;
   Widget PSform,
          b_indirect;
   XmString temp_string;
   int n;
   Arg args[20];

   /* Create the application */
   ParmShell = XtVaAppInitialize(&ParmApp, "Tab Test", NULL, 0,
                                &argc, argv, NULL, NULL);

   /* Create the form */
   n=0;
   XtSetArg(args[n], XmNwidth, 300);n++;
   XtSetArg(args[n], XmNheight, 150);n++;
   PSform = XmCreateForm(ParmShell, "PSform", args, n);
   XtManageChild(PSform);

   /* Create the indirect toggle button */
   temp_string=XmStringLtoRCreate("Indirect", XmSTRING_DEFAULT_CHARSET);
   n=0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNheight, 75);n++;
   XtSetArg(args[n], XmNlabelString, temp_string);n++;
   b_indirect = XmCreateToggleButton(PSform, "Toggle", args, n);
   XmStringFree(temp_string);
   XtAddCallback (b_indirect, XmNvalueChangedCallback,(XtCallbackProc)ChangeIndirect,
                  NULL);

   XtManageChild(b_indirect);

   /* Create the intermediate destination text field */
   temp_string=XmStringLtoRCreate("Intermediate Dest", XmSTRING_DEFAULT_CHARSET);
   n=0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET);n++;
   XtSetArg(args[n], XmNtopWidget, b_indirect);n++;
   XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM);n++;
   XtSetArg(args[n], XmNlabelString, temp_string);n++;
   XtSetArg(args[n], XmNscrollVertical, False);n++;
   XtSetArg(args[n], XmNscrollHorizontal, False);n++;
   b_text = XmCreateScrolledText(PSform, "LabelIndirect", args, n);
   XmStringFree(temp_string);
   n=0;
   XtSetArg(args[n], XmNeditMode, XmSINGLE_LINE_EDIT);n++;
   XtSetValues(b_text,args,n);
   XtManageChild(b_text);

   XtRealizeWidget(ParmShell);
   dumpWidgetTree(ParmShell);
#if 0
   XtAppMainLoop(ParmApp);
#else
   LessTifTestMainLoop(ParmShell);
#endif

   exit(0);
}