Index: tags/before-XString-Modif/management/include/G4ViewParameters.hh
===================================================================
--- trunk/source/visualization/management/include/G4ViewParameters.hh	(revision 862)
+++ tags/before-XString-Modif/management/include/G4ViewParameters.hh	(revision 895)
@@ -156,4 +156,6 @@
         G4int            GetWindowSizeHintX      () const;
         G4int            GetWindowSizeHintY      () const;
+        G4int            GetWindowLocationHintX  () const;
+        G4int            GetWindowLocationHintY  () const;
   const G4String&        GetXGeometryString      () const;
   // If non-null, can be interpreted with XParseGeometry (see man
@@ -222,4 +224,5 @@
   void SetMarkerNotHidden      ();
   void SetWindowSizeHint       (G4int xHint, G4int yHint);
+  void SetWindowLocationHint   (G4int xHint, G4int yHint);
   void SetXGeometryString      (const G4String&);
   void SetAutoRefresh          (G4bool);
@@ -270,4 +273,6 @@
   G4int        fWindowSizeHintX; // Size hints for pixel-based window systems.
   G4int        fWindowSizeHintY;
+  G4int        fWindowLocationHintX; // Location hints for pixel-based window systems.
+  G4int        fWindowLocationHintY;
   G4String     fXGeometryString; // If non-null, geometry string for X Windows.
   G4bool       fAutoRefresh;     // ...after change of view parameters.
Index: tags/before-XString-Modif/management/include/G4ViewParameters.icc
===================================================================
--- trunk/source/visualization/management/include/G4ViewParameters.icc	(revision 862)
+++ tags/before-XString-Modif/management/include/G4ViewParameters.icc	(revision 895)
@@ -170,4 +170,18 @@
 }
 
+inline G4int G4ViewParameters::GetWindowLocationHintX () const {
+#ifdef G4DEBUG
+        printf("G4ViewParameters::GetWindowLocationHintX () :: %d\n",fWindowLocationHintX);
+#endif
+  return fWindowLocationHintX;
+}
+
+inline G4int G4ViewParameters::GetWindowLocationHintY () const {
+#ifdef G4DEBUG
+        printf("G4ViewParameters::GetWindowLocationHintY () :: %d\n",fWindowLocationHintY);
+#endif
+  return fWindowLocationHintY;
+}
+
 inline const G4String& G4ViewParameters::GetXGeometryString () const {
   return fXGeometryString;
@@ -328,4 +342,12 @@
 }
 
+inline void G4ViewParameters::SetWindowLocationHint (G4int xHint, G4int yHint) {
+#ifdef G4DEBUG
+        printf("G4ViewParameters::SetWindowLocationHint () :: %d %d\n",xHint,yHint);
+#endif
+  fWindowLocationHintX = xHint;
+  fWindowLocationHintY = yHint;
+}
+
 inline void G4ViewParameters::SetXGeometryString (const G4String& geomString) {
   fXGeometryString = geomString;
Index: tags/before-XString-Modif/management/include/G4VisCommandsViewer.hh
===================================================================
--- trunk/source/visualization/management/include/G4VisCommandsViewer.hh	(revision 862)
+++ tags/before-XString-Modif/management/include/G4VisCommandsViewer.hh	(revision 895)
@@ -138,7 +138,17 @@
   G4VisCommandViewerCreate (const G4VisCommandViewerCreate&);
   G4VisCommandViewerCreate& operator = (const G4VisCommandViewerCreate&);
+  int ParseGeometry ( const char *string, int *x, int *y, unsigned int *width, unsigned int *height);
+  int ReadInteger(char *string, char **NextString);
   G4String NextName ();
   G4UIcommand* fpCommand;
   G4int fId;
+  int NoValue;
+  int XValue;
+  int YValue;
+  int WidthValue;
+  int HeightValue;
+  int AllValues;
+  int XNegative;
+  int YNegative;
 };
 
Index: tags/before-XString-Modif/management/include/G4VisManager.hh
===================================================================
--- trunk/source/visualization/management/include/G4VisManager.hh	(revision 862)
+++ tags/before-XString-Modif/management/include/G4VisManager.hh	(revision 895)
@@ -355,4 +355,5 @@
   void  GetWindowSizeHint (G4int& xHint, G4int& yHint) const;
   // Note: GetWindowSizeHint information is returned via the G4int& arguments.
+  void  GetWindowLocationHint (G4int& xHint, G4int& yHint) const;
   const G4String&              GetXGeometryString          () const;
   // GetXGeometryString is intended to be parsed by XParseGeometry.
@@ -381,4 +382,5 @@
   void              SetVerboseLevel             (Verbosity);
   void              SetWindowSizeHint           (G4int xHint, G4int yHint);
+  void              SetWindowLocationHint           (G4int xHint, G4int yHint);
   void              SetXGeometryString          (const G4String&);
   void              SetEventRefreshing          (G4bool);
@@ -457,4 +459,5 @@
   G4VisStateDependent*  fpStateDependent;   // Friend state dependent class.
   G4int fWindowSizeHintX, fWindowSizeHintY; // For viewer...
+  G4int fWindowLocationHintX, fWindowLocationHintY; // For viewer...
   G4String              fXGeometryString;   // ...construction.
   G4TrajectoriesModel   dummyTrajectoriesModel;  // For passing drawing mode.
Index: tags/before-XString-Modif/management/include/G4VisManager.icc
===================================================================
--- trunk/source/visualization/management/include/G4VisManager.icc	(revision 862)
+++ tags/before-XString-Modif/management/include/G4VisManager.icc	(revision 895)
@@ -78,4 +78,10 @@
 }
 
+inline void G4VisManager::GetWindowLocationHint
+ (G4int& xHint, G4int& yHint) const {
+  xHint = fpViewer->GetViewParameters().GetWindowLocationHintX();
+  yHint = fpViewer->GetViewParameters().GetWindowLocationHintY();
+}
+
 inline const G4String& G4VisManager::GetXGeometryString () const {
   return fXGeometryString;
@@ -118,4 +124,16 @@
 }
 
+inline void G4VisManager::SetWindowLocationHint (G4int xHint, G4int yHint) {
+#ifdef G4DEBUG
+        printf("G4VisManager::SetWindowLocationHint () :: %d %d\n",xHint,yHint);
+#endif
+  G4ViewParameters vp = fpViewer->GetViewParameters();
+  vp.SetWindowLocationHint(xHint,yHint);
+#ifdef G4DEBUG
+        printf("G4VisManager::SetViewParameteres location ()\n");
+#endif
+  fpViewer->SetViewParameters(vp);
+}
+
 inline void G4VisManager::SetXGeometryString (const G4String& geomString) {
   fXGeometryString = geomString;
Index: tags/before-XString-Modif/management/src/G4VViewer.cc
===================================================================
--- trunk/source/visualization/management/src/G4VViewer.cc	(revision 862)
+++ tags/before-XString-Modif/management/src/G4VViewer.cc	(revision 895)
@@ -66,4 +66,7 @@
   pVisMan->GetWindowSizeHint(xHint, yHint);
   const G4String& XGeometryString = pVisMan->GetXGeometryString();
+#ifdef G4DEBUG
+    printf("G4VViewer::G4VViewer set geometry of viewer\n");
+#endif
   fVP.SetWindowSizeHint(xHint,yHint);
   fVP.SetXGeometryString(XGeometryString);
Index: tags/before-XString-Modif/management/src/G4VisCommandsViewer.cc
===================================================================
--- trunk/source/visualization/management/src/G4VisCommandsViewer.cc	(revision 862)
+++ tags/before-XString-Modif/management/src/G4VisCommandsViewer.cc	(revision 895)
@@ -488,5 +488,14 @@
 ////////////// /vis/viewer/create ///////////////////////////////////////
 
-G4VisCommandViewerCreate::G4VisCommandViewerCreate (): fId (0) {
+G4VisCommandViewerCreate::G4VisCommandViewerCreate ():
+  fId (0),
+  NoValue(0x0000),
+  XValue(0x0001),
+  YValue(0x0002),
+  WidthValue(0x0004),
+  HeightValue(0x0008),
+  AllValues(0x000F),
+  XNegative(0x0010),
+  YNegative(0x0020) {
   G4bool omitable;
   fpCommand = new G4UIcommand ("/vis/viewer/create", this);
@@ -636,4 +645,5 @@
   }
 
+
   // Parse windowSizeHintString to extract first field for backwards
   // compatibility...
@@ -641,8 +651,17 @@
   G4int windowSizeHint;
   size_t i;
+#ifdef G4DEBUG
+    printf("G4VisCommandViewerCreate::SetNewValue string\n");
+#endif
   for (i = 0; i < windowSizeHintString.size(); ++i) {
     char c = windowSizeHintString[i];
+#ifdef G4DEBUG
+    printf("%c",c);
+#endif
     if (c == 'x' || c == 'X' || c == '+' || c == '-') break;
   }
+#ifdef G4DEBUG
+    printf("\n");
+#endif
   if (i != windowSizeHintString.size()) {
     // x or X or + or - found - must be a X-Window-type geometry string...
@@ -666,12 +685,47 @@
     windowSizeHintString = ossw.str();
   }
-  fpVisManager->SetWindowSizeHint (windowSizeHint, windowSizeHint);
-  fpVisManager->SetXGeometryString(windowSizeHintString);
   // WindowSizeHint and XGeometryString are picked up from the vis
   // manager in the G4VViewer constructor.  They have to be held by
   // the vis manager until the viewer is contructed - next line...
 
+  ////////
+
+  int x,y = 0;
+  unsigned int w,h = 0;
+
+  int m = ParseGeometry( windowSizeHintString, &x, &y, &w, &h );
+  //  QSize minSize = main_widget->minimumSize();
+  //  QSize maxSize = main_widget->maximumSize();
+  if ( ((m & YValue) == 0) ||
+       ((m & XValue) == 0) ||
+       ((m & HeightValue) == 0 ) ||
+       ((m & WidthValue)  == 0 )) {
+    if (verbosity >= G4VisManager::errors) {
+      G4cout << "ERROR: Unrecognised geometry string \""
+             << windowSizeHintString
+             << "\".  Using 100 for X and Y location."
+             << "\".  Using 600 for Width and Height."
+             << G4endl;
+    }
+    x = 100;
+    y = 100;
+    w = 600;
+    h = 600;
+  }
+
+#ifdef G4DEBUG
+  printf  ("Lecture X:%d Y:%d W:%d H:%d\n",x,y,w,h);
+#endif
+
+
+
   // Create viewer.
   fpVisManager -> CreateViewer (newName);
+
+  // set parameters BEFORE
+  fpVisManager->SetWindowSizeHint (w,h);
+  fpVisManager->SetWindowLocationHint (x,y);
+  fpVisManager->SetXGeometryString(windowSizeHintString);
+
   G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
   if (newViewer && newViewer -> GetName () == newName) {
@@ -1518,2 +1572,131 @@
   SetViewParameters(currentViewer, vp);
 }
+
+/* Keep from :
+ * 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
+ *
+ *    ParseGeometry parses strings of the form
+ *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
+ *   width, height, xoffset, and yoffset are unsigned integers.
+ *   Example:  "=80x24+300-49"
+ *   The equal sign is optional.
+ *   It returns a bitmask that indicates which of the four values
+ *   were actually found in the string. For each value found,
+ *   the corresponding argument is updated;  for each value
+ *   not found, the corresponding argument is left unchanged.
+ */
+
+
+int G4VisCommandViewerCreate::ParseGeometry (
+ const char *string,
+ int *x,
+ int *y,
+ unsigned int *width,
+ unsigned int *height)
+{
+
+  int mask = NoValue;
+  register char *strind;
+  unsigned int tempWidth, tempHeight;
+  int tempX, tempY;
+  char *nextCharacter;
+  if ( (string == NULL) || (*string == '\0')) {
+    return(mask);
+  }
+  if (*string == '=')
+    string++;  /* ignore possible '=' at beg of geometry spec */
+  strind = (char *)string;
+  if (*strind != '+' && *strind != '-' && *strind != 'x') {
+    tempWidth = ReadInteger(strind, &nextCharacter);
+    if (strind == nextCharacter)
+      return (0);
+    strind = nextCharacter;
+    mask |= WidthValue;
+  }
+  if (*strind == 'x' || *strind == 'X') {
+    strind++;
+    tempHeight = ReadInteger(strind, &nextCharacter);
+    if (strind == nextCharacter)
+      return (0);
+    strind = nextCharacter;
+    mask |= HeightValue;
+  }
+
+  if ((*strind == '+') || (*strind == '-')) {
+    if (*strind == '-') {
+      strind++;
+      tempX = -ReadInteger(strind, &nextCharacter);
+      if (strind == nextCharacter)
+        return (0);
+      strind = nextCharacter;
+      mask |= XNegative;
+
+    }
+    else
+      {	strind++;
+        tempX = ReadInteger(strind, &nextCharacter);
+        if (strind == nextCharacter)
+          return(0);
+        strind = nextCharacter;
+      }
+    mask |= XValue;
+    if ((*strind == '+') || (*strind == '-')) {
+      if (*strind == '-') {
+        strind++;
+        tempY = -ReadInteger(strind, &nextCharacter);
+        if (strind == nextCharacter)
+          return(0);
+        strind = nextCharacter;
+        mask |= YNegative;
+      }
+      else
+        {
+          strind++;
+          tempY = ReadInteger(strind, &nextCharacter);
+          if (strind == nextCharacter)
+            return(0);
+          strind = nextCharacter;
+        }
+      mask |= YValue;
+    }
+  }
+  /* If strind isn't at the end of the string the it's an invalid
+     geometry specification. */
+  if (*strind != '\0') return (0);
+  if (mask & XValue)
+    *x = tempX;
+  if (mask & YValue)
+    *y = tempY;
+  if (mask & WidthValue)
+    *width = tempWidth;
+  if (mask & HeightValue)
+    *height = tempHeight;
+  return (mask);
+}
+
+/* Keep from :
+ * 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
+ *
+ */
+int G4VisCommandViewerCreate::ReadInteger(char *string, char **NextString)
+{
+    register int Result = 0;
+    int Sign = 1;
+
+    if (*string == '+')
+	string++;
+    else if (*string == '-')
+    {
+	string++;
+	Sign = -1;
+    }
+    for (; (*string >= '0') && (*string <= '9'); string++)
+    {
+	Result = (Result * 10) + (*string - '0');
+    }
+    *NextString = string;
+    if (Sign >= 0)
+	return (Result);
+    else
+	return (-Result);
+}
Index: tags/before-XString-Modif/management/src/G4VisManager.cc
===================================================================
--- trunk/source/visualization/management/src/G4VisManager.cc	(revision 862)
+++ tags/before-XString-Modif/management/src/G4VisManager.cc	(revision 895)
@@ -199,4 +199,7 @@
 
 void G4VisManager::Initialise () {
+#ifdef G4DEBUG
+  printf("G4VisManager::Initialise\n");
+#endif
 
   if (fVerbosity >= startup) {
@@ -649,10 +652,25 @@
 
 void G4VisManager::CreateViewer (G4String name) {
+#ifdef G4DEBUG
+  printf("G4VisManager::CreateViewer TOP\n");
+#endif
 
   if (!fInitialised) Initialise ();
+#ifdef G4DEBUG
+  printf("G4VisManager::CreateViewer 2\n");
+#endif
 
   if (fpSceneHandler) {
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 3\n");
+#endif
     G4VViewer* p = fpGraphicsSystem -> CreateViewer (*fpSceneHandler, name);
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 4\n");
+#endif
     if (!p) {
+#ifdef G4DEBUG
+      printf("G4VisManager::CreateViewer !p\n");
+#endif
       if (fVerbosity >= errors) {
 	G4cout << "ERROR in G4VisManager::CreateViewer during "
@@ -662,6 +680,15 @@
       }
     } else {
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 5\n");
+#endif
       p -> Initialise ();
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 6\n");
+#endif
       if (p -> GetViewId() < 0) {
+#ifdef G4DEBUG
+        printf("G4VisManager::CreateViewer Id <0\n");
+#endif
 	if (fVerbosity >= errors) {
 	G4cout << "ERROR in G4VisManager::CreateViewer during "
@@ -671,6 +698,15 @@
 	}
       } else {
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 7\n");
+#endif
 	fpViewer = p;                             // Make current.
+#ifdef G4DEBUG
+    printf("G4VisManager::CreateViewer 8\n");
+#endif
 	fpSceneHandler -> AddViewerToList (fpViewer);
+#ifdef G4DEBUG
+  printf("G4VisManager::CreateViewer 9\n");
+#endif
 	fpSceneHandler -> SetCurrentViewer (fpViewer);
 
@@ -680,5 +716,11 @@
 	}
 
+#ifdef G4DEBUG
+  printf("G4VisManager::CreateViewer 10 Read parameters\n");
+#endif
 	const G4ViewParameters& vp = fpViewer->GetViewParameters();
+#ifdef G4DEBUG
+  printf("G4VisManager::CreateViewer 11 END of read Parameters\n");
+#endif
 	if (fVerbosity >= parameters) {
 	  G4cout << " view parameters are:\n  " << vp << G4endl;
@@ -716,4 +758,7 @@
   }
   else PrintInvalidPointers ();
+#ifdef G4DEBUG
+  printf("G4VisManager::END OF CreateViewer\n");
+#endif
 }
 
