Example #1
0
void QPrinter::interpret(PMPrintSettings *s)
{
  //get values
  UInt32 from, to;
  if (PMGetFirstPage(*s, &from) == noErr && PMGetLastPage(*s, &to) == noErr) {
    if (to == INT_MAX) //this means all pages!
      from = to = 0;
    setFromTo(from, to);
  }

  UInt32 copies;
  if (PMGetCopies(*s, &copies) == noErr)
    setNumCopies(copies);

  UInt32 max, min;
  if (PMGetPageRange(*s, &min, &max) == noErr) {
    // The problem here is that Apple's print dialog will always show a one even when you pass
    // it a zero. So take care of that. The other problem is that we can also call this because
    // we need to interpret the default settings, in that case, the min and max will both be
    // zero. In that case, leave them "as is" as some other functions will reset the max and
    // make everything OK when the dialog is actually called.
    int newMin = min;
    int newMax = max;

    if (newMin < 1 && newMax != 0)
      newMin = 1;
    setMinMax(newMin, newMax);
  }

  PMColorMode cm;
  if (PMGetColorMode(*s, &cm) == noErr)
    setColorMode(cm == kPMGray ? GrayScale : Color);
  // Get the current Printer Name
  CFIndex currPrinterIndex;
  PMPrinter currPrinter;
  CFArrayRef printerArray;
  OSStatus err = PMSessionCreatePrinterList(psession, &printerArray,
                                            &currPrinterIndex, &currPrinter);
  if (err != noErr)
    qWarning("Qt: QPrinter::interpret problem creating printer list %ld", err);
  if (printerArray) {
    setPrinterName(cfstring2qstring((CFStringRef)CFArrayGetValueAtIndex(printerArray,
                                                                        currPrinterIndex)));
    CFRelease(printerArray);
  }
}
Example #2
0
void ReportPrinter::setPrinterType(type type)
{
  if(outputFormat() != QPrinter::NativeFormat) {
    type = Standard;
  }

  if(type == m_printerType) {
    return;
  }

  // NB engines switch resets printer properties, we have to save them
  // (and also note that the print dialog can't support and custom printers, so it has to be called before switching to a custom type)
  QString savePrinterName = printerName();

  releaseEngines();

  switch (type) {
  case Sato:
    m_paintEngine = new SatoPaintEngine(this);
    if (m_printToBuffer)
      m_paintEngine->setPrintToBuffer();

    m_printEngine = new SatoPrintEngine(m_paintEngine, this);
    break;

  case Zebra:
    m_paintEngine = new ZebraPaintEngine(this);
    if (m_printToBuffer)
      m_paintEngine->setPrintToBuffer();

    m_printEngine = new ZebraPrintEngine(m_paintEngine, this);
    break;

  default:
    break;
  }

  if(m_paintEngine && m_printEngine) {
    setEngines(m_printEngine, m_paintEngine);
  }
  m_printerType = type;
  setPrinterName(savePrinterName);
}
Example #3
0
ofxCUPS::ofxCUPS(string printerName_)
{
    setPrinterName(printerName_);
}
Example #4
0
void bootup(char *modeptr, int enumber)
/*****************************/
{
    char	 autodir[MAXPATH];
    char         parampath[MAXPATH];
    char         plotname[STR64];
    char         mstr[MAXPATH];
    char         rtautocmd[2 * MAXPATH + 20];
    char	 estring[5];
    extern char  PlotterName[];
    extern char  PrinterName[];
    int do_rt = 0;
    int lval;
    endian_tester et;

    (void) modeptr;
    et.my_int = 0x0a0b0c0d;
    BigEndian = (et.my_bytes[0] == 0x0a) ? 1:0;
    psg_pid = 0;		/* set pids to zero */

    if ( !Bnmr )
       disp_status("BOOTUP  ");

/*  May 18, 1987.  Addition to read the system global parameters.
    If a problem occurs, the program exits immediately, for this
    should not happen.  The CONPAR file is on the distribution tape.	*/

    strcpy(parampath,systemdir);
#ifdef UNIX
    strcat(parampath,"/conpar");
#else 
    strcat(parampath,"conpar");
#endif 
    if (P_read(SYSTEMGLOBAL,parampath)) 
    {
	fprintf(stderr,"problem loading system global parameters from %s\n",
		parampath);
	exit(1);
    }
    openVnmrInfo(systemdir);

/*  If automation mode, use value of autodir to establish path to experiment  */

    if (mode_of_vnmr == AUTOMATION)
    {
      getAutoDir(autodir, MAXPATH);
      if (strlen(autodir) == 0)
      {
	  fprintf( stderr, "unable to access 'autodir' parameter\n" );
	  exit(1);
      }
    }

    /* setup signal handlers to catch these signals */
    if (Wissun())		/* Only do this if using SUN console */
    {
        set_acqi_signal();
    }
    else if (mode_of_vnmr == FOREGROUND) /* Only creat a Vnmr socket if foreground */
    {

	setupVnmrAsync(AcqSocketIsRead);
    }

#ifndef VNMRJ
    if (Wishds())
	last_line = 19;
    else
#endif
	last_line = 20;

    /* load parameters in global file */
    /* moved 9 lines to read GLOBAL before EXP, this way we can use
       curexpdir to restart Vnmr in the last exp used. May 17, 1997 */

    strcpy(parampath,userdir);
    strcat(parampath,"/global");
    if (P_read(GLOBAL,parampath)) 
	Werrprintf("problem loading global parameters");
#ifdef VNMRJ
   // set curexpdir based on jcurwin of viewport 1
   jcurwin_init(curexpdir);
#endif

     // load unshared globalX for viewport X if foreground
     if (!Bnmr)
     {
        sprintf(parampath,"%s/global%d",userdir,VnmrJViewId);
        /* Don't complain if unshared globals are missing */
        P_read(GLOBAL,parampath);
     }

    // set OperatorName 
    if ( (P_getstring(GLOBAL,"operator",OperatorName,1,MAXSTR) != 0) ||
         ( ! strcmp(OperatorName, "") ) )
	strcpy(OperatorName, UserName);

/*  If lock fails, and program is running in foreground mode, set
    current experiment to be EXP0, which doesn't exist.  The user
    can then join another experiment or use other techniques to
    unlock the desired experiment.

    If running in any other mode, exit immediately with an error
    message.							*/

/* May 19, 1997. Use curexpdir to set the enumber, check if directory
   still exists, if not make it exp1. Only done if FOREGROUND Vnmr.
   Acqproc, autoproc, and other procs determine enumber themselves.
   Note that curexpdir is overwritten below, when we read exp parameters */

#ifdef VNMRJ
   jviewport_init();
   P_setstring(GLOBAL,"curexp",curexpdir,1);
#else 
   P_getstring(GLOBAL,"curexp",curexpdir,1,MAXPATH);
#endif 
   if (mode_of_vnmr == FOREGROUND)
   {
      enumber = expdir_to_expnum(curexpdir);
      if (enumber == 0)
         lval = -1;
      else if ( ! access(curexpdir,F_OK))
        lval = lockExperiment( enumber, FOREGROUND);
      else
        lval = -1;
   }
#ifdef SUN
   else if (mode_of_vnmr == ACQUISITION)
      lval = (enumber == 0) ? -2 :checkAcqLock( enumber );
   else if ( Bnmr && (enumber == 0) )
      lval = -2;
   else
#endif
      lval = lockExperiment( enumber, mode_of_vnmr );

    if (lval != 0)
    {
        if ((mode_of_vnmr != FOREGROUND) && (lval != -2) )
        {
	    fprintf( stderr, "unable to lock experiment %d\n", enumber);
	    exit(1);
	}
        if (enumber == 0)
        {
#ifdef VNMRJ
           if (VnmrJViewId != 1)
           {
	      P_getstring(GLOBAL, "jviewportlabel", mstr, VnmrJViewId, MAXPATH);
	      Werrprintf( "No experiment selected for the %s viewport.",mstr);
           }
           jcurwin_setexp( "0" , -1 );
#else 
           if (lval != -2)
	      Werrprintf( "No experiment selected.");
#endif 
        }
        else
        {
#ifdef VNMRJ
           if (VnmrJViewId == 1)
	      Werrprintf( "Unable to lock experiment %d", enumber );
           else
           {
	      P_getstring(GLOBAL, "jviewportlabel", mstr, VnmrJViewId, MAXPATH);
	      Werrprintf( "Unable to lock experiment %d for the %s viewport.",enumber, mstr);
           }
           jcurwin_setexp( "0", -1 );
#else 
	   Werrprintf( "Unable to lock experiment %d", enumber );
#endif 
        }
        strcpy( curexpdir, userdir );
#ifdef UNIX
        strcat( curexpdir, "/exp0" );
#else 
	vms_fname_cat( curexpdir, "[.exp0]" );
#endif 
#ifdef VNMRJ
        if (mode_of_vnmr != AUTOMATION)
        { 
           sprintf(mstr,"exp0 %s",curexpdir);
           writelineToVnmrJ("expn",mstr);
        }
#endif
    }

/*  Only read in parameters if the target experiment was locked.  */

    else
    {
	if (mode_of_vnmr == AUTOMATION)
	  strcpy( curexpdir, &autodir[ 0 ] );
	else
          strcpy( curexpdir, userdir );

	sprintf(estring, "%d", enumber);
#ifdef UNIX
        strcat(curexpdir, "/exp");
	strcat(curexpdir, estring);
#else 
        vms_fname_cat(curexpdir, "[.exp");
        vms_fname_cat(curexpdir, estring);
        vms_fname_cat(curexpdir, "]");
#endif 

        if (mode_of_vnmr == AUTOMATION)
        {
	    lval = strlen( &datadir[ 0 ] );
	    if (lval > MAXPATH-8)
	    {
	        fprintf(stderr, "data pathname too long in automation mode");
	        exit(1);
	    }
            else if (lval > 1)
            {
                int ex;

                sprintf(rtautocmd, "cp %s.fid/sampleinfo %s/sampleinfo",
                        datadir,curexpdir);
                system(rtautocmd);
                ex = 0;
                /* Wait up to 0.5 secs for fid to appear */
                while ( access(rtautocmd,R_OK) && (ex < 50) )
                {
                   struct timespec timer;

                   timer.tv_sec=0;
                   timer.tv_nsec = 10000000;   /* 10 msec */
#ifdef __INTERIX
				   usleep(timer.tv_nsec/1000);
#else
                   nanosleep( &timer, NULL);
#endif
                   ex++;
                }
	        sprintf( &rtautocmd[ 0 ], "%s('%s','nodg')\n",
                         (acqStartUseRtp) ? "RTP" : "RT", &datadir[ 0 ] );
                do_rt = 1; /* do the rt command after reading global tree */
            }
            else  /* read curpar parameters only from the automation exp */
            {
                D_getparfilepath(CURRENT, parampath, curexpdir);
                if (P_read(CURRENT,parampath))
                {  /* if no parameters in current experiment */
                   strcpy(parampath,systemdir);
#ifdef UNIX
                   strcat(parampath,"/stdpar/H1.par/procpar");
#else 
                   vms_fname_cat(parampath,"[.stdpar.H1_par]procpar");
#endif 
                   if (P_read(CURRENT,parampath))
	              Werrprintf("problem loading current parameters");
                }
                P_copy(CURRENT,PROCESSED);
            }
        }
	else       /* if (mode_of_vnmr != AUTOMATION) */
        {
           /* load parameters in curexp/curpar file */
           D_getparfilepath(CURRENT, parampath, curexpdir);
           if (P_read(CURRENT,parampath))
	       Werrprintf("problem loading current parameters from \"%s\"",
                           parampath);
           /* load parameters in curexp/procpar file */
           D_getparfilepath(PROCESSED, parampath, curexpdir);
           if (P_read(PROCESSED,parampath))
	       Werrprintf("problem loading processed parameters from \"%s\"",
                           parampath);
#ifdef VNMRJ
	   sprintf(mstr,"exp%s %s",estring,curexpdir);
	   writelineToVnmrJ("expn",mstr);
#endif 
        }
    }


    /* May 17, 1997. We read GLOBAL parameters earlier */
    setGlobalPars();
#ifdef VNMRJ
    if (!Bnmr)
       saveViewPortAddr();
#endif 
    bufferscale = getbufscale();	/* obtain the value for bufferscale */
    finddatainfo();
    DEBUGPRINT1("bufferscale set to %d\n", bufferscale);
    D_init();				/* initialize the data file handler;
					   bufferscale must be known before
					   D_init() is called.		    */

    /* setAppdirs needs to happen after operator is set in setGlobalPars but before
     * any macros are called
     */
#ifdef VNMRJ
    if (VnmrJViewId == 1)
#endif 
    {
       setAppdirs();
    }

    specIndex = 1;
    if (mode_of_vnmr == AUTOMATION)
    {
      if (do_rt)
      {
        turnOffFixpar();
        execString( &rtautocmd[ 0 ] );
      }
      else
      {
        Werrprintf( "Spectrometer in automation mode" );
      }
    }
    else if (enumber || (mode_of_vnmr != BACKGROUND) )
    {
       disp_expno();
    }
    init_proc2d();
    strcpy(dconi_runstring,"dcon\n");

    /* Assign some function pointers for the */
    /* graphics module                       */
    set_bootup_gfcn_ptrs();
    if (Bnmr)
       init_colors();  /* set default colors for graphics and plotters */

    set_automount_dir();

    /*  Set up plotting parameters */
    /*  If there is trouble setting plottin parameters (ie plotting device
        doesn't exist or devicetable/devicenames is bad, set to "none" device */
    if (P_getstring(GLOBAL,"plotter" ,plotname, 1,32))
    {  P_setstring(GLOBAL,"plotter","none",0);
       strcpy(PlotterName,"none");
    }
    if (!setPlotterName(plotname))
    {  P_setstring(GLOBAL,"plotter","none",0);
       strcpy(PlotterName,"none");
    }

    /*  Set up printing parameters */
    /*  If there is trouble setting printing parameters (ie printing device
        doesn't exist or devicetable/devicenames is bad, set to "none" device */
    if (P_getstring(GLOBAL,"printer" ,plotname, 1,32))
    {  P_setstring(GLOBAL,"printer","none",0);
       strcpy(PrinterName,"none");
    }
    if (!setPrinterName(plotname))
    {  P_setstring(GLOBAL,"Printer","none",0);
       strcpy(PrinterName,"none");
    }

#ifdef SUN
/*
 *  Set up signal handler to exit VNMR
 *  The function nmr_quit will be called when Vnmr exits
 */
    set_nmr_quit_signal();
#endif 
    check_datastation();

#ifdef VNMRJ
    writelineToVnmrJ("bootup","");
    /* create a frame for graphics display */
    frame_update("init", "");
#endif 

/*  The extra space in the first Wscrprintf is essential for
    the scrollable text subwindow to work correctly.			*/

/* ---  print revision ID and Date, Compiled within revdate.c --- */
    P_setstring( SYSTEMGLOBAL, "rev", &RevID[ 0 ], 1);
    P_setstring( SYSTEMGLOBAL, "revdate", &RevDate[ 0 ], 1);
    if (!Bnmr) /* only execute the bootup macro if we are in forground */
    {
	Wscrprintf("\n              %s\n",RevID);
        Wscrprintf("              %s\n",RevDate);

        Wscrprintf("              %s\n\n",Copyright);
        if (strlen(PlotterName) > 0)
           Wscrprintf( "              Plotting Device is set to %s\n",PlotterName);
        else
           Wscrprintf( "              Plotting Device is set to ''\n");
        if (strlen(PrinterName) > 0)
           Wscrprintf( "              Printing Device is set to %s\n\n",PrinterName);
        else
           Wscrprintf( "              Printing Device is set to ''\n\n");

        disp_current_seq();
        if (Wissun())
           sendTripleEscToMaster( 'C',"bootup(0)");
        else
	   execString("bootup(0)\n");
        disp_status("        ");
    }
    else if (enumber)
    {
	execString("bootup(1)\n");
    }

    p11_init();
}