Print

Print


Commit in GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd on MAIN
LCDDSubdetector.java+42-61.13 -> 1.14
provide default visualization for layer, slice, module, and module_component objects when vis is not specified in the xml node

GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
LCDDSubdetector.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- LCDDSubdetector.java	22 Feb 2009 00:18:32 -0000	1.13
+++ LCDDSubdetector.java	1 Mar 2009 08:39:01 -0000	1.14
@@ -140,15 +140,36 @@
         }
     }
     
+    /**
+     * Utility method for checking and setting lcdd visualization parameters on a volume.
+     * If the XML node does not have a visualization reference, the volume is turned off 
+     * completely unless it is a detector; the showDaughters attribute is set to true
+     * so that sub-volumes are not turned off even if they have visualization settings.  
+     * Detectors are automatically added to the scene unless specifically turned off with 
+     * visualization settings, so this default does not apply when the XML node is called
+     * <detector>.
+     * 
+     * This method is used extensively by subclasses in their addToLCDD() methods for
+     * assigning visualization attributes to detector envelopes, layer envelopes,
+     * and layer slices.
+     * 
+     * @param lcdd The LCDD structure being built.
+     * @param node The XML node with the possible visualization reference.
+     * @param volume The volume to which visualization is being assigned.
+     */
     public final static void setVisAttributes(LCDD lcdd, Element node, Volume volume)
     {
-    	//System.out.println("vis --> " + node.getAttributeValue("name"));
-    	//System.out.println("    --> " + volume.getAttributeValue("name"));
+    	if (lcdd == null)
+    		throw new IllegalArgumentException("The lcdd object points to null.");
+    	
+    	if (node == null)
+    		throw new IllegalArgumentException("The node object points to null.");
+    	
+    	if (volume == null)
+    		throw new IllegalArgumentException("The volume object points to null.");
     	
         if (node.getAttribute("vis") != null)
-        {
-        	//System.out.println("setting vis");
-        	
+        {      	
             String visref = node.getAttributeValue("vis");
             VisAttributes vis = lcdd.getVisAttributes(visref);
             if (vis != null)
@@ -157,9 +178,24 @@
             }
             else
             {
-                throw new RuntimeException("vis " + visref + " does not exist");
+                throw new RuntimeException("The vis reference " + visref + " does not exist.");
             }
         }
+        else
+        {
+        	// Slices are turned off by default.
+        	if (node.getName().equals("slice"))
+        		volume.setVisAttributes(lcdd.getVisAttributes("InvisibleNoDaughters"));
+        	// Layers are also turned off by default but daughters are left possibly visible.
+        	else if (node.getName().equals("layer"))
+        		volume.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
+        	// Tracker modules are similar to layers.
+        	else if (node.getName().equals("module"))
+        		volume.setVisAttributes(lcdd.getVisAttributes("InvisibleWithDaughters"));
+        	// Tracker module components are turned off by default.
+        	else if (node.getName().equals("module_component"))
+        		volume.setVisAttributes(lcdd.getVisAttributes("InvisibleNoDaughters"));
+        }
     }
     
     public void setAttributes(LCDD lcdd, Element node, Volume volume)
CVSspam 0.2.8