예제 #1
0
        private static bool AlreadyPastedPT(ProbabilisticTransitionClipData pt, List <ProbabilisticTransitionClipData> alreadyPasted)
        {
            foreach (ProbabilisticTransitionClipData t in alreadyPasted)
            {
                if (PTClipObjectsEqual(t, pt))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        private static bool ValidatePTClipData(ProbabilisticTransitionClipData pt, DataSheet stratumSheet, DataSheet stateClassSheet, DataSheet transitionTypeSheet)
        {
            Debug.Assert(stratumSheet.Name == Strings.DATASHEET_STRATA_NAME);
            Debug.Assert(stateClassSheet.Name == Strings.DATASHEET_STATECLASS_NAME);
            Debug.Assert(transitionTypeSheet.Name == Strings.DATASHEET_TRANSITION_TYPE_NAME);

            if (pt.StratumSource != null)
            {
                if (!stratumSheet.ValidationTable.ContainsValue(pt.StratumSource))
                {
                    FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", pt.StratumSource);
                    return(false);
                }
            }

            if (!stateClassSheet.ValidationTable.ContainsValue(pt.StateClassSource))
            {
                FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", pt.StateClassSource);
                return(false);
            }

            if (pt.StratumDest != null)
            {
                if (!stratumSheet.ValidationTable.ContainsValue(pt.StratumDest))
                {
                    FormsUtilities.ErrorMessageBox("The stratum '{0}' does not exist in this project.", pt.StratumDest);
                    return(false);
                }
            }

            if (pt.StateClassDest != null)
            {
                if (!stateClassSheet.ValidationTable.ContainsValue(pt.StateClassDest))
                {
                    FormsUtilities.ErrorMessageBox("The state class '{0}' does not exist in this project.", pt.StateClassDest);
                    return(false);
                }
            }

            if (!transitionTypeSheet.ValidationTable.ContainsValue(pt.TransitionType))
            {
                FormsUtilities.ErrorMessageBox("The transition type '{0}' does not exist in this project.", pt.TransitionType);
                return(false);
            }

            if (pt.StratumSource != null)
            {
                pt.StratumIdSource = stratumSheet.ValidationTable.GetValue(pt.StratumSource);
            }

            pt.StateClassIdSource = stateClassSheet.ValidationTable.GetValue(pt.StateClassSource);

            if (pt.StratumDest != null)
            {
                pt.StratumIdDest = stratumSheet.ValidationTable.GetValue(pt.StratumDest);
            }

            if (pt.StateClassDest != null)
            {
                pt.StateClassIdDest = stateClassSheet.ValidationTable.GetValue(pt.StateClassDest);
            }

            pt.TransitionTypeId = transitionTypeSheet.ValidationTable.GetValue(pt.TransitionType);

#if DEBUG
            if (pt.StratumIdSource.HasValue)
            {
                Debug.Assert(pt.StratumIdSource.Value > 0);
            }

            Debug.Assert(pt.StateClassIdSource > 0);

            if (pt.StratumDest != null)
            {
                Debug.Assert(pt.StratumIdDest.Value > 0);
            }

            if (pt.StateClassDest != null)
            {
                Debug.Assert(pt.StateClassIdDest.Value > 0);
            }

            Debug.Assert(pt.TransitionTypeId > 0);
#endif

            return(true);
        }
예제 #3
0
        private static ProbabilisticTransitionClipData PTToClipFormat(Transition pt, DataSheet stratumSheet, DataSheet stateClassSheet, DataSheet transitionTypeSheet)
        {
            Debug.Assert(stratumSheet.Name == Strings.DATASHEET_STRATA_NAME);
            Debug.Assert(stateClassSheet.Name == Strings.DATASHEET_STATECLASS_NAME);
            Debug.Assert(transitionTypeSheet.Name == Strings.DATASHEET_TRANSITION_TYPE_NAME);

            ProbabilisticTransitionClipData cd = new ProbabilisticTransitionClipData();

            if (pt.StratumIdSource.HasValue)
            {
                cd.StratumSource = stratumSheet.ValidationTable.GetDisplayName(pt.StratumIdSource.Value);
            }

            cd.StateClassSource = stateClassSheet.ValidationTable.GetDisplayName(pt.StateClassIdSource);

            if (pt.StratumIdDestination.HasValue)
            {
                cd.StratumDest = stratumSheet.ValidationTable.GetDisplayName(pt.StratumIdDestination.Value);
            }

            if (pt.StateClassIdDestination.HasValue)
            {
                cd.StateClassDest = stateClassSheet.ValidationTable.GetDisplayName(pt.StateClassIdDestination.Value);
            }

            cd.TransitionType = transitionTypeSheet.ValidationTable.GetDisplayName(pt.TransitionTypeId);
            cd.Probability    = pt.Probability;

            if (pt.PropnWasNull)
            {
                cd.Proportion = null;
            }
            else
            {
                cd.Proportion = pt.Proportion;
            }

            if (pt.AgeMinWasNull)
            {
                cd.AgeMin = null;
            }
            else
            {
                cd.AgeMin = pt.AgeMinimum;
            }

            if (pt.AgeMaxWasNull)
            {
                cd.AgeMax = null;
            }
            else
            {
                cd.AgeMax = pt.AgeMaximum;
            }

            if (pt.AgeRelativeWasNull)
            {
                cd.AgeRelative = null;
            }
            else
            {
                cd.AgeRelative = pt.AgeRelative;
            }

            if (pt.AgeResetWasNull)
            {
                cd.AgeReset = null;
            }
            else
            {
                cd.AgeReset = pt.AgeReset;
            }

            if (pt.TstMinimumWasNull)
            {
                cd.TstMin = null;
            }
            else
            {
                cd.TstMin = pt.TstMinimum;
            }

            if (pt.TstMaximumWasNull)
            {
                cd.TstMax = null;
            }
            else
            {
                cd.TstMax = pt.TstMaximum;
            }

            if (pt.TstRelativeWasNull)
            {
                cd.TstRelative = null;
            }
            else
            {
                cd.TstRelative = pt.TstRelative;
            }

            return(cd);
        }
예제 #4
0
        private static bool PTClipObjectsEqual(ProbabilisticTransitionClipData t1, ProbabilisticTransitionClipData t2)
        {
            if (!NullableUtilities.NullableIdsEqual(t1.StratumIdSource, t2.StratumIdSource))
            {
                return(false);
            }

            if (t1.StateClassIdSource != t2.StateClassIdSource)
            {
                return(false);
            }

            if (!NullableUtilities.NullableIdsEqual(t1.StratumIdDest, t2.StratumIdDest))
            {
                return(false);
            }

            if (!NullableUtilities.NullableIdsEqual(t1.StateClassIdDest, t2.StateClassIdDest))
            {
                return(false);
            }

            if (t1.TransitionTypeId != t2.TransitionTypeId)
            {
                return(false);
            }

            if (t1.Proportion != t2.Proportion)
            {
                return(false);
            }

            if (t1.Probability != t2.Probability)
            {
                return(false);
            }

            if (t1.AgeMin != t2.AgeMin)
            {
                return(false);
            }

            if (t1.AgeMax != t2.AgeMax)
            {
                return(false);
            }

            if (t1.AgeRelative != t2.AgeRelative)
            {
                return(false);
            }

            if (t1.AgeReset != t2.AgeReset)
            {
                return(false);
            }

            if (t1.TstMin != t2.TstMin)
            {
                return(false);
            }

            if (t1.TstMax != t2.TstMax)
            {
                return(false);
            }

            if (t1.TstRelative != t2.TstRelative)
            {
                return(false);
            }

            return(true);
        }