public FormBehavior(C3mbSpeciesModel Species, int ThisIndex) { InitializeComponent(); m_beh = Species.GetBehaviorCopy(ThisIndex); m_spe = Species; m_myIndex = ThisIndex; BehNameButton.Text = m_beh.name; this.Text = m_szTitleBar1 + "(" + (m_myIndex+1) + " of " + m_spe.BehaviorCount + ")" + m_szTitleBar2; UpdatePanel(); ModelOKButton.Text = "Done"; m_initializing = false; }
public CBehavior AddBehavior(Boolean UpdateModel) { CBehavior beh; beh = new CBehavior(); // +1 for the new behavior being added. m_list.Add(beh); if(UpdateModel == false) return beh; // Initially there is only a single depth span for the new behavior. Set the // single span's shallow and deep values to default. Debug.Assert(beh.SpanManager.SpanCount == 1); beh.SpanManager.SetSpan(0, 0, -3500); // index 0 because first and only span since it is a new behavior. // Set the behavior's default name. beh.name = "Behavior " + (m_list.Count); //--------------------------------------------------------------------------// // Update Behavior Transition Matrices //------------------------------------// // For each behavior add a column to each of its normal behavior depth span // as well as its depth environmental attractor and temperature environmental // attractor. Each added behavior gets an added column. for(int i=0; i<m_list.Count; i++) // { // Increment the environmental attractor behavior transtion matrices beh = (CBehavior)m_list[i]; while(beh.depthBehTrans.vector.columnCount < Count + 1) beh.IncrementTransitionBehaviorVectors(); // Increment each spans normal behavior transtion matrices for(int j=0; j<beh.SpanManager.SpanCount; j++) /*Count is the number of behaviors*/ while(beh.SpanManager.GetSpan(j).behTrans.transitionCount < Count) beh.SpanManager.GetSpan(j).IncrementSpanBehaviorTransitionVectorElement(); } // Return the newly added behavior. return (CBehavior)m_list[Count-1]; }
//--------------// // Class Methods //--------------// public CBehavior GetCopy() { int i; CSpan span; CBehavior c = new CBehavior(); c.m_name = m_name; //--------------------// // Behavior transition //--------------------// // Delete any spans in the newly instantiated CBehavior instance c.m_spanMgr.DeleteAllSpans(); // Copy the behavior spans from this behavor to the copy. for(i=0; i<m_spanMgr.SpanCount && null != (span = m_spanMgr.GetSpan(i)); i++) { c.SpanManager.AddSpan(span); } c.m_behTermMdl = m_behTermMdl; c.m_depthEnvAttctrBehTrans = m_depthEnvAttctrBehTrans.GetCopy(); c.m_tempEnvAttctrBehTrans = m_tempEnvAttctrBehTrans.GetCopy(); // Dive Parameters //c.m_fBttmDvEnabled = m_fBttmDvEnabled; c.m_flatBottomDive = m_flatBottomDive.GetCopy(); c.m_ascent = m_ascent.GetCopy(); c.m_descent = m_descent.GetCopy(); c.m_depth = m_depth.GetCopy(); c.m_reverse = m_reverse.GetCopy(); c.m_surfintrvl = m_surfintrvl.GetCopy(); // Travel Parameters c.m_direction = m_direction.GetCopy(); c.m_rate = m_rate.GetCopy(); // Environmental Attractors c.m_envInfPriority = m_envInfPriority; c.m_envAttDirDepth = m_envAttDirDepth.GetCopy(); c.m_envAttDirTemp = m_envAttDirTemp.GetCopy(); return c; }
public Boolean ReplaceBehavior(int Index, CBehavior Replacement) { if(false == CUtil.CheckIndex(Count, Index)) return false; m_list[Index] = Replacement; return true; }
private void CopyBehaviorButton_Click(object sender, EventArgs e) { FormNormalModelSelect dlg = new FormNormalModelSelect(m_spe, m_myIndex); dlg.ShowDialog(this); this.BringToFront(); if(dlg.result == RESLT.CANCEL) return; m_beh = m_spe.GetBehaviorCopy(dlg.selectedIndex); m_spe.SetBehavior(m_myIndex, m_beh); UpdateModifiedStatus(); UpdatePanel(); }
// Replaces a behavior at index. public Boolean SetBehavior(int Index, CBehavior Replacement) { if(true == m_behMgr.ReplaceBehavior(Index, Replacement)) { m_needSave = true; return true; } return false; }
public RmBehTransVec(TRANSITIONALMODELTYPE TransType, C3mbSpeciesModel Species, CBehavior Behavior, int BehaviorIndex, string szTitle) { int i; InitializeComponent(); m_initializing = true; m_spe = Species; m_beh = Behavior; m_behIndex = BehaviorIndex; m_szTitle = szTitle; m_behaviorCnt = Species.BehaviorCount; m_transModelType = TransType; CBehavior beh; CEnvAttrBehTrans transModel; this.Text = szTitle; m_vectorTextBoxArray[0] = VectorTextBox00; m_vectorTextBoxArray[1] = VectorTextBox01; m_vectorTextBoxArray[2] = VectorTextBox02; m_vectorTextBoxArray[3] = VectorTextBox03; m_vectorTextBoxArray[4] = VectorTextBox04; m_vectorTextBoxArray[5] = VectorTextBox05; m_vectorTextBoxArray[6] = VectorTextBox06; m_vectorTextBoxArray[7] = VectorTextBox07; m_behNameLabelArray[0] = NameLabel00; m_behNameLabelArray[1] = NameLabel01; m_behNameLabelArray[2] = NameLabel02; m_behNameLabelArray[3] = NameLabel03; m_behNameLabelArray[4] = NameLabel04; m_behNameLabelArray[5] = NameLabel05; m_behNameLabelArray[6] = NameLabel06; m_behNameLabelArray[7] = NameLabel07; m_T50TextBoxArray[0] = T50TextBox00; m_T50TextBoxArray[1] = T50TextBox01; m_T50TextBoxArray[2] = T50TextBox02; m_T50TextBoxArray[3] = T50TextBox03; m_T50TextBoxArray[4] = T50TextBox04; m_T50TextBoxArray[5] = T50TextBox05; m_T50TextBoxArray[6] = T50TextBox06; m_T50TextBoxArray[7] = T50TextBox07; m_slopeTextBoxArray[0] = SlopeTextBox00; m_slopeTextBoxArray[1] = SlopeTextBox01; m_slopeTextBoxArray[2] = SlopeTextBox02; m_slopeTextBoxArray[3] = SlopeTextBox03; m_slopeTextBoxArray[4] = SlopeTextBox04; m_slopeTextBoxArray[5] = SlopeTextBox05; m_slopeTextBoxArray[6] = SlopeTextBox06; m_slopeTextBoxArray[7] = SlopeTextBox07; //m_refreshing = true; for(i=0; i<m_spe.BehaviorCount && i<NUM_NRML_BUTTONS; i++) { if(i == m_behIndex) beh = m_beh; else beh = m_spe.GetBehaviorCopy(i); switch(m_transModelType) { //case TRANSITIONALMODELTYPE.BEHAVIORAL: // transModel = beh.nrmlBehTrans; // break; case TRANSITIONALMODELTYPE.DEPTHENV: transModel = beh.depthBehTrans; break; case TRANSITIONALMODELTYPE.TEMPERATUREENV: transModel = beh.temperatureBehTrans; break; default: transModel = beh.depthBehTrans; // transModel = beh.nrmlBehTrans; break; } m_behNameLabelArray[i].Text = beh.name; m_vectorTextBoxArray[i].Text = transModel.vector.ConvertToString(); m_T50TextBoxArray[i].Text = "" + transModel.meanTimeInBehMinuites; m_slopeTextBoxArray[i].Text = "" + transModel.slopeCoeff_goesAway; } for(; i<NUM_NRML_BUTTONS; i++) { m_behNameLabelArray[i].Text = ""; m_behNameLabelArray[i].Enabled = false; m_vectorTextBoxArray[i].Text = ""; m_vectorTextBoxArray[i].Enabled = false; m_T50TextBoxArray[i].Text = ""; m_T50TextBoxArray[i].Enabled = false; m_slopeTextBoxArray[i].Text = ""; m_slopeTextBoxArray[i].Enabled = false; } DoneButton.Enabled = true; RefreshButton.Enabled = false; UpdateVectorModel(); m_initializing = false; //m_refreshing = false; }