Ignore:
Timestamp:
Dec 3, 2008, 5:31:19 PM (16 years ago)
Author:
garnier
Message:

Modif pour XGeometry complet. Avec debug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/visualization/management/src/G4ViewParameters.cc

    r850 r896  
    3939
    4040G4ViewParameters::G4ViewParameters ():
     41  fNoValue(0x0000),
     42  fXValue(0x0001),
     43  fYValue(0x0002),
     44  fWidthValue(0x0004),
     45  fHeightValue(0x0008),
     46  fAllValues(0x000F),
     47  fXNegative(0x0010),
     48  fYNegative(0x0020),
    4149  fDrawingStyle (wireframe),
    4250  fAuxEdgeVisible (false),
     
    7179  fWindowSizeHintX (600),
    7280  fWindowSizeHintY (600),
     81  fWindowLocationHintX(0),
     82  fWindowLocationHintY(0),
     83  fWindowLocationHintXNegative(true),
     84  fWindowLocationHintYNegative(false),
    7385  fAutoRefresh (false),
    7486  fBackgroundColour (G4Colour(0.,0.,0.)),         // Black
    7587  fPicking (false)
    7688{
     89#ifdef G4DEBUG
     90  printf("G4ViewParameters::Create \n");
     91#endif
    7792  fDefaultMarker.SetScreenSize (5.);
    7893  // Markers are 5 pixels "overall" size, i.e., diameter.
     
    518533  return false;
    519534}
     535
     536
     537void G4ViewParameters::SetXGeometryString (const G4String& geomString) {
     538
     539
     540  G4int x,y = 0;
     541  unsigned int w,h = 0;
     542  G4int m = ParseGeometry( geomString, &x, &y, &w, &h );
     543
     544  // Check errors
     545  if ( ((m & fYValue) == 0) ||
     546       ((m & fXValue) == 0) ||
     547       ((m & fHeightValue) == 0 ) ||
     548       ((m & fWidthValue)  == 0 )) {
     549    G4cout << "ERROR: Unrecognised geometry string \""
     550           << geomString
     551           << "\".  Using default"
     552           << G4endl;
     553  } else {
     554    // Set the string
     555    fXGeometryString = geomString;
     556
     557    // Set values
     558    fWindowSizeHintX = w;
     559    fWindowSizeHintY = h;
     560    fWindowLocationHintX = x;
     561    fWindowLocationHintY = y;
     562    if ( (m & fXNegative) ) {
     563      fWindowLocationHintXNegative = true;
     564    } else {
     565      fWindowLocationHintXNegative = false;
     566    }
     567    if ( (m & fYNegative) ) {
     568      fWindowLocationHintYNegative = true;
     569    } else {
     570      fWindowLocationHintYNegative = false;
     571    }
     572
     573  }
     574
     575}
     576
     577G4int G4ViewParameters::GetWindowAbsoluteLocationHintX (G4int sizeX ) const {
     578#ifdef G4DEBUG
     579  printf("G4ViewParameters::GetWindowLocationHintX () :: %d\n",fWindowLocationHintX);
     580#endif
     581  if ( fWindowLocationHintXNegative ) {
     582    return  sizeX  + fWindowLocationHintX - fWindowSizeHintX;
     583  }
     584  return fWindowLocationHintX;
     585}
     586
     587G4int G4ViewParameters::GetWindowAbsoluteLocationHintY (G4int sizeY ) const {
     588#ifdef G4DEBUG
     589  printf("G4ViewParameters::GetWindowLocationHintY () :: %d\n",fWindowLocationHintY);
     590#endif
     591  if (  fWindowLocationHintYNegative ) {
     592    return  sizeY  + fWindowLocationHintY - fWindowSizeHintY;
     593  }
     594  return fWindowLocationHintY;
     595}
     596
     597/* Keep from :
     598 * ftp://ftp.trolltech.com/qt/source/qt-embedded-free-3.0.6.tar.gz/qt-embedded-free-3.0.6/src/kernel/qapplication_qws.cpp
     599 *
     600 *    ParseGeometry parses strings of the form
     601 *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
     602 *   width, height, xoffset, and yoffset are unsigned integers.
     603 *   Example:  "=80x24+300-49"
     604 *   The equal sign is optional.
     605 *   It returns a bitmask that indicates which of the four values
     606 *   were actually found in the string. For each value found,
     607 *   the corresponding argument is updated;  for each value
     608 *   not found, the corresponding argument is left unchanged.
     609 */
     610
     611int G4ViewParameters::ParseGeometry (
     612 const char *string,
     613 G4int *x,
     614 G4int *y,
     615 unsigned int *width,
     616 unsigned int *height)
     617{
     618
     619  G4int mask = fNoValue;
     620  register char *strind;
     621  unsigned int tempWidth, tempHeight;
     622  G4int tempX, tempY;
     623  char *nextCharacter;
     624  if ( (string == NULL) || (*string == '\0')) {
     625    return(mask);
     626  }
     627  if (*string == '=')
     628    string++;  /* ignore possible '=' at beg of geometry spec */
     629  strind = (char *)string;
     630  if (*strind != '+' && *strind != '-' && *strind != 'x') {
     631    tempWidth = ReadInteger(strind, &nextCharacter);
     632    if (strind == nextCharacter)
     633      return (0);
     634    strind = nextCharacter;
     635    mask |= fWidthValue;
     636  }
     637  if (*strind == 'x' || *strind == 'X') {
     638    strind++;
     639    tempHeight = ReadInteger(strind, &nextCharacter);
     640    if (strind == nextCharacter)
     641      return (0);
     642    strind = nextCharacter;
     643    mask |= fHeightValue;
     644  }
     645
     646  if ((*strind == '+') || (*strind == '-')) {
     647    if (*strind == '-') {
     648      strind++;
     649      tempX = -ReadInteger(strind, &nextCharacter);
     650      if (strind == nextCharacter)
     651        return (0);
     652      strind = nextCharacter;
     653      mask |= fXNegative;
     654
     655    }
     656    else
     657      { strind++;
     658        tempX = ReadInteger(strind, &nextCharacter);
     659        if (strind == nextCharacter)
     660          return(0);
     661        strind = nextCharacter;
     662      }
     663    mask |= fXValue;
     664    if ((*strind == '+') || (*strind == '-')) {
     665      if (*strind == '-') {
     666        strind++;
     667        tempY = -ReadInteger(strind, &nextCharacter);
     668        if (strind == nextCharacter)
     669          return(0);
     670        strind = nextCharacter;
     671        mask |= fYNegative;
     672      }
     673      else
     674        {
     675          strind++;
     676          tempY = ReadInteger(strind, &nextCharacter);
     677          if (strind == nextCharacter)
     678            return(0);
     679          strind = nextCharacter;
     680        }
     681      mask |= fYValue;
     682    }
     683  }
     684  /* If strind isn't at the end of the string the it's an invalid
     685     geometry specification. */
     686  if (*strind != '\0') return (0);
     687  if (mask & fXValue)
     688    *x = tempX;
     689  if (mask & fYValue)
     690    *y = tempY;
     691  if (mask & fWidthValue)
     692    *width = tempWidth;
     693  if (mask & fHeightValue)
     694    *height = tempHeight;
     695  return (mask);
     696}
     697
     698/* Keep from :
     699 * ftp://ftp.trolltech.com/qt/source/qt-embedded-free-3.0.6.tar.gz/qt-embedded-free-3.0.6/src/kernel/qapplication_qws.cpp
     700 *
     701 */
     702G4int G4ViewParameters::ReadInteger(char *string, char **NextString)
     703{
     704    register G4int Result = 0;
     705    G4int Sign = 1;
     706
     707    if (*string == '+')
     708        string++;
     709    else if (*string == '-')
     710    {
     711        string++;
     712        Sign = -1;
     713    }
     714    for (; (*string >= '0') && (*string <= '9'); string++)
     715    {
     716        Result = (Result * 10) + (*string - '0');
     717    }
     718    *NextString = string;
     719    if (Sign >= 0)
     720        return (Result);
     721    else
     722        return (-Result);
     723}
     724   
Note: See TracChangeset for help on using the changeset viewer.