diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/BaseToolPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/BaseToolPanel.java
index ce85b687e..667a1e0bd 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/BaseToolPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/BaseToolPanel.java
@@ -67,187 +67,232 @@
import org.opensim.view.pub.OpenSimDB;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public abstract class BaseToolPanel extends JPanel implements ActionListener, Observer {
-
- private FileFilter settingsFilter = null;
-
- protected JButton loadSettingsButton = new JButton("Load...");
- protected JButton saveSettingsButton = new JButton("Save...");
- protected JButton applyButton = new JButton("Run");
- protected JButton okButton = new JButton("Close");
- //protected JButton cancelButton = new JButton("Cancel");
- protected JButton helpButton = new JButton("Help");
- protected Dialog ownerDialog = null;
- protected boolean cleanupAfterExecuting = false; // Keep track if cleaning up needs to be done on execution finish vs. dialog close
-
- static String stripOuterTags(String nmsmFilename) {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = dbf.newDocumentBuilder();
- FileInputStream fis = new FileInputStream(nmsmFilename);
-
- Document doc = builder.parse(new File(nmsmFilename));
- InputSource is = new InputSource(fis);
- // get the first element
- Element element = doc.getDocumentElement();
-
- // get all child nodes
- NodeList nodes = element.getChildNodes();
- int lastDotLocation = nmsmFilename.lastIndexOf(".");
- String extension="";
- if (lastDotLocation!=-1)
- extension = nmsmFilename.substring(lastDotLocation);
- String osimFile = nmsmFilename.replace(extension, "osim"+extension);
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- DOMSource source = new DOMSource(nodes.item(1));
- FileWriter writer = new FileWriter(new File(osimFile));
- StreamResult result = new StreamResult(writer);
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.transform(source, result);
- writer.flush();
- writer.close();
-
- return osimFile;
- } catch (ParserConfigurationException ex) {
- Exceptions.printStackTrace(ex);
- } catch (FileNotFoundException ex) {
- Exceptions.printStackTrace(ex);
- } catch (SAXException ex) {
- Exceptions.printStackTrace(ex);
- } catch (IOException ex) {
- Exceptions.printStackTrace(ex);
- } catch (TransformerConfigurationException ex) {
- Exceptions.printStackTrace(ex);
- } catch (TransformerException ex) {
- Exceptions.printStackTrace(ex);
- }
- return "";
- }
-
- //------------------------------------------------------------------------
- // Load/Save Settings Actions
- //------------------------------------------------------------------------
- class LoadSettingsAction extends AbstractAction {
- public LoadSettingsAction() { super("Load Settings..."); }
- public void actionPerformed(ActionEvent evt) {
- String fileName = FileUtils.getInstance().browseForFilename(settingsFilter);
- if(fileName!=null) loadSettings(fileName);
- }
- }
- class SaveSettingsAction extends AbstractAction {
- public SaveSettingsAction() { super("Save Settings..."); }
- public void actionPerformed(ActionEvent evt) {
- String fileName = FileUtils.getInstance().browseForFilenameToSave(settingsFilter, true, "", null);
- if(fileName!=null) saveSettings(fileName, getToolXML());
- }
- }
-
- public BaseToolPanel() {
-
- loadSettingsButton.addActionListener(new LoadSettingsAction());
- saveSettingsButton.addActionListener(new SaveSettingsAction());
- applyButton.setEnabled(false);
- OpenSimDB.getInstance().addObserver(this);
- }
-
- public void setSettingsFileDescription(String description) {
- settingsFilter = FileUtils.getFileFilter(".xml", description);
- }
-
- //------------------------------------------------------------------------
- // Override in derived classes
- //------------------------------------------------------------------------
- public void loadSettings(String fileName) {
-
- }
- public void saveSettings(String fileName, String contents) {
- String fullFilename = FileUtils.addExtensionIfNeeded(fileName, ".xml");
- OpenSimObject.setSerializeAllDefaults(true);
- //String toolFileContent = jointPersonalizationToolModel.getToolAsObject().dump();
- BufferedWriter writer;
+
+ private FileFilter settingsFilter = null;
+
+ protected JButton loadSettingsButton = new JButton("Load...");
+ protected JButton saveSettingsButton = new JButton("Save...");
+ protected JButton applyButton = new JButton("Run");
+ protected JButton okButton = new JButton("Close");
+ //protected JButton cancelButton = new JButton("Cancel");
+ protected JButton helpButton = new JButton("Help");
+ protected Dialog ownerDialog = null;
+ protected boolean cleanupAfterExecuting = false; // Keep track if cleaning up needs to be done on execution finish vs. dialog close
+
+ static String stripOuterTags(String nmsmFilename) {
try {
- writer = new BufferedWriter(new FileWriter(fullFilename));
- writer.write("\n");
- writer.write(contents);
- writer.write("");
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ FileInputStream fis = new FileInputStream(nmsmFilename);
+
+ Document doc = builder.parse(new File(nmsmFilename));
+ InputSource is = new InputSource(fis);
+ // get the first element
+ Element element = doc.getDocumentElement();
+
+ // get all child nodes
+ NodeList nodes = element.getChildNodes();
+ int lastDotLocation = nmsmFilename.lastIndexOf(".");
+ String extension = "";
+ if (lastDotLocation != -1) {
+ extension = nmsmFilename.substring(lastDotLocation);
+ }
+ String osimFile = nmsmFilename.replace(extension, "osim" + extension);
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ DOMSource source = new DOMSource(nodes.item(1));
+ FileWriter writer = new FileWriter(new File(osimFile));
+ StreamResult result = new StreamResult(writer);
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.transform(source, result);
+ writer.flush();
writer.close();
+
+ return osimFile;
+ } catch (ParserConfigurationException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (FileNotFoundException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (SAXException ex) {
+ Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
+ } catch (TransformerConfigurationException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (TransformerException ex) {
+ Exceptions.printStackTrace(ex);
}
- }
- public void pressedCancel() {}
- public void pressedClose() {}
- public void pressedApply() {}
-
- //------------------------------------------------------------------------
- // Dialog Operations
- //------------------------------------------------------------------------
- public JButton[] getDialogOptions() {
- return new JButton[]{loadSettingsButton, saveSettingsButton, okButton, helpButton};
- }
-
- public void setOwner(Dialog window) { ownerDialog = window; }
-
- public void updateApplyButton(boolean applyEnabled) {
- applyButton.setEnabled(applyEnabled);
- }
-
- public void actionPerformed(ActionEvent evt) {
- if(evt.getSource() == okButton) {
- pressedClose();
- ownerDialog.dispose();
- } else if(evt.getSource() == applyButton) {
- pressedApply();
- }
- }
-
- //------------------------------------------------------------------------
- // Helper function to create dialog
- //------------------------------------------------------------------------
- public static void openToolDialog(final BaseToolPanel panel, String name) {
- DialogDescriptor dlg = new DialogDescriptor(panel, name, false, panel);
- dlg.setOptions(panel.getDialogOptions());
- Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg);
- panel.setOwner(dialog);
- dialog.setVisible(true);
- dialog.requestFocus();
- //JFrame toolFrame = DialogUtils.createFrameForPanel(panel, name);
- //DialogUtils.addButtons(toolFrame, (JButton[]) panel.getDialogOptions(), panel);
- //panel.setOwner(toolFrame);
- //toolFrame.setVisible(true);
- dialog.requestFocus();
- dialog.addWindowListener(new WindowAdapter(){
- public void windowClosed(WindowEvent e) {
- super.windowClosed(e);
- panel.cleanup();
- OpenSimDB.getInstance().deleteObserver(panel);
- }
-
- public void windowClosing(WindowEvent e) {
- super.windowClosing(e);
- panel.cleanup();
- OpenSimDB.getInstance().deleteObserver(panel);
- }
- });
- }
- // Relinquish C++ resources by setting references to them to null
- public void cleanup()
- {
- // If tool is still running don't do any cleanup until the tool is done otherwise cleanup now
- // by freeing C++ allocated resources.
- }
-
- public void close()
- {
- pressedCancel();
- OpenSimDB.getInstance().deleteObserver(this);
- ownerDialog.dispose();
- }
-
- abstract String getToolXML();
+ return "";
+ }
+
+ static void replaceOpenSimDocumentTags(String pathName) {
+ try {
+ File inputFile = new File(pathName);
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(inputFile);
+ //doc.getDocumentElement().normalize();
+ NodeList nodeList = doc.getElementsByTagName("OpenSimDocument");
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node oldNode = nodeList.item(i);
+ Element element = (Element) oldNode;
+ if (element != null) { element.setAttribute("Version", "1.0.0"); }
+ doc.renameNode(oldNode, oldNode.getNamespaceURI(), "NMSMPipelineDocument");
+ }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(inputFile);
+ transformer.transform(source, result);
+ } catch (ParserConfigurationException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (TransformerConfigurationException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (TransformerException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (SAXException ex) {
+ Exceptions.printStackTrace(ex);
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+ //------------------------------------------------------------------------
+ // Load/Save Settings Actions
+ //------------------------------------------------------------------------
+ // Override this method to change behavior of writing properties only if different from default
+ // Per issue #40 https://github.com/aymanhab/opensim-gui-rcnl/issues/40
+ void forceWritableProperties(OpenSimObject dObject) {
+ }
+
+ class LoadSettingsAction extends AbstractAction {
+
+ public LoadSettingsAction() {
+ super("Load Settings...");
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ String fileName = FileUtils.getInstance().browseForFilename(settingsFilter);
+ if (fileName != null) {
+ loadSettings(fileName);
+ }
+ }
+ }
+
+ class SaveSettingsAction extends AbstractAction {
+
+ public SaveSettingsAction() {
+ super("Save Settings...");
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ String fileName = FileUtils.getInstance().browseForFilenameToSave(settingsFilter, true, "", null);
+ if (fileName != null) {
+ saveSettings(fileName);
+ }
+ }
+ }
+
+ public BaseToolPanel() {
+
+ loadSettingsButton.addActionListener(new LoadSettingsAction());
+ saveSettingsButton.addActionListener(new SaveSettingsAction());
+ applyButton.setEnabled(false);
+ OpenSimDB.getInstance().addObserver(this);
+ }
+
+ public void setSettingsFileDescription(String description) {
+ settingsFilter = FileUtils.getFileFilter(".xml", description);
+ }
+
+ //------------------------------------------------------------------------
+ // Override in derived classes
+ //------------------------------------------------------------------------
+ public void loadSettings(String fileName) {
+
+ }
+
+ abstract void saveSettings(String fileName) ;
+
+ public void pressedCancel() {
+ }
+
+ public void pressedClose() {
+ }
+
+ public void pressedApply() {
+ }
+
+ //------------------------------------------------------------------------
+ // Dialog Operations
+ //------------------------------------------------------------------------
+ public JButton[] getDialogOptions() {
+ return new JButton[]{loadSettingsButton, saveSettingsButton, okButton, helpButton};
+ }
+
+ public void setOwner(Dialog window) {
+ ownerDialog = window;
+ }
+
+ public void updateApplyButton(boolean applyEnabled) {
+ applyButton.setEnabled(applyEnabled);
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ if (evt.getSource() == okButton) {
+ pressedClose();
+ ownerDialog.dispose();
+ } else if (evt.getSource() == applyButton) {
+ pressedApply();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ // Helper function to create dialog
+ //------------------------------------------------------------------------
+ public static void openToolDialog(final BaseToolPanel panel, String name) {
+ DialogDescriptor dlg = new DialogDescriptor(panel, name, false, panel);
+ dlg.setOptions(panel.getDialogOptions());
+ Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg);
+ panel.setOwner(dialog);
+ dialog.setVisible(true);
+ dialog.requestFocus();
+ //JFrame toolFrame = DialogUtils.createFrameForPanel(panel, name);
+ //DialogUtils.addButtons(toolFrame, (JButton[]) panel.getDialogOptions(), panel);
+ //panel.setOwner(toolFrame);
+ //toolFrame.setVisible(true);
+ dialog.requestFocus();
+ dialog.addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent e) {
+ super.windowClosed(e);
+ panel.cleanup();
+ OpenSimDB.getInstance().deleteObserver(panel);
+ }
+
+ public void windowClosing(WindowEvent e) {
+ super.windowClosing(e);
+ panel.cleanup();
+ OpenSimDB.getInstance().deleteObserver(panel);
+ }
+ });
+ }
+ // Relinquish C++ resources by setting references to them to null
+
+ public void cleanup() {
+ // If tool is still running don't do any cleanup until the tool is done otherwise cleanup now
+ // by freeing C++ allocated resources.
+ }
+
+ public void close() {
+ pressedCancel();
+ OpenSimDB.getInstance().deleteObserver(this);
+ ownerDialog.dispose();
+ }
+
}
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties
index 312cad212..a8be4abab 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties
@@ -181,12 +181,12 @@ TreatmentOptimizationJPanel.jRCNLTorqueControllerPanel.border.title=RCNL Torque
TreatmentOptimizationJPanel.jLabel2.text=Surrogate model data directory
TreatmentOptimizationJPanel.jCoordinatesListPanel3.border.title=Coordinate List
TreatmentOptimizationJPanel.jSynergyControllerDetailsPanel1.border.title=RCNL Synergy Controller
-TreatmentOptimizationJPanel.jControllersPanel.TabConstraints.tabTitle=RCNL Controllers
+TreatmentOptimizationJPanel.jControllersPanel.TabConstraints.tabTitle=RCNL Controllers
TreatmentOptimizationJPanel.jLabel6.text=Tracked Quantities Dir:
TreatmentOptimizationJPanel.jLabel8.text=Optimal Control Solver Settings File:
TreatmentOptimizationJPanel.jLabel5.text=Results Dir:
TreatmentOptimizationJPanel.outputPanel.border.title=Output
-TreatmentOptimizationJPanel.inputOutputPanel.TabConstraints.tabTitle=Settings
+TreatmentOptimizationJPanel.inputOutputPanel.TabConstraints.tabTitle=Settings
TreatmentOptimizationJPanel.jLabel4.text=Initial Guess Dir:
TreatmentOptimizationJPanel.jLabel3.text=Osimx File:
TreatmentOptimizationJPanel.currentModelFileTextField.toolTipText=Current Model in GUI
@@ -214,3 +214,5 @@ EditCostTermJPanel.jErrorCenterTextField.text=0.
EditCosnstraintTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
EditCosnstraintTermJPanel.jMaxErrorTextField.text=0
EditCosnstraintTermJPanel.jMinErrorTextField.text=0
+SelectQuantitiesFromListJPanel.jSelectAllCheckBox.toolTipText=select all shown quantities
+SelectQuantitiesFromListJPanel.jSelectAllCheckBox.text=select all shown
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ComponentTableModel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ComponentTableModel.java
index a97790d14..941cf12d6 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ComponentTableModel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ComponentTableModel.java
@@ -117,5 +117,12 @@ void restrictNamesBy(String pattern){
fireTableDataChanged();
}
+
+ void selectShown() {
+ for (int q=0; q
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -55,9 +50,10 @@
-
+
+
@@ -130,9 +126,9 @@
-
+
-
+
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java
index 2aaf915af..1dd90989e 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java
@@ -136,9 +136,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jComponentListPanelLayout.setHorizontalGroup(
jComponentListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jComponentListPanelLayout.createSequentialGroup()
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 780, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 559, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(editComonentListButton)
+ .addComponent(editComonentListButton, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jComponentListPanelLayout.setVerticalGroup(
@@ -216,24 +216,21 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jComponentListPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jEnabledCheckBox)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel11)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(131, 131, 131)
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jErrorCenterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addContainerGap())
+ .addComponent(jComponentListPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jEnabledCheckBox)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel11)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(131, 131, 131)
+ .addComponent(jLabel3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jErrorCenterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -244,7 +241,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCostTermNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
+ .addGap(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/GCPPersonalizationJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/GCPPersonalizationJPanel.java
index d8193e138..daa538eaf 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/GCPPersonalizationJPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/GCPPersonalizationJPanel.java
@@ -417,14 +417,9 @@ public void pressedCancel() {
super.pressedCancel(); //To change body of generated methods, choose Tools | Templates.
}
- @Override
- String getToolXML() {
- return gcpPersonalizationToolModel.getToolAsObject().dump();
- }
-
@Override
public void loadSettings(String nmsmFilename) {
- String fileName = super.stripOuterTags(nmsmFilename);
+ String fileName = BaseToolPanel.stripOuterTags(nmsmFilename);
Model model = OpenSimDB.getInstance().getCurrentModel();
//if(model==null) throw new IOException("JointPersonalizationJPanel got null model");
gcpPersonalizationToolModel = new GCPPersonalizationToolModel(model, fileName);
@@ -453,9 +448,8 @@ public void setSettingsFileDescription(String description) {
}
@Override
- public void saveSettings(String fileName, String contents) {
+ public void saveSettings(String fileName) {
- String adjustedContents = contents;
// Before saving the settings, we need to make motion file and grf file relative to input_directory
String inputDir = gcpPersonalizationToolModel.getDataDir();
String saveInputMotion = gcpPersonalizationToolModel.getInputMotionFile();
@@ -469,10 +463,11 @@ public void saveSettings(String fileName, String contents) {
String relativeGRFFile = FileUtils.makePathRelative(saveGRFfile, inputDir);
if (relativeGRFFile != null)
gcpPersonalizationToolModel.setInputGRFFile(relativeGRFFile);
- adjustedContents = getToolXML();
}
// Set proprties from relative path
- super.saveSettings(fileName, adjustedContents); //To change body of generated methods, choose Tools | Templates.
+ String fullFilename = FileUtils.addExtensionIfNeeded(fileName, ".xml");
+ gcpPersonalizationToolModel.getToolAsObject().print(fullFilename);
+ replaceOpenSimDocumentTags(fullFilename);
// Restore from model
gcpPersonalizationToolModel.setInputMotionFile(saveInputMotion);
gcpPersonalizationToolModel.setInputGRFFile(saveGRFfile);
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/JointPersonalizationJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/JointPersonalizationJPanel.java
index 65db1de2c..e0eaf57b3 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/JointPersonalizationJPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/JointPersonalizationJPanel.java
@@ -304,13 +304,17 @@ public void pressedCancel() {
}
@Override
- public String getToolXML() {
- return jointPersonalizationToolModel.getToolAsObject().dump();
+ public void saveSettings(String fileName) {
+ String fullFilename = FileUtils.addExtensionIfNeeded(fileName, ".xml");
+ OpenSimObject obj = jointPersonalizationToolModel.getToolAsObject();
+ forceWritableProperties(obj);
+ obj.print(fullFilename);
+ replaceOpenSimDocumentTags(fullFilename);
}
@Override
public void loadSettings(String nmsmFilename) {
- String fileName = super.stripOuterTags(nmsmFilename);
+ String fileName = BaseToolPanel.stripOuterTags(nmsmFilename);
Model model = OpenSimDB.getInstance().getCurrentModel();
//if(model==null) throw new IOException("JointPersonalizationJPanel got null model");
jointPersonalizationToolModel = new JointPersonalizationToolModel(model, fileName);
@@ -331,6 +335,24 @@ public void setSettingsFileDescription(String description) {
super.setSettingsFileDescription(description); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
+ void forceWritableProperties(OpenSimObject dObject) {
+ super.forceWritableProperties(dObject); //To change body of generated methods, choose Tools | Templates.
+ // For each JMPTask in tasklist, force write of parent_frame_transformation, child_frame_transformation
+ // dObject is an instance of JointModelPersonalizationTool
+ AbstractProperty ap = dObject.getPropertyByName("JMPTaskList");
+ PropertyObjectList olist = PropertyObjectList.getAs(ap);
+ for (int i=0; i< olist.size(); i++){
+ OpenSimObject ithTask = olist.getValue(i);
+ AbstractProperty apJnts = ithTask.getPropertyByName("JMPJointSet");
+ PropertyObjectList poJointList = PropertyObjectList.updAs(apJnts);
+ for (int j=0; j
-
-
-
-
-
-
+
+
+
+
@@ -35,14 +33,9 @@
-
-
-
-
-
-
-
-
+
+
+
@@ -56,7 +49,10 @@
-
+
+
+
+
@@ -67,7 +63,13 @@
-
+
+
+
+
+
+
+
@@ -87,24 +89,45 @@
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/SelectQuantitiesFromListJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/SelectQuantitiesFromListJPanel.java
index 0955b1b60..7c31a73e9 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/SelectQuantitiesFromListJPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/SelectQuantitiesFromListJPanel.java
@@ -6,6 +6,7 @@
package org.opensim.rcnl;
import java.util.ArrayList;
+import javax.swing.JCheckBox;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelListener;
@@ -55,10 +56,16 @@ private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
+ jSelectAllCheckBox = new javax.swing.JCheckBox();
+
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jLabel1.text")); // NOI18N
FilterTextField.setToolTipText(org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.FilterTextField.toolTipText")); // NOI18N
+ jTable1.setModel(tableModel);
+ jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
+ jScrollPane1.setViewportView(jTable1);
+
javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
jPanel.setLayout(jPanelLayout);
jPanelLayout.setHorizontalGroup(
@@ -66,7 +73,9 @@ private void initComponents() {
.addGroup(jPanelLayout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE))
+ .addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
+ .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE))
);
jPanelLayout.setVerticalGroup(
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -74,12 +83,22 @@ private void initComponents() {
.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(FilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(0, 0, Short.MAX_VALUE))
+ .addGap(433, 433, 433))
+ .addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelLayout.createSequentialGroup()
+ .addGap(0, 52, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
- jTable1.setModel(tableModel);
- jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
- jScrollPane1.setViewportView(jTable1);
+ org.openide.awt.Mnemonics.setLocalizedText(jSelectAllCheckBox, org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jSelectAllCheckBox.text")); // NOI18N
+ jSelectAllCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jSelectAllCheckBox.toolTipText")); // NOI18N
+ jSelectAllCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ jSelectAllCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ jSelectAllCheckBox.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jSelectAllCheckBoxActionPerformed(evt);
+ }
+ });
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -89,32 +108,43 @@ private void initComponents() {
.addContainerGap()
.addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
- .addContainerGap()))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(9, 9, 9)
+ .addComponent(jSelectAllCheckBox)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(268, Short.MAX_VALUE))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(73, 73, 73)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jSelectAllCheckBox)
+ .addGap(12, 12, 12))
);
}// //GEN-END:initComponents
+ private void jSelectAllCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectAllCheckBoxActionPerformed
+// tableModel.selectShown(true);
+// updateSelected();
+ ((JCheckBox)evt.getSource()).setSelected(false);
+ if (tableModel instanceof MuscleGroupTableModel)
+ ((MuscleGroupTableModel) tableModel).selectShown();
+ else if (tableModel instanceof CoordinateTableModel)
+ ((CoordinateTableModel) tableModel).selectShown();
+ else if (tableModel instanceof ComponentTableModel)
+ ((ComponentTableModel) tableModel).selectShown();
+
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jSelectAllCheckBoxActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JFormattedTextField FilterTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel;
private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JCheckBox jSelectAllCheckBox;
private javax.swing.JTable jTable1;
// End of variables declaration//GEN-END:variables
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form
index 30f4fa0c5..3819a82c4 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form
@@ -91,7 +91,7 @@
-
+
@@ -111,7 +111,7 @@
-
+
@@ -174,7 +174,7 @@
-
+
@@ -243,7 +243,7 @@
-
+
@@ -297,6 +297,9 @@
+
+
+
@@ -327,17 +330,9 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -442,7 +437,7 @@
-
+
@@ -451,7 +446,7 @@
-
+
@@ -499,7 +494,7 @@
-
+
@@ -524,7 +519,7 @@
-
+
@@ -578,7 +573,7 @@
-
+
@@ -609,7 +604,7 @@
-
+
@@ -691,7 +686,7 @@
-
+
@@ -827,7 +822,7 @@
-
+
@@ -847,7 +842,7 @@
-
+
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java
index b23aa4023..29bd80e13 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java
@@ -6,6 +6,8 @@
package org.opensim.rcnl;
import java.awt.Dialog;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
import java.io.IOException;
import java.util.Observable;
import java.util.Observer;
@@ -13,12 +15,15 @@
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import javax.swing.filechooser.FileFilter;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
+import org.openide.util.Exceptions;
import org.opensim.modeling.AbstractProperty;
import org.opensim.modeling.Model;
import org.opensim.modeling.OpenSimObject;
import org.opensim.modeling.PropertyObjectList;
+import org.opensim.utils.FileUtils;
import org.opensim.view.pub.OpenSimDB;
/**
@@ -222,11 +227,11 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(outputDirPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(13, 13, 13)))
+ .addGap(0, 0, 0)))
);
outputPanelLayout.setVerticalGroup(
outputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 69, Short.MAX_VALUE)
+ .addGap(0, 95, Short.MAX_VALUE)
.addGroup(outputPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(outputPanelLayout.createSequentialGroup()
.addContainerGap()
@@ -252,6 +257,11 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
buttonGroup1.add(jRadioButton2);
org.openide.awt.Mnemonics.setLocalizedText(jRadioButton2, org.openide.util.NbBundle.getMessage(TreatmentOptimizationJPanel.class, "TreatmentOptimizationJPanel.jRadioButton2.text")); // NOI18N
+ jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jRadioButton2ActionPerformed(evt);
+ }
+ });
javax.swing.GroupLayout jSolverSettingsPanelLayout = new javax.swing.GroupLayout(jSolverSettingsPanel);
jSolverSettingsPanel.setLayout(jSolverSettingsPanelLayout);
@@ -272,7 +282,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
.addComponent(jRadioButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(solverSettingsFilePath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
- .addContainerGap())
+ .addGap(0, 0, 0))
);
jSolverSettingsPanelLayout.setVerticalGroup(
jSolverSettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -333,16 +343,14 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(inputModelPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(inputModelPanelLayout.createSequentialGroup()
- .addGroup(inputModelPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(inputModelPanelLayout.createSequentialGroup()
- .addComponent(osimxFilePath, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
- .addGap(3, 3, 3))
- .addComponent(trackedQuantitiesDirPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(InitialGuessDirPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
+ .addComponent(osimxFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, 708, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(trackedQuantitiesDirPath, javax.swing.GroupLayout.PREFERRED_SIZE, 711, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(InitialGuessDirPath, javax.swing.GroupLayout.PREFERRED_SIZE, 711, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(currentModelFileTextField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
+
+ inputModelPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {InitialGuessDirPath, osimxFilePath, trackedQuantitiesDirPath});
+
inputModelPanelLayout.setVerticalGroup(
inputModelPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(inputModelPanelLayout.createSequentialGroup()
@@ -386,14 +394,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jCoordinatesListPanel2Layout.setHorizontalGroup(
jCoordinatesListPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jCoordinatesListPanel2Layout.createSequentialGroup()
- .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 871, Short.MAX_VALUE)
+ .addComponent(jScrollPane2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonEditSettingsCoordinateList, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jCoordinatesListPanel2Layout.setVerticalGroup(
jCoordinatesListPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE)
.addGroup(jCoordinatesListPanel2Layout.createSequentialGroup()
.addGap(98, 98, 98)
.addComponent(jButtonEditSettingsCoordinateList)
@@ -459,7 +467,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jCoordinatesListPanel3Layout.setHorizontalGroup(
jCoordinatesListPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jCoordinatesListPanel3Layout.createSequentialGroup()
- .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 783, Short.MAX_VALUE)
+ .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 777, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonEditSynergyCoordinateList, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))
);
@@ -511,7 +519,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
.addGroup(jSynergyControllerDetailsPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(surrogateModelDirPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap(93, Short.MAX_VALUE))
);
jRCNLTorqueControllerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TreatmentOptimizationJPanel.class, "TreatmentOptimizationJPanel.jRCNLTorqueControllerPanel.border.title"))); // NOI18N
@@ -555,13 +563,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jRCNLTorqueControllerPanel.setLayout(jRCNLTorqueControllerPanelLayout);
jRCNLTorqueControllerPanelLayout.setHorizontalGroup(
jRCNLTorqueControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 1035, Short.MAX_VALUE)
+ .addGap(0, 1029, Short.MAX_VALUE)
.addGroup(jRCNLTorqueControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(JTorqueControllerDetailsPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jRCNLTorqueControllerPanelLayout.setVerticalGroup(
jRCNLTorqueControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 347, Short.MAX_VALUE)
+ .addGap(0, 383, Short.MAX_VALUE)
.addGroup(jRCNLTorqueControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jRCNLTorqueControllerPanelLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -584,7 +592,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jControllersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jControllersPanelLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(jSynergyControllerDetailsPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 533, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jSynergyControllerDetailsPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jRCNLTorqueControllerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
@@ -625,7 +633,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jCostTermsPanelLayout.setHorizontalGroup(
jCostTermsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jCostTermsPanelLayout.createSequentialGroup()
- .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 861, Short.MAX_VALUE)
+ .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 855, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jCostTermsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(deleteCostTermButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -642,7 +650,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(editCostTermButton)
.addGap(14, 14, 14)
.addComponent(deleteCostTermButton)
- .addContainerGap(180, Short.MAX_VALUE))
+ .addContainerGap(346, Short.MAX_VALUE))
);
jConstTermsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TreatmentOptimizationJPanel.class, "TreatmentOptimizationJPanel.jConstTermsPanel.border.title"))); // NOI18N
@@ -721,7 +729,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1061, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jTabbedPane1)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -753,6 +761,22 @@ private void trackedQuantitiesDirPathStateChanged(javax.swing.event.ChangeEvent
private void deleteConstraintTermButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteConstraintTermButtonActionPerformed
// TODO add your handling code here:
+ int[] sels = jConstraintTermList.getSelectedIndices();
+ PropertyObjectList poList = treatmentOptimizationToolModel.getConstraintTermListAsObjectList();
+ Vector tasksToDelete = new Vector();
+ for (int i=0; i0; r-- ){
+ constraintTermListModel.remove(tasksToDelete.get(r-1));
+ poList.removeValueAtIndex(tasksToDelete.get(r-1));
+ }
+ // Recreate list model to cleanup
+ constraintTermListModel = new ConstraintTermListModel(poList);
+ jConstraintTermList.setModel(constraintTermListModel);
}//GEN-LAST:event_deleteConstraintTermButtonActionPerformed
private void editConstraintTermButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editConstraintTermButtonActionPerformed
@@ -925,6 +949,20 @@ private void jOptimizeSynVecCheckBoxActionPerformed(java.awt.event.ActionEvent e
treatmentOptimizationToolModel.setOptimizeSynergyVector(jOptimizeSynVecCheckBox.isSelected());
}//GEN-LAST:event_jOptimizeSynVecCheckBoxActionPerformed
+ private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
+ // TODO add your handling code here:
+ OpenSimObject settingsAsObject = OpenSimObject.newInstanceOfType("OptimalControlSolverSettings");
+ OpenSimObject.setSerializeAllDefaults(true);
+ FileFilter settingsFilter = FileUtils.getFileFilter(".xml", "Optimal Control Solver Settings");
+ String fileName = FileUtils.getInstance().browseForFilenameToSave(settingsFilter, true, "", null);
+ if(fileName!=null) {
+ String fullFilename = FileUtils.addExtensionIfNeeded(fileName, ".xml");
+ settingsAsObject.print(fullFilename);
+ treatmentOptimizationToolModel.setOCSettingsFile(fullFilename);
+ }
+ OpenSimObject.setSerializeAllDefaults(false);
+ }//GEN-LAST:event_jRadioButton2ActionPerformed
+
@Override
public void update(Observable o, Object o1) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
@@ -935,14 +973,9 @@ public void pressedCancel() {
super.pressedCancel(); //To change body of generated methods, choose Tools | Templates.
}
- @Override
- public String getToolXML() {
- return treatmentOptimizationToolModel.getToolAsObject().dump();
- }
-
@Override
public void loadSettings(String nmsmFilename) {
- String fileName = super.stripOuterTags(nmsmFilename);
+ String fileName = BaseToolPanel.stripOuterTags(nmsmFilename);
Model model = OpenSimDB.getInstance().getCurrentModel();
//if(model==null) throw new IOException("JointPersonalizationJPanel got null model");
@@ -963,6 +996,9 @@ public void loadSettings(String nmsmFilename) {
// Cost+Constraints
costTermListModel = new CostTermListModel(treatmentOptimizationToolModel.getCostTermListAsObjectList());
+ jCostTermList.setModel(costTermListModel);
+ constraintTermListModel = new ConstraintTermListModel(treatmentOptimizationToolModel.getConstraintTermListAsObjectList());
+ jConstraintTermList.setModel(constraintTermListModel);
}
@Override
@@ -1058,5 +1094,25 @@ public void valueChanged(ListSelectionEvent lse) {
deleteConstraintTermButton.setEnabled(sels.length>=1);
}
}
+ @Override
+ public void saveSettings(String fileName) {
+ String fullFilename = FileUtils.addExtensionIfNeeded(fileName, ".xml");
+ OpenSimObject obj = treatmentOptimizationToolModel.getToolAsObject();
+ forceWritableProperties(obj);
+ obj.print(fullFilename);
+ replaceOpenSimDocumentTags(fullFilename);
+ }
+
+ @Override
+ void forceWritableProperties(OpenSimObject dObject) {
+ super.forceWritableProperties(dObject); //To change body of generated methods, choose Tools | Templates.
+ AbstractProperty ap = dObject.getPropertyByName("RCNLCostTermSet");
+ PropertyObjectList olist = PropertyObjectList.getAs(ap);
+ for (int i=0; i< olist.size(); i++){
+ OpenSimObject costterm = olist.getValue(i);
+ costterm.updPropertyByName("max_allowable_error").setValueIsDefault(false);
+ }
+ }
+
}
diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationToolModel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationToolModel.java
index 2aa38d65c..b71cf05aa 100644
--- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationToolModel.java
+++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationToolModel.java
@@ -113,7 +113,9 @@ private void connectPropertiesToClassMembers() {
propOCSettingsFileString = PropertyStringList.getAs(propOCSettingsFile);
AbstractProperty propStatesCoordinateList = toolAsObject.updPropertyByName("states_coordinate_list");
propStatesCoordinateListString = PropertyStringList.getAs(propStatesCoordinateList);
- propRCNLSynergyControllerObject = toolAsObject.updPropertyByName("RCNLSynergyController").getValueAsObject();
+ boolean defaultProp = toolAsObject.getPropertyByName("RCNLSynergyController").getValueIsDefault();
+ propRCNLSynergyControllerObject = toolAsObject.updPropertyByName("RCNLSynergyController").getValueAsObject();
+ defaultProp = toolAsObject.getPropertyByName("RCNLSynergyController").getValueIsDefault();
// Convert to ObjectProperty so we can dig deeper
propOptimizeForSynvergyVectorBool = PropertyBoolList.getAs(propRCNLSynergyControllerObject.updPropertyByName("optimize_synergy_vectors"));
propSurrogateModelDirString = PropertyStringList.getAs(propRCNLSynergyControllerObject.updPropertyByName("surrogate_model_data_directory"));