Skip to content

Commit

Permalink
Support max-min errors in constraint term editing, support maxError f…
Browse files Browse the repository at this point in the history
…or cost term editing, test serialization
  • Loading branch information
aymanhab committed Aug 31, 2024
1 parent 52f888e commit ccd9e9c
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 200 deletions.
8 changes: 4 additions & 4 deletions Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ EditCosnstraintTermJPanel.editComonentListButton.text=Edit...
EditCosnstraintTermJPanel.jComponentListPanel.border.title=Component List
EditCosnstraintTermJPanel.jEnabledCheckBox.text=Enabled
EditCosnstraintTermJPanel.jLabel1.text=Constraint Term Type:
EditCosnstraintTermJPanel.jTextField1.text=0
EditCosnstraintTermJPanel.jTextField2.text=0
EditCosnstraintTermJPanel.jLabel3.text=Max error:
EditCosnstraintTermJPanel.jLabel4.text=Name:
EditCosnstraintTermJPanel.jConstraintNameTextField.text=
Expand Down Expand Up @@ -207,10 +205,12 @@ TreatmentOptimizationJPanel.jCoordinatesListPanel2.border.title=States Coordinat
TreatmentOptimizationJPanel.jButtonEditSettingsCoordinateList.text=Edit...
TreatmentOptimizationJPanel.jOptimizeSynVecCheckBox.text=Optimize Synergy Vectors
TreatmentOptimizationJPanel.jButtonEditSynergyCoordinateList.text=Edit...
EditCostTermJPanel.jMaxErrorTextField.text=0
EditCostTermJPanel.jMaxErrorTextField.text=0.
EditCostTermJPanel.jCostTermNameTextField.text=
EditCostTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
TreatmentOptimizationJPanel.jPanelCostConstraints.TabConstraints.tabTitle=Cost/Constraints
EditCostTermJPanel.jLabel3.text=Error center:
EditCostTermJPanel.jErrorCenterTextField.text=
EditCostTermJPanel.jErrorCenterTextField.text=0.
EditCosnstraintTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
EditCosnstraintTermJPanel.jMaxErrorTextField.text=0
EditCosnstraintTermJPanel.jMinErrorTextField.text=0
18 changes: 18 additions & 0 deletions Gui/opensim/rice_cnl/src/org/opensim/rcnl/ConstraintTermModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.opensim.modeling.AbstractProperty;
import org.opensim.modeling.Model;
import org.opensim.modeling.OpenSimObject;
import org.opensim.modeling.PropertyHelper;
import org.opensim.modeling.PropertyStringList;
import org.opensim.view.pub.OpenSimDB;

Expand All @@ -20,11 +21,15 @@ public class ConstraintTermModel {
OpenSimObject constraintTerm;
private TreatmentOptimizationToolModel.Mode mode;
private int termIndex = 0;
private AbstractProperty maxErrorProp;
private AbstractProperty minErrorProp;

public ConstraintTermModel(OpenSimObject rCNLConstraintTerm, TreatmentOptimizationToolModel.Mode mode){
this.model = OpenSimDB.getInstance().getCurrentModel();
this.constraintTerm = rCNLConstraintTerm;
this.mode = mode;
maxErrorProp = rCNLConstraintTerm.updPropertyByName("max_error");
minErrorProp = rCNLConstraintTerm.updPropertyByName("min_error");
}

void setTypeIndex(int selectedIndex) {
Expand Down Expand Up @@ -54,4 +59,17 @@ PropertyStringList getPropertyComponentList() {
}
return PropertyStringList.updAs(constraintTerm.updPropertyByName("coordinate_list"));
}
public double getMaxError() {
return PropertyHelper.getValueDouble(maxErrorProp);
}
public void setMaxError(double newMaxErr) {
PropertyHelper.setValueDouble(newMaxErr, maxErrorProp);
}
public double getMinError() {
return PropertyHelper.getValueDouble(minErrorProp);
}
public void setMinError(double newMinError) {
PropertyHelper.setValueDouble(newMinError, minErrorProp);
}

}
20 changes: 20 additions & 0 deletions Gui/opensim/rice_cnl/src/org/opensim/rcnl/CostTermModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.opensim.modeling.AbstractProperty;
import org.opensim.modeling.Model;
import org.opensim.modeling.OpenSimObject;
import org.opensim.modeling.PropertyHelper;
import org.opensim.modeling.PropertyStringList;
import org.opensim.view.pub.OpenSimDB;

Expand All @@ -20,11 +21,17 @@ public class CostTermModel {
OpenSimObject costTerm;
private TreatmentOptimizationToolModel.Mode mode;
private int termIndex = 0;
private AbstractProperty errorProp;
private AbstractProperty errorCenterProp;



public CostTermModel(OpenSimObject rCNLCostTerm, TreatmentOptimizationToolModel.Mode mode){
this.model = OpenSimDB.getInstance().getCurrentModel();
this.costTerm = rCNLCostTerm;
this.mode = mode;
errorProp = costTerm.updPropertyByName("max_allowable_error");
errorCenterProp = costTerm.updPropertyByName("error_center");
}

void setTypeIndex(int selectedIndex) {
Expand Down Expand Up @@ -54,4 +61,17 @@ PropertyStringList getPropertyComponentList() {
}
return PropertyStringList.updAs(costTerm.updPropertyByName("coordinate_list"));
}

public double getMaxAllowableError() {
return PropertyHelper.getValueDouble(errorProp);
}
public void setMaxAllowableError(double newMaxErr) {
PropertyHelper.setValueDouble(newMaxErr, errorProp);
}
public double getErrorCenter() {
return PropertyHelper.getValueDouble(errorCenterProp);
}
public void setErrorCenter(double newErrorCenter) {
PropertyHelper.setValueDouble(newErrorCenter, errorCenterProp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,43 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jComponentListPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jComponentTypeTextField" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
<Component id="jEnabledCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jConstraintTypeComboBox" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jConstraintNameTextField" min="-2" pref="460" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jComponentTypeTextField" min="-2" pref="220" max="-2" attributes="0"/>
</Group>
<Component id="jEnabledCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextField2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="253" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextField1" min="-2" max="-2" attributes="0"/>
<Component id="jConstraintTypeComboBox" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jConstraintNameTextField" min="-2" pref="460" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="309" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jMaxErrorTextField" min="-2" pref="146" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="128" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jMinErrorTextField" min="-2" pref="139" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jComponentListPanel" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -81,13 +79,13 @@
<Component id="jComponentTypeTextField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jComponentListPanel" min="-2" pref="199" max="-2" attributes="0"/>
<Component id="jComponentListPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="jTextField2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jMaxErrorTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jMinErrorTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
Expand Down Expand Up @@ -130,8 +128,8 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane2" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane2" min="-2" pref="762" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="editComonentListButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -144,11 +142,7 @@
<Component id="editComonentListButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="43" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jScrollPane2" min="-2" pref="144" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="83" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane2" alignment="0" pref="103" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
Expand Down Expand Up @@ -218,12 +212,16 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField1">
<Component class="javax.swing.JTextField" name="jMinErrorTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="EditCosnstraintTermJPanel.jTextField1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="EditCosnstraintTermJPanel.jMinErrorTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jMinErrorTextFieldFocusLost"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMinErrorTextFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
Expand All @@ -232,12 +230,16 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField2">
<Component class="javax.swing.JTextField" name="jMaxErrorTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="EditCosnstraintTermJPanel.jTextField2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="EditCosnstraintTermJPanel.jMaxErrorTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jMaxErrorTextFieldFocusLost"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMaxErrorTextFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
Expand Down
Loading

0 comments on commit ccd9e9c

Please sign in to comment.