Changeset 32 in Sophya


Ignore:
Timestamp:
Jan 10, 1997, 6:02:28 PM (29 years ago)
Author:
ansari
Message:

Support pour Output Postscript (psfile.cc/.h) avec modif des fichiers gen et x Reza 10/01/97

Location:
trunk/SophyaPI/PI
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/exclude

    r29 r32  
    1818piwindowmac.cc
    1919piup_def.cc
     20ex_dessin.cc
     21sc_sample.cc
  • trunk/SophyaPI/PI/pibwdggen.cc

    r23 r32  
    22
    33#include "pibwdggen.h"
     4#include "psfile.h"
    45
    56// Les methodes de la classe  PIBWdgGen
     
    1011PIWdg(par, nom, sx, sy, px, py)
    1112{
     13mPSOut=NULL;
    1214}
    1315
     
    115117}
    116118
     119
     120/* --Methode-- */
     121void PIBaseWdgGen::PSPrint(PSFile * psf, int ofx, int ofy)
     122{
     123if(!psf) return;
     124mPSOut = psf;
     125psf->NewBloc((float)(ofx+XPos()), (float)(ofy+YPos()),
     126             (float)XSize(),(float)YSize(),
     127             (float)XSize(),(float)YSize());
     128Draw();
     129psf->EndBloc();
     130mPSOut=NULL;
     131}
     132
  • trunk/SophyaPI/PI/pibwdggen.h

    r11 r32  
    77#include "pibwdggen.h"
    88
     9
    910enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ;
    1011
    11 enum PIColors  { PI_Black = 0, PI_White = 1,  PI_Grey = 2,
     12enum PIColors  { PI_NotDefColor = -1,
     13                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
    1214                 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 
    1315                 PI_Yellow = 6, PI_Magenta =7 };
    1416
    15 enum PIFontSize { PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 };
     17enum PIFontSize { PI_NotDefFontSize = -1,
     18                  PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 };
    1619
    17 enum PIFontAtt { PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
     20enum PIFontAtt { PI_NotDefFontAtt = -1,
     21                 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
    1822
    19 enum PILineAtt { PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };
     23enum PILineAtt { PI_NotDefLineAtt = -1,
     24                 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };
    2025
    21 enum PIMarker  { PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2, 
     26enum PIMarker  { PI_NotDefMarker = -1,
     27                 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2, 
    2228                 PI_CircleMarker=3, PI_FCircleMarker=4,
    2329                 PI_BoxMarker=5, PI_FBoxMarker=6,
     
    109115  virtual void       Ptr3Move(int x, int y);
    110116  virtual void       Keyboard(int key, PIKeyModifier kmod);
     117
     118// PostScript output
     119  virtual void       PSPrint(PSFile * psf, int ofx = 0, int ofy = 0);
     120
     121protected:
     122  PSFile * mPSOut;  /* Fichier PostScript eventuel */
    111123};
    112124
    113125
    114126#endif /* PIBWDGGEN_H_SEEN */
     127
  • trunk/SophyaPI/PI/pibwdgx.cc

    r23 r32  
    1212#include "pixtbaseP.h"
    1313#include "pixtbase.h"
     14
     15#include "psfile.h"
    1416
    1517
     
    132134void PIBaseWdgX::EraseWindow()
    133135{
     136if(mPSOut) return;
    134137XClearWindow   (XtDisplay(XtWdg()),XtWindow(XtWdg()) );
    135138return;
     
    139142void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)
    140143{
     144if(mPSOut){
     145mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* PIFontSize ?? */
     146}
     147else
    141148XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()),
    142149                  DefGC(), x, y, s, strlen(s));
     
    148155void PIBaseWdgX::DrawLine(int x1, int y1, int x2, int y2)
    149156{
     157if(mPSOut){
     158mPSOut->DrawLine((float)x1,(float)y1,(float)x2,(float)y2,
     159                 mFCol,mLAtt);
     160}
     161else
    150162XDrawLine(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(), x1, y1, x2, y2);
    151163return;
     
    156168void PIBaseWdgX::DrawBox(int x0, int y0, int dx, int dy)
    157169{
     170if(mPSOut)
     171mPSOut->DrawBox((float)x0,(float)y0,(float)dx,(float)dy,mFCol,mLAtt);
     172else{
    158173if (dx < 0)  { x0 += dx;  dx = -dx; }
    159174if (dy < 0)  { y0 += dy;  dy = -dy; }
    160175XDrawRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()),
    161176               DefGC(), x0, y0, dx, dy);
     177}
    162178return;
    163179}
     
    166182void PIBaseWdgX::DrawFBox(int x0, int y0, int dx, int dy)
    167183{
     184if(mPSOut)
     185mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy);
     186else{
    168187if (dx < 0)  { x0 += dx;  dx = -dx; }
    169188if (dy < 0)  { y0 += dy;  dy = -dy; }
    170189XFillRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()),
    171190               DefGC(), x0, y0, dx, dy);
     191}
    172192return;
    173193}
     
    176196void PIBaseWdgX::DrawCircle(int x0, int y0, int r)
    177197{
     198if(mPSOut)
     199mPSOut->DrawCircle((float)x0,(float)y0,(float)r,mFCol,mLAtt);
     200else
    178201XDrawArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),
    179202         x0-r, y0-r, 2*r, 2*r, 0, 360*64);
     
    184207void PIBaseWdgX::DrawFCircle(int x0, int y0, int r)
    185208{
     209if(mPSOut)
     210mPSOut->DrawFCircle((float)x0,(float)y0,(float)r,mFCol,mFCol,mLAtt);
     211else
    186212XFillArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),
    187213         x0-r, y0-r, 2*r, 2*r, 0, 360*64);
     
    198224XPoint *pxp;
    199225int i;
    200 
     226float *xtmp;
     227float *ytmp;
     228
     229if(mPSOut)
     230{
     231xtmp = (float*)malloc(n*sizeof(float));
     232ytmp = (float*)malloc(n*sizeof(float));
     233for(i=0;i<n;i++){
     234  xtmp[i] = (float)x[i];
     235  ytmp[i] = (float)y[i];
     236}
     237mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt);
     238free(xtmp);
     239free(ytmp);
     240}
     241else {
    201242if (n <= 0)  return;
    202243if (n > NMXXPOINTS)  pxp = new XPoint[n];
     
    205246XDrawLines(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, CoordModePrevious);
    206247if (n > NMXXPOINTS)  delete[] pxp;
     248}
    207249return;
    208250}
     
    215257XPoint *pxp;
    216258int i;
    217 
     259float *xtmp;
     260float *ytmp;
     261
     262if(mPSOut)
     263{
     264xtmp = (float*)malloc(n*sizeof(float));
     265ytmp = (float*)malloc(n*sizeof(float));
     266for(i=0;i<n;i++){
     267  xtmp[i] = (float)x[i];
     268  ytmp[i] = (float)y[i];
     269}
     270mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt);
     271free(xtmp);
     272free(ytmp);
     273}
     274else
     275{
    218276if (n <= 0)  return;
    219277if (n > NMXXPOINTS)  pxp = new XPoint[n];
     
    223281                        Complex, CoordModePrevious);
    224282if (n > NMXXPOINTS)  delete[] pxp;
     283}
    225284return;
    226285}
     
    233292int x[4],y[4];
    234293PILineAtt clatt;
    235 
     294if(mPSOut)
     295mPSOut->DrawMarker((float)x0,(float)y0,mMrk,mFCol);
     296else
     297{
    236298if (mMrk == PI_DotMarker)
    237299  XDrawPoint(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), x0, y0);
     
    279341  SelLine(clatt);
    280342  }
     343}
    281344return;
    282345}
     
    286349{
    287350int i;
    288 
     351float *xtmp;
     352float *ytmp;
     353
     354if(mPSOut)
     355{
     356xtmp = (float*)malloc(n*sizeof(float));
     357ytmp = (float*)malloc(n*sizeof(float));
     358for(i=0;i<n;i++){
     359  xtmp[i] = (float)x[i];
     360  ytmp[i] = (float)y[i];
     361}
     362mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol);
     363free(xtmp);
     364free(ytmp);
     365}
     366else
     367{
    289368if (n <= 0)  return;
    290369if (mMrk == PI_DotMarker)
     
    299378  }
    300379else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
     380}
    301381}
    302382
  • trunk/SophyaPI/PI/picmap.h

    r2 r32  
     1#ifndef PICMAP_H_SEEN
     2#define PICMAP_H_SEEN
     3
    14#include "pisysdep.h"
    25#include PICMAPNTV_H
     
    1215};
    1316
     17#endif
     18
  • trunk/SophyaPI/PI/picontainergen.cc

    r18 r32  
    2323  for(int i=0; i<mNCh; i++)  delete mChilds[i];
    2424delete[] mChilds;
     25}
     26
     27/* --Methode-- */
     28void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
     29{
     30int i;
     31if (!psf)  return;
     32if (!Visible())  return;
     33for(i=0; i<mNCh; i++)  mChilds[i]->PSPrint(psf, ofx+XPos(), ofy+YPos());
     34return;
    2535}
    2636
  • trunk/SophyaPI/PI/picontainergen.h

    r18 r32  
    1818  virtual long         kind() {return ClassId; }
    1919
     20  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0);
     21
    2022  virtual void         Show();
    2123  virtual void         Hide();
  • trunk/SophyaPI/PI/pipixmapx.cc

    r18 r32  
    66
    77#include "pipixmapx.h"
     8#include "psfile.h"
    89
    910static  GC    mygc;
     
    5960void PIPixmapX::Draw()
    6061{
    61 Draw(0, 0, XSize(), YSize());
     62if(mPSOut)
     63  if(pixmap)
     64    mPSOut->Image(0, 0, (float)XSize(), (float)YSize(), nx, ny, pixmap, cmap);
     65  else
     66    return; /* pour l'instant */
     67else
     68  Draw(0, 0, XSize(), YSize());
    6269}
    6370
  • trunk/SophyaPI/PI/piwdggen.cc

    r23 r32  
    55#include "picontainergen.h"
    66
     7#include "psfile.h"
    78
    89/* --Methode-- */
     
    4445}
    4546
     47/* --Methode-- */
     48void PIWdgGen::PSPrint(PSFile *psf, int ofx, int ofy)
     49{
     50char str[256];
     51
     52if (!psf) return;
     53psf->NewBloc((float)ofx+XPos(), (float)ofy+YPos(), (float)XSize(), (float)YSize(),
     54             (float)XSize(), (float)YSize());
     55psf->DrawBox(0., 0., (float)XSize(), (float)YSize());
     56sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
     57psf->DrawString(5., 5., str);
     58psf->EndBloc();
     59
     60return;
     61}
    4662
    4763/* --Methode--
  • trunk/SophyaPI/PI/piwdggen.h

    r23 r32  
    2020};
    2121
     22class PSFile;
    2223class PIContainerGen;
    2324class PIWdgGen : public PIMsgHandler
     
    6061  virtual void           GetScreenPos(int & spx, int & spy);
    6162
     63  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
     64
    6265protected:
    6366  PIContainerGen        *parent;
  • trunk/SophyaPI/PI/piwindowgen.cc

    r30 r32  
    11#include "piwindowgen.h"
    2 
     2#include "psfile.h"
    33
    44/* --Methode-- */
     
    1515PIWindowGen::~PIWindowGen()
    1616{}
     17
     18/* --Methode-- */
     19void PIWindowGen::PSPrint(PSFile *psf, int ofx, int ofy)
     20{
     21if (!psf) return;
     22int ori;
     23ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
     24psf->NewPage((float)XSize(), (float)YSize(),ori);
     25PIContainerGen::PSPrint(psf, ofx, ofy);
     26}
    1727
    1828
  • trunk/SophyaPI/PI/piwindowgen.h

    r30 r32  
    2222  virtual long      kind() {return ClassId; }
    2323
     24  virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0);
     25
    2426  inline  void      AutoHideOnClose(bool ahc=true) { mAHC = ahc; }
    2527
Note: See TracChangeset for help on using the changeset viewer.