- Timestamp:
- Dec 3, 2008, 5:31:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/management/src/G4VisCommandsViewer.cc
r894 r896 489 489 490 490 G4VisCommandViewerCreate::G4VisCommandViewerCreate (): 491 fId (0), 492 NoValue(0x0000), 493 XValue(0x0001), 494 YValue(0x0002), 495 WidthValue(0x0004), 496 HeightValue(0x0008), 497 AllValues(0x000F), 498 XNegative(0x0010), 499 YNegative(0x0020) { 491 fId (0) 492 { 500 493 G4bool omitable; 501 494 fpCommand = new G4UIcommand ("/vis/viewer/create", this); … … 689 682 // the vis manager until the viewer is contructed - next line... 690 683 691 //////// 692 693 int x,y = 0; 694 unsigned int w,h = 0; 695 696 int m = ParseGeometry( windowSizeHintString, &x, &y, &w, &h ); 697 // QSize minSize = main_widget->minimumSize(); 698 // QSize maxSize = main_widget->maximumSize(); 699 if ( ((m & YValue) == 0) || 700 ((m & XValue) == 0) || 701 ((m & HeightValue) == 0 ) || 702 ((m & WidthValue) == 0 )) { 703 if (verbosity >= G4VisManager::errors) { 704 G4cout << "ERROR: Unrecognised geometry string \"" 705 << windowSizeHintString 706 << "\". Using 100 for X and Y location." 707 << "\". Using 600 for Width and Height." 708 << G4endl; 709 } 710 x = 100; 711 y = 100; 712 w = 600; 713 h = 600; 714 } 715 716 #ifdef G4DEBUG 717 printf ("Lecture X:%d Y:%d W:%d H:%d\n",x,y,w,h); 718 #endif 719 720 721 722 // Create viewer. 723 fpVisManager -> CreateViewer (newName); 724 725 // set parameters BEFORE 726 fpVisManager->SetWindowSizeHint (w,h); 727 fpVisManager->SetWindowLocationHint (x,y); 728 fpVisManager->SetXGeometryString(windowSizeHintString); 684 fpVisManager -> CreateViewer (newName,windowSizeHintString); 729 685 730 686 G4VViewer* newViewer = fpVisManager -> GetCurrentViewer (); … … 1573 1529 } 1574 1530 1575 /* Keep from : 1576 * 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 1577 * 1578 * ParseGeometry parses strings of the form 1579 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where 1580 * width, height, xoffset, and yoffset are unsigned integers. 1581 * Example: "=80x24+300-49" 1582 * The equal sign is optional. 1583 * It returns a bitmask that indicates which of the four values 1584 * were actually found in the string. For each value found, 1585 * the corresponding argument is updated; for each value 1586 * not found, the corresponding argument is left unchanged. 1587 */ 1588 1589 1590 int G4VisCommandViewerCreate::ParseGeometry ( 1591 const char *string, 1592 int *x, 1593 int *y, 1594 unsigned int *width, 1595 unsigned int *height) 1596 { 1597 1598 int mask = NoValue; 1599 register char *strind; 1600 unsigned int tempWidth, tempHeight; 1601 int tempX, tempY; 1602 char *nextCharacter; 1603 if ( (string == NULL) || (*string == '\0')) { 1604 return(mask); 1605 } 1606 if (*string == '=') 1607 string++; /* ignore possible '=' at beg of geometry spec */ 1608 strind = (char *)string; 1609 if (*strind != '+' && *strind != '-' && *strind != 'x') { 1610 tempWidth = ReadInteger(strind, &nextCharacter); 1611 if (strind == nextCharacter) 1612 return (0); 1613 strind = nextCharacter; 1614 mask |= WidthValue; 1615 } 1616 if (*strind == 'x' || *strind == 'X') { 1617 strind++; 1618 tempHeight = ReadInteger(strind, &nextCharacter); 1619 if (strind == nextCharacter) 1620 return (0); 1621 strind = nextCharacter; 1622 mask |= HeightValue; 1623 } 1624 1625 if ((*strind == '+') || (*strind == '-')) { 1626 if (*strind == '-') { 1627 strind++; 1628 tempX = -ReadInteger(strind, &nextCharacter); 1629 if (strind == nextCharacter) 1630 return (0); 1631 strind = nextCharacter; 1632 mask |= XNegative; 1633 1634 } 1635 else 1636 { strind++; 1637 tempX = ReadInteger(strind, &nextCharacter); 1638 if (strind == nextCharacter) 1639 return(0); 1640 strind = nextCharacter; 1641 } 1642 mask |= XValue; 1643 if ((*strind == '+') || (*strind == '-')) { 1644 if (*strind == '-') { 1645 strind++; 1646 tempY = -ReadInteger(strind, &nextCharacter); 1647 if (strind == nextCharacter) 1648 return(0); 1649 strind = nextCharacter; 1650 mask |= YNegative; 1651 } 1652 else 1653 { 1654 strind++; 1655 tempY = ReadInteger(strind, &nextCharacter); 1656 if (strind == nextCharacter) 1657 return(0); 1658 strind = nextCharacter; 1659 } 1660 mask |= YValue; 1661 } 1662 } 1663 /* If strind isn't at the end of the string the it's an invalid 1664 geometry specification. */ 1665 if (*strind != '\0') return (0); 1666 if (mask & XValue) 1667 *x = tempX; 1668 if (mask & YValue) 1669 *y = tempY; 1670 if (mask & WidthValue) 1671 *width = tempWidth; 1672 if (mask & HeightValue) 1673 *height = tempHeight; 1674 return (mask); 1675 } 1676 1677 /* Keep from : 1678 * 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 1679 * 1680 */ 1681 int G4VisCommandViewerCreate::ReadInteger(char *string, char **NextString) 1682 { 1683 register int Result = 0; 1684 int Sign = 1; 1685 1686 if (*string == '+') 1687 string++; 1688 else if (*string == '-') 1689 { 1690 string++; 1691 Sign = -1; 1692 } 1693 for (; (*string >= '0') && (*string <= '9'); string++) 1694 { 1695 Result = (Result * 10) + (*string - '0'); 1696 } 1697 *NextString = string; 1698 if (Sign >= 0) 1699 return (Result); 1700 else 1701 return (-Result); 1702 } 1531
Note: See TracChangeset
for help on using the changeset viewer.