Changeset 292 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
May 11, 1999, 6:01:04 AM (26 years ago)
Author:
ercodmgr
Message:

Coupes X-Y pour PIImage et diverses petites correction - Reza 11/05/99

Location:
trunk/SophyaPI/PI
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/lut.cc

    r204 r292  
    44// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
    55
    6 #include "defs.h"
     6#include "machdefs.h"
    77#include <stdlib.h>
    88#include <stdio.h>
  • trunk/SophyaPI/PI/parradapter.h

    r204 r292  
    77#define PARRADAPTER_SEEN
    88
    9 #include "defs.h"
    10 #include "machine.h"
     9#include "machdefs.h"
    1110#include "lut.h"
    1211
  • trunk/SophyaPI/PI/pibwdgx.cc

    r180 r292  
    108108void PIBaseWdgX::Refresh()
    109109{
    110 if ( IsVisible() )  {
     110if (XtIsRealized(XtWdg())) {
     111// if ( IsVisible() )  {
    111112//  EraseWindow();   --> Ne pas faire  Reza 12/98
    112113  Draw(mWGrC, 0, 0, XSize(), YSize());
  • trunk/SophyaPI/PI/picons.cc

    r158 r292  
    743743nc = (mCPendC-mCPbeginC)/mFLarg;
    744744nl = (mCPendL-mCPbeginL)/mFHaut;
     745if (nl < 1) nl = 1;  // On selectionne au moins une ligne
    745746// printf("*DBG* NC=%d NL=%d \n",nc, nl);
    746747l1 = mNL+1; l2 = -1;
     
    767768mCPendC = (int) ( (float)mCPendC/(float)mFLarg-0.8 );
    768769mCPbeginL = (int) ( (float)mCPbeginL/(float)mFHaut-0.5 ) ;
    769 mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.3 ) ;
     770mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.5 ) ;
     771if (mCPendL <= mCPbeginL) mCPendL = mCPbeginL+1;  // Au moins une ligne selectionnee
    770772// printf("..DBG.. C= %d %d  L = %d %d ", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
    771773j = mNL-mWSzL-mOffL;
  • trunk/SophyaPI/PI/pidrawer.cc

    r209 r292  
    55
    66#include "pidrawer.h"
     7#include <math.h>
    78
    89//++
  • trunk/SophyaPI/PI/pidrwtools.cc

    r209 r292  
    4444/* --Methode-- */
    4545PIDrwTools::PIDrwTools(PIApplication* par)
    46 : PIWindow((PIMsgHandler*)par, "PIDrawerTools", PIWK_dialog, 240, 240, 150, 150)
     46: PIWindow((PIMsgHandler*)par, "PIDrawerTools", PIWK_normal, 240, 240, 150, 150)
    4747{
    4848int bsx, bsy, spx, spy;
  • trunk/SophyaPI/PI/pigraphgen.cc

    r204 r292  
    181181//|     PI_Black , PI_White,  PI_Grey , PI_Red , PI_Blue , PI_Green , 
    182182//|     PI_Yellow , PI_Magenta , PI_Cyan , PI_Turquoise , PI_NavyBlue ,
    183 //|     PI_Orange , PI_SiennaRed , PI_Purple , PI_LimeGreen , PI_Gold
     183//|     PI_Orange , PI_SiennaRed , PI_Purple , PI_LimeGreen , PI_Gold ,
     184//|     PI_ColorAllBits0 , PI_ColorAllBits1
    184185// void  SelBackground(PIColors col=PI_White)
    185186//      Choix de la couleur d'arrière-plan
     
    189190//      Choix de la couleur d'arrière-plan: Couleur numéro "cid" de la table de couleur "cmap"
    190191// void  SelGOMode(PIGOMode mod=PI_GOCopy)
    191 //      Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR"     
     192//      Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR" ou  "PI_GOInvert"
    192193// void  SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont)
    193194//      Choix de la fonte pour le tracé de texte
  • trunk/SophyaPI/PI/pigraphgen.h

    r204 r292  
    1313
    1414
    15 enum PIColors  { PI_ColorFromMap = -2, PI_NotDefColor = -1,
     15enum PIColors  { PI_ColorFromMap = -4, PI_NotDefColor = -1,
    1616                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
    1717                 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 
     
    1919                 PI_Cyan = 8, PI_Turquoise = 9, PI_NavyBlue = 10,
    2020                 PI_Orange = 11, PI_SiennaRed = 12, PI_Purple = 13, 
    21                  PI_LimeGreen = 14, PI_Gold = 15 };
     21                 PI_LimeGreen = 14, PI_Gold = 15,
     22                 PI_ColorAllBits0 = 16, PI_ColorAllBits1 = 17 };
    2223
    2324enum PIFontSize { PI_NotDefFontSize = -1,
     
    4041                 PI_StarMarker=9, PI_FStarMarker=10 };
    4142
    42 enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1 };
     43enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1, PI_GOInvert = 2 };
    4344
    4445
  • trunk/SophyaPI/PI/pigraphx.cc

    r204 r292  
    2020static int HugeFontIndex = 6;
    2121static  PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont };
    22 #define NMAXCOL  16
     22#define NMAXCOL  18
    2323static  PIXColor colpix[NMAXCOL];
    2424
     
    420420    mGOm = mod;
    421421    break;
     422  case PI_GOInvert :
     423    XSetFunction(mDisp, DefGC(), GXinvert);
     424    mGOm = mod;
     425    break;
    422426  }
    423427return;
     
    801805colpix[PI_Black] = XBlackPixel(mdsp, scr);
    802806colpix[PI_White] = XWhitePixel(mdsp, scr);
     807colpix[PI_ColorAllBits0] = 0;
     808colpix[PI_ColorAllBits1] = ~colpix[PI_ColorAllBits0];
    803809if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) )
    804810  colpix[PI_Grey] = mycol.pixel;
  • trunk/SophyaPI/PI/piimage.cc

    r212 r292  
    1212#include "piimgtools.h"
    1313#include "pidrwtools.h"
     14#include "piscdrawwdg.h"
    1415#include PIAPP_H
    1516
     
    2223//      Peut contrôler un PIPixmap pour l'affichage d'une zone
    2324//      agrandie (zoom) et un PIPixmap pour l'affichage de toute
    24 //      l'image (réduite).
     25//      l'image (réduite). Peut aussi gerer une fenetre de coupes.
    2526//      Utilise les adaptateur de tableaux 2D manipuler le
    2627//      contenu des images ("P2DArrayAdapter").
     
    4041//      * <Alt>C : *Copier*/Coller Permet de copier le contenu de la zone sélectionnée
    4142//      de l'image sous forme texte.
     43//      * <Alt>P : Active/désactive l'affichage de l'indicateur de la postion du pavé
     44//      * <Alt>X : Active/désactive l'affichage des coupes X,Y
    4245//      * <Alt>Z : Supprime les textes et signes ajoutés au dessin.
    4346//      * Touches Curseurs : déplace la pavé.
     
    101104showinfo = false;
    102105
     106// Fenetre et ScDrawWdg pour les coupes
     107cutwin = NULL;
     108cutscw = NULL;
     109
    103110gpixm = zpixm = pixm = NULL;
    104111xsgpxm = xszpxm = xspxm = 0;
     
    112119dxmv = dymv = 0;
    113120xcurs = ycurs = -1;
     121cuhsz = 8;  cuvsz = 8;
     122cucol = PI_Yellow; culat = PI_NormalLine;
    114123zoom = 1;
    115124zmgv = 1;
     
    157166  }
    158167if (cmvw)  cmvw->SetColMap(NULL, 1., -1., true);
     168if (cutwin)  delete cutwin;
    159169if (lut) delete lut;
    160170delete mdrw;
     
    169179void PIImage::Process(PIMessage msg, PIMsgHandler* sender, void* data)
    170180{
    171 if (UserMsg(msg) == (Msg()+626))
     181
     182if ((ModMsg(msg) == PIMsg_Close) && (sender == cutwin)) {
     183  cutwin->Hide();
     184  delete cutwin;
     185  cutwin = NULL;
     186  cutscw = NULL;
     187  }
     188else if (UserMsg(msg) == (Msg()+626))
    172189  {
    173190  if (ModMsg(msg) == PIMsg_Click)
     
    261278  char buff[256];
    262279  double x,y;
    263   img->XYCoord(xpav, ypav, x, y);
     280  img->Coord(xpav, ypav, x, y);
    264281  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ",
    265282          x, y , (*img)(xpav, ypav), xpav, ypav );
     
    277294else DrawCursor(mWGrC, -1, -1);
    278295return;
     296}
     297
     298
     299/* --Methode-- */
     300void PIImage::ShowCuts(bool cuts)
     301{
     302if (cuts) {
     303  if (cutwin) { cutwin->Show(); return; }
     304  int tpx, tpy;
     305  GetScreenPos(tpx, tpy);
     306  string nom = Nom() + "-Cuts";
     307  cutwin = new PIWindow(this, const_cast<char *>(nom.c_str()), PIWK_normal,  300, 200, tpx, tpy+YSize()+10);
     308  cutwin->SetAutoDelChilds(true);
     309  nom += "_ScWdg";
     310  cutscw = new PIScDrawWdg(cutwin, const_cast<char *>(nom.c_str()), 300, 200, 0, 0);
     311  cutscw->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
     312  cutarrx = new PIImg1DArrAdapter();
     313  cutarry = new PIImg1DArrAdapter();
     314  PIYfXDrawer * drw;
     315  drw = new PIYfXDrawer(cutarrx, NULL, true);
     316  drw->SetColAtt(PI_Red);
     317  drw->SetMarkerAtt(5, PI_CrossMarker);
     318  drw->SetLineAtt(PI_ThinLine);
     319  cutscw->AddScDrawer(drw, true);
     320  drw = new PIYfXDrawer(cutarry, NULL, true);
     321  drw->SetColAtt(PI_Blue);
     322  drw->SetMarkerAtt(5, PI_TriangleMarker);
     323  drw->SetLineAtt(PI_ThinLine);
     324  cutscw->AddScDrawer(drw, true);
     325  cutscw->SetTitles("Red: X , Blue: Y");
     326  UpdateCuts();
     327  cutwin->Show();
     328  }
     329else {
     330  if (!cutwin)  return;
     331  cutwin->Hide();
     332  delete cutwin;
     333  cutwin = NULL;
     334  cutscw = NULL;
     335  }
    279336}
    280337
     
    392449else mdrw->SetColAtt(PI_White);
    393450PIPixmap::SetColMap(cmp, refr);
     451if (refr) { xcurs =  ycurs = -1; }
    394452if (zow)  zow->SetColMap(cmp, refr);
    395453if (gvw)  gvw->SetColMap(cmp, refr);
     
    425483  char buff[256];
    426484  double x,y;
    427   img->XYCoord(xpav, ypav, x, y);
     485  img->Coord(xpav, ypav, x, y);
    428486  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ",
    429487          x, y , (*img)(xpav, ypav), xpav, ypav );
     
    432490  }
    433491if (zow != NULL)   ComputeZoomPixmap();
     492if (cutwin) UpdateCuts();
    434493if (gvw != NULL)
    435494  if ( (gvw->UserData() != this) || (mw) )  SetGloVPixmap();
     
    456515{
    457516PIPixmap::Draw(g, x0, y0, dx, dy);
     517xcurs = ycurs = -1;
    458518winovis = false;    // $CHECK$ Reza A enlever si possible 17/6/96
    459519if (curshow) {
     
    467527  char buff[256];
    468528  double x,y;
    469   img->XYCoord(xpav, ypav, x, y);
     529  img->Coord(xpav, ypav, x, y);
    470530  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ",
    471531        x, y , (*img)(xpav, ypav), xpav, ypav );
     
    488548    PIDrwTools::SetCurrentBaseWdg(this);
    489549    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
     550    }
     551  else if (key == 'P' || key == 'p') {   // Activation/desactivation affichage curseur
     552    bool sc = !curshow;
     553    ShowCursor(sc);
     554    }
     555  else if (key == 'X' || key == 'x') {   // Activation/desactivation affichage coupes X,Y
     556    bool cut = (cutwin == NULL) ? true : false;
     557    ShowCuts(cut);
    490558    }
    491559// ----  Le copier ----
     
    593661if (curshow)  DrawCursor(mWGrC,-1,-1);
    594662mWGrC->SelGOMode(PI_GOXOR);
    595 if (GetColMapId() == CMAP_COLRJ32)
    596 mWGrC->SelForeground(PI_Yellow);
    597 else mWGrC->SelForeground(PI_Magenta);
     663PIColors xc;
     664if ((GetColMapId() == CMAP_COLRJ32) || (GetColMapId() == CMAP_COLRJ128))  xc = PI_Yellow;
     665else  xc = PI_ColorAllBits1;
     666mWGrC->SelForeground(xc);
    598667mWGrC->SelLine(PI_NormalLine);
    599668if (ustrtw || atrtw) ShowTrTxW();
     
    604673void PIImage::Ptr2Move(int x, int y)
    605674{
    606 int xp, yp;
     675int xp, yp, tmp;
    607676if (img == NULL)  return;
    608677if (xmv0 < 0)  return;
     
    615684 char buff[256]; 
    616685 double x,y;
    617  img->XYCoord(xp, yp, x, y);
     686 img->Coord(xp, yp, x, y);
    618687 sprintf(buff," X= %g , Y= %g  Pix= %g  (C= %d,%d)   ",
    619688         x, y , (*img)(xp, yp),  (xp+xpv0)/2, (yp+ypv0)/2 );
     
    639708xpav = (xpv0+xp2)/2;
    640709ypav = (ypv0+yp2)/2;
    641 xszpav = ((xp2-xpv0) > 0) ? (xp2-xpv0) : 1;
    642 yszpav = ((yp2-ypv0) > 0) ? (yp2-ypv0) : 1;
     710xszpav = xp2-xpv0;
     711yszpav = yp2-ypv0;
     712if (xszpav < 0)  xszpav = -xszpav;
     713if (yszpav < 0)  yszpav = -yszpav;
    643714
    644715Apply(false);
     
    879950
    880951/* --Methode-- */
     952void PIImage::UpdateCuts()
     953{
     954if (!cutwin || !img) return;
     955
     956int hsx, hsy;
     957hsx = XSzPave()/2;
     958hsy = YSzPave()/2;
     959cutarrx->SetData(img, false, 2*hsx+1, XPave(), YPave());
     960cutarry->SetData(img, true, 2*hsy+1, XPave(), YPave());
     961double x1,y1,x2,y2;
     962double xmin, xmax, ymin, ymax;
     963img->Coord(XPave()-hsx, YPave()-hsy, x1, y1);
     964img->Coord(XPave()+hsx, YPave()+hsy, x2, y2);
     965if (x1 < x2)  cutarrx->DefineXCoordinate(-cutarrx->Size()/2, 1.);
     966else   cutarrx->DefineXCoordinate(cutarrx->Size()/2, -1.);
     967if (y1 < y2)  cutarry->DefineXCoordinate(-cutarry->Size()/2, 1.);
     968else   cutarry->DefineXCoordinate(cutarry->Size()/2, -1.);
     969
     970// On calcule les limites :
     971if (cutarrx->Size() > cutarry->Size() ) {
     972  xmax = cutarrx->Size()/2. + 1.;   
     973  xmin = -xmax;
     974}
     975else {
     976  xmax = cutarry->Size()/2. + 1.;   
     977  xmin = -xmax;
     978}
     979 
     980int i;
     981double cv;
     982ymax = ymin = cutarrx->Value(0);
     983for(i=1; i<cutarrx->Size(); i++) {
     984  cv = cutarrx->Value(i);
     985  if (cv < ymin)  ymin = cv;
     986  if (cv > ymax)  ymax = cv;
     987}
     988for(i=0; i<cutarry->Size(); i++) {
     989  cv = cutarry->Value(i);
     990  if (cv < ymin)  ymin = cv;
     991  if (cv > ymax)  ymax = cv;
     992}
     993ymin -= 0.05*(ymax-ymin);
     994ymax += 0.05*(ymax-ymin);
     995cutscw->SetLimits(xmin, xmax, ymin, ymax);
     996//cutscw->UpdateLimits();
     997cutscw->Refresh();
     998//printf("UpdateCuts()-DBG X: %d  -> %g  , Y: %d -> %g \n", cutarrx->Size(), cutarrx->Value(0),
     999//       cutarry->Size(), cutarry->Value(0));
     1000}
     1001
     1002/* --Methode-- */
    8811003void PIImage::DrawCursor(PIGraphic* g)
    8821004{
     
    8871009}
    8881010
    889 #define CURSHSIZE  25
    8901011 
    8911012/* --Methode-- */
     
    8941015
    8951016if (winovis)  return;      // $CHECK$ Reza A enlever si possible 17/6/96
    896 
    897 g->SelGOMode(PI_GOCopy);
    898 if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) ||
    899      (GetColMapId() == CMAP_GREY128) || (GetColMapId() == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
    900 else  g->SelForeground(PI_White);
    901 
    902 if (zoom < 3)  g->SelLine(PI_NormalLine);
    903 else g->SelLine(PI_ThickLine);
    904 
    905 if ((xcurs>=0) && (ycurs>=0) && (g->kind() != PI_PSFileGraphics ) ) {
    906   PIPixmap::Draw(g, xcurs-3, ycurs-CURSHSIZE, 6, CURSHSIZE*2);
    907   PIPixmap::Draw(g, xcurs-CURSHSIZE, ycurs-3, CURSHSIZE*2, 6);
    908 }
     1017//printf("DBG-DrawCursor(g, %d, %d) \n", xc, yc);
     1018int cmapid = cmap->Type();
     1019if ( (xcurs>=0) && (ycurs>=0) ) {
     1020  if (g->kind() == PI_PSFileGraphics ) {
     1021    g->SelGOMode(PI_GOCopy);
     1022    if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
     1023         (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
     1024    else  g->SelForeground(PI_Yellow);
     1025    }
     1026  else  {
     1027    //    g->SelGOMode(PI_GOXOR);
     1028    g->SelGOMode(PI_GOInvert);
     1029    g->SelForeground(cucol);
     1030    }
     1031  g->SelLine(culat);
     1032  //  On efface le curseur precedant ou on le trace ds le postscript
     1033  g->DrawLine(xcurs-cuhsz, ycurs, xcurs-4, ycurs);
     1034  g->DrawLine(xcurs+4, ycurs, xcurs+cuhsz, ycurs);
     1035  g->DrawLine(xcurs, ycurs-cuvsz, xcurs, ycurs-4);
     1036  g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+cuvsz);
     1037  //  printf("DrawCursor/Erase() %d %d - %d %d -> %d %d \n", xcurs, ycurs, cuhsz, cuvsz, xc, yc);
     1038  }
     1039
     1040if (g->kind() == PI_PSFileGraphics )  {
     1041  g->SelLine(PI_NormalLine);
     1042  g->SelForeground(PI_White); 
     1043  return;
     1044  }
     1045
    9091046if ((xc >= 0) && (yc >= 0))
    9101047  {
     1048    //  g->SelGOMode(PI_GOXOR);
     1049  g->SelGOMode(PI_GOInvert);
     1050  // Nouvelle epaisseur de trait du curseur
     1051  if (zoom < -2) culat = PI_ThinLine;
     1052  else if (zoom < 4) culat = PI_NormalLine;
     1053  else culat = PI_ThickLine;
     1054  g->SelLine(culat);
     1055
     1056  // couleur  de trait du curseur
     1057  if ((cmapid == CMAP_COLRJ32) || (cmapid == CMAP_COLRJ128))  cucol = PI_Yellow;
     1058  else  cucol = PI_ColorAllBits1;
     1059  g->SelForeground(cucol);
     1060
     1061  // Nouveau taille du curseur
     1062  cuhsz = xszpav/2;  cuvsz = yszpav/2;
     1063  if (zoom > 0)  { cuhsz = xszpav*zoom/2;  cuvsz = yszpav*zoom/2; }
     1064  else { cuhsz = xszpav/(-zoom*2);  cuvsz = yszpav/(-zoom*2); }
     1065  if ( cuhsz < 10) cuhsz = 10;
     1066  if ( cuvsz < 10) cuvsz = 10;
     1067
    9111068  xcurs = xc;   ycurs = yc;
    912   g->DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs);
    913   g->DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs);
    914   g->DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4);
    915   g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE);
    916   }
    917 else { xcurs = ycurs = -1; }
     1069
     1070  g->DrawLine(xcurs-cuhsz, ycurs, xcurs-4, ycurs);
     1071  g->DrawLine(xcurs+4, ycurs, xcurs+cuhsz, ycurs);
     1072  g->DrawLine(xcurs, ycurs-cuvsz, xcurs, ycurs-4);
     1073  g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+cuvsz);
     1074  //  printf("DrawCursor() %d %d - %d %d \n", xcurs, ycurs, cuhsz, cuvsz);
     1075  }
     1076else {
     1077  xcurs = ycurs = -1; cuhsz = cuvsz = 10;
     1078  cucol = PI_Yellow; culat = PI_NormalLine;
     1079  }
    9181080
    9191081g->SelGOMode(PI_GOCopy);
     
    10491211xpav = offx+xwsz/2;
    10501212ypav = offx+ywsz/2;
    1051 xszpav = ((xwsz+ywsz)/20) ;
     1213xszpav = ((xwsz+ywsz)/15) ;
    10521214if (xszpav < 1) xszpav = 1;
    10531215yszpav = xszpav;
     
    10551217return;
    10561218}
     1219
     1220
     1221//---------------------------------------------------------------------------------
     1222//-------  On definit une classe ArrayAdapter pour les donnees des coupes  --------
     1223//---------------------------------------------------------------------------------
     1224
     1225/* --Methode-- */
     1226PIImage::PIImg1DArrAdapter::PIImg1DArrAdapter() : P1DArrayAdapter(0)
     1227{
     1228data = NULL;
     1229fgay = false;
     1230off1 = off2 = 0;
     1231}
     1232
     1233/* --Methode-- */
     1234void PIImage::PIImg1DArrAdapter::SetData(P2DArrayAdapter* d, bool ax, int sz, int o1, int o2)
     1235{
     1236data = d;
     1237fgay = ax;
     1238if (o1 < 0)  o1 = 0;
     1239if (o2 < 0)  o2 = 0;
     1240if (o1 >= d->XSize()) o1 = d->XSize()-1;
     1241if (o2 >= d->YSize()) o2 = d->YSize()-1;
     1242off1 = o1;
     1243off2 = o2;
     1244if ((sz%2) == 0)  sz++;
     1245if (sz < 0) sz = 1;
     1246mSize = sz;
     1247}
     1248
     1249/* --Methode-- */
     1250double PIImage::PIImg1DArrAdapter::Value(int i)
     1251{
     1252if (!data) return(0.);
     1253int k;
     1254if (fgay) {
     1255  k = off2-mSize/2+i;
     1256  if (k < 0)  k = 0;
     1257  if (k >= data->YSize()) k = data->YSize()-1;
     1258  return((*data)(off1, k));
     1259  }
     1260else {
     1261  k = off1-mSize/2+i;
     1262  if (k < 0)  k = 0;
     1263  if (k >= data->XSize()) k = data->XSize()-1;
     1264  return((*data)(k, off2));
     1265  }
     1266}
  • trunk/SophyaPI/PI/piimage.h

    r204 r292  
    1616#include PIWIN_H
    1717#include "picmapview.h"
     18
     19class PIScDrawWdg;
    1820
    1921class PIImage : public PIPixmap
     
    4547  void ShowInfo(bool si=true);
    4648  void ShowCursor(bool sc=true);
     49
     50  void ShowCuts(bool cuts=true);
    4751
    4852//  Gestion du choix de LUT, facteur d agrandissement, table de couleur
     
    101105  static void SetCurrentPIImage(PIImage* curimg);
    102106
     107//  On definit une classe ArrayAdapter pour les donnees des coupes
     108  class PIImg1DArrAdapter : public P1DArrayAdapter {
     109  public :
     110                     PIImg1DArrAdapter();
     111     virtual double  Value(int i);
     112     virtual void    SetData(P2DArrayAdapter* d, bool ax, int sz, int o1, int o2);
     113  protected :
     114    P2DArrayAdapter* data;
     115    bool fgay;
     116    int off1, off2;
     117  };
     118
    103119protected:
    104120  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     
    107123  void ComputeGloVPixmap();
    108124  void SetGloVPixmap();
     125  void UpdateCuts();
    109126
    110127  void DrawCursor(PIGraphic* g);
     
    154171  int xmv0, ymv0;
    155172  int dxmv, dymv;
    156   int xcurs, ycurs;
     173  int xcurs, ycurs;  // Position curseur
     174  int cuhsz, cuvsz;  // Taille vertical, horizontal curseur
     175  PILineAtt culat;   // Attribut de ligne du curseur 
     176  PIColors cucol;    // Attribut de couleur du curseur
    157177  int xszpav, yszpav;
     178// Pour gerer une fenetre pour les coupes en X,Y
     179  bool hascuts;
     180  PIWindow * cutwin;
     181  PIScDrawWdg * cutscw;
     182  PIImg1DArrAdapter * cutarrx;
     183  PIImg1DArrAdapter * cutarry;
     184
    158185// buffer pour copier-coller
    159186  char* cpbuffer;
    160187  int cpbuflen;
    161 
    162188//  PIImage courante
    163189  static PIImage* cur_piimage;
  • trunk/SophyaPI/PI/piimgtools.cc

    r204 r292  
    2020/* --Methode-- */
    2121PIImgTools::PIImgTools(PIApplication* par)
    22 : PIWindow((PIMsgHandler*)par, "PIImageTools", PIWK_dialog, 240, 240, 150, 150)
     22: PIWindow((PIMsgHandler*)par, "PIImageTools", PIWK_normal, 240, 240, 150, 150)
    2323{
    2424int bsx, bsy, spx, spy;
  • trunk/SophyaPI/PI/pimsghandler.h

    r180 r292  
    44/* Classe de gestion de messages */
    55
     6#include "machdefs.h"
    67#include <stdlib.h>
    78
    8 #include "defs.h"
    99
    1010enum {
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r190 r292  
    7373//      L'action sur le bouton 1 déclenche l'envoi d'un message
    7474//      avec le modifier PIMsg_Click. La position du bouton-press
    75 //      est stocké.
     75//      est stocké. (- Offset affichage)
    7676// int  XPPos()
    77 //      Position X du click
     77//      Position X du click - Offset Affichage pixmap
    7878// int  YPPos()
    79 //      Position Y du click
     79//      Position Y du click - Offset Affichage pixmap
    8080//--
    8181
     
    141141void  PIPixmapGen::But1Press(int x, int y)
    142142{
    143 mPpos[0] = x;  mPpos[1] = y; 
     143mPpos[0] = x-ofx;  mPpos[1] = y-ofy; 
    144144if (Msg())  Send(Msg(), PIMsg_Click, mPpos);
    145145return;
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r211 r292  
    324324  SelPointerShape(cPointer);
    325325  mWGrC->SelLine(cLatt);
    326  
    327   if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
     326
     327  //  Pour rendre le changement de zoom moins delicat $REZA - 05/99$ 
     328  int dxd = xEndDrag-xBegDrag;
     329  if (dxd < 0) dxd = -dxd;
     330  int dyd = yEndDrag-yBegDrag;
     331  if (dyd < 0) dyd = -dyd;
     332  //  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag) // $REZA - 05/99$ 
     333  if ( (dxd < 5) || (dyd < 5) )    // $REZA - 05/99$ 
    328334    SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame );
    329335  else {
     
    362368  mAx = ax;
    363369  mAy = ay;
     370}
     371
     372/* --Methode-- */
     373PIYfXDrawer::~PIYfXDrawer()
     374{
     375  if (mAdDO && mAx)  delete mAx;
     376  if (mAdDO && mAy)  delete mAy;
     377}
     378
     379/* --Methode-- */
     380void PIYfXDrawer::UpdateLimits()
     381{
    364382  if ((mAx == NULL))  mSz = 0;
    365383  else {
     
    367385    else   mSz = (mAx->Size() < mAy->Size()) ? mAx->Size() :  mAy->Size();
    368386    }
    369 }
    370 
    371 /* --Methode-- */
    372 PIYfXDrawer::~PIYfXDrawer()
    373 {
    374   if (mAdDO && mAx)  delete mAx;
    375   if (mAdDO && mAy)  delete mAy;
    376 }
    377 
    378 /* --Methode-- */
    379 void PIYfXDrawer::UpdateLimits()
    380 {
    381387  if (mSz <= 0)  return;
    382388  double xmin, xmax, ymin, ymax;
     
    423429  int i;
    424430
     431  if ((mAx == NULL))  mSz = 0;
     432  else {
     433    if (!mAy)  mSz = mAx->Size();
     434    else   mSz = (mAx->Size() < mAy->Size()) ? mAx->Size() :  mAy->Size();
     435    }
    425436  if (mSz <= 0)  return;
    426437
  • trunk/SophyaPI/PI/piwdgx.cc

    r204 r292  
    592592char **ppc;
    593593if (narg > 0)  { n = narg, ppc = arg; }
    594 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
    595594else { ppc = const_cast<char **>(&pc); n = 1; }
    596 #else
    597 else { ppc = (char **)(&pc); n = 1; }
    598 #endif
    599595//  strncpy(appname, ppc[0], 63); appname[63] = '\0';
    600596strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
    601597//  top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc);
    602 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
    603598top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res), NULL);
    604 #else
    605 top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, (String*)(fallback_res), NULL);
    606 #endif
    607599if (top == NULL) {
    608600  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n");
  • trunk/SophyaPI/PI/piwindowgen.cc

    r80 r292  
    9797  return;
    9898  }
    99 else if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC)
     99else if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC) {
    100100  Hide();   // Action par defaut en cas de MsgClose.
    101 else if (ModMsg(msg) == PIMsg_Active)
    102   Send(Msg(),PIMsg_Active);
    103 
    104 ReSend(msg, sender, data);
     101  ReSend(msg, sender, data);
     102  }
     103else if (ModMsg(msg) == PIMsg_Active) {
     104  ReSend(msg, sender, data);
     105  PIWdg * sndw = dynamic_cast<PIWdg *>(sender);
     106  if (sndw && (sndw->kind() != PIWindowGen::ClassId))  Send(Msg(),PIMsg_Active);
     107  }
     108else ReSend(msg, sender, data);
    105109return; 
    106110}
  • trunk/SophyaPI/PI/piwindowx.cc

    r204 r292  
    154154
    155155// XRaiseWindow est necessaire, sinon la fenetre passe des fois derriere ...
    156 if (mWtyp == PIWK_transient) 
     156//if (mWtyp == PIWK_transient) 
    157157  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
    158158 
  • trunk/SophyaPI/PI/psfile.cc

    r204 r292  
    295295 */
    296296PSFile::PSFile(const char * FileName, double sc)
    297 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
    298297    : mPSFileName(FileName==NULL? "unnamed.eps" : const_cast<char *>(FileName)),
    299 #else
    300     : mPSFileName(FileName==NULL? "unnamed.eps" : (char *)(FileName)),
    301 #endif
    302298      Tw (-1.), Th(-1.),         /* Non specifies pour du eps  */
    303299      WMargin (-1), HMargin(-1), /* Non specifiees en eps  */
     
    360356               PIPaperSize   paperSize,
    361357               double marginX, double marginY)
    362 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
    363358 :  mPSFileName (FileName == NULL ? "unnamed.ps" : const_cast<char *>(FileName)),
    364 #else
    365  :  mPSFileName (FileName == NULL ? "unnamed.ps" : (char *)(FileName)),
    366 #endif
    367359    Tw(PaperSizeTable[paperSize].width),  /* Format papier utilise */
    368360    Th(PaperSizeTable[paperSize].height), /*                       */
  • trunk/SophyaPI/PI/psfile.h

    r204 r292  
    1818 */
    1919
     20#include "machdefs.h"
    2021#include <stdio.h>
    2122#include <stdlib.h>
    22 #include "defs.h"
    2323#ifdef __mac__
    2424#include <stat.h>
Note: See TracChangeset for help on using the changeset viewer.