示例#1
0
        /// <summary>
        /// Convienence method to create a layer state and capture the current state in one call.
        /// It is still safe to use the constructors directly as well.
        /// </summary>
        /// <returns></returns>
        public static LayerState CreateAndCapture()
        {
            LayerState layerState = new LayerState();

            layerState.captureState();
            return(layerState);
        }
 /// <summary>
 /// Push a new state onto the undo/redo buffer, will erase anything after the current undo.
 /// This will use the passed states for undo and redo.
 /// </summary>
 public void pushUndoState(LayerState undoState, LayerState redoState)
 {
     if (!undoState.isTheSameAs(redoState)) //This uses the slightly unreliable isTheSameAs function, but worse case scenerio we end up with a duplicate undo.
     {
         undoRedoBuffers[activeStateName].pushAndSkip(new TwoWayDelegateCommand <LayerState, LayerState>(redoState, undoState, new TwoWayDelegateCommand <LayerState, LayerState> .Funcs()
         {
             ExecuteFunc = state =>
             {
                 state.apply();
                 if (OnRedo != null)
                 {
                     OnRedo.Invoke(this);
                 }
             },
             UndoFunc = state =>
             {
                 state.apply();
                 if (OnUndo != null)
                 {
                     OnUndo.Invoke(this);
                 }
             }
         }));
         if (OnUndoRedoChanged != null)
         {
             OnUndoRedoChanged.Invoke(this);
         }
     }
 }
 public LayerChangeAction(String transparencyState, LayerState layerState)
 {
     this.TransparencyState       = transparencyState;
     this.LayerState              = layerState;
     this.Duration                = 1.0f;
     UseSystemLayerTransitionTime = false;
 }
示例#4
0
 public void copyFrom(LayerState source)
 {
     entries.Clear();
     entries.Capacity = source.entries.Count;
     foreach (LayerEntry entry in source.entries)
     {
         entries.Add(CopySaver.Default.copy(entry));
     }
 }
示例#5
0
 public Bookmark(String name, Vector3 cameraTrans, Vector3 cameraLookAt, LayerState layers)
 {
     this.Name      = name;
     CameraPosition = new CameraPosition()
     {
         Translation = cameraTrans,
         LookAt      = cameraLookAt,
     };
     this.Layers = layers;
 }
        public override void editing()
        {
            LayerState undo = LayerState.CreateAndCapture();
            String     currentTransparencyState = TransparencyController.ActiveTransparencyState;

            TransparencyController.ActiveTransparencyState = TransparencyState;
            LayerState.timedApply(MedicalConfig.CameraTransitionTime);
            TransparencyController.ActiveTransparencyState = currentTransparencyState;
            TimelineController.LayerController.pushUndoState(undo);
        }
示例#7
0
        public void itemAdded(ButtonGridItem item, LayerState layers, Vector3 translation, Vector3 lookAt, UserObjectType userObject = default(UserObjectType))
        {
            ButtonGridItemLiveThumbnailHost host = new ButtonGridItemLiveThumbnailHost(item)
            {
                Layers      = layers,
                Translation = translation,
                LookAt      = lookAt,
                UserObject  = userObject
            };

            item.UserObject = host;
            liveThumbnailController.addThumbnailHost(host);
            determineVisibleHosts();
        }
        public Object getRealValue(int column)
        {
            switch (column)
            {
            case 0:
                return(memberWrapper.getWrappedName());

            case 1:
                LayerState layerState = LayerState;
                if (layerState != null)
                {
                    return(LayerState);
                }
                return(null);
            }
            return(null);
        }
示例#9
0
 /// <summary>
 /// Tries to determine if this layer state is the same as the given one. This will check the sizes of the entries lists,
 /// if they are not the same it will be false. If they are the same it will compare each entry, if the entries do not
 /// match name for name and alpha value for alpha value they will not be the same. Note that the order of the entries in
 /// both layer states must be the same or else they will still be considered different. The entries list is only enumerated
 /// one time. This is mostly useful to see if two layer states generated on the same program run with the same scene are the
 /// same (since the entries should always come out in the same order).
 /// </summary>
 /// <param name="other">The other entry.</param>
 /// <returns>True if they are the same and false otherwise.</returns>
 public bool isTheSameAs(LayerState other)
 {
     if (entries.Count == other.entries.Count)
     {
         for (int i = 0; i < entries.Count; ++i)
         {
             var mine   = entries[i];
             var theirs = other.entries[i];
             if (mine.TransparencyObject != theirs.TransparencyObject || mine.AlphaValue != theirs.AlphaValue)
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
 public override void skipTo(float timelineTime)
 {
     if (TransparencyController.hasTransparencyState(TransparencyState))
     {
         if (timelineTime <= EndTime)
         {
             float  currentPosition          = timelineTime - StartTime;
             String currentTransparencyState = TransparencyController.ActiveTransparencyState;
             TransparencyController.ActiveTransparencyState = TransparencyState;
             float percent = 1.0f;
             if (Duration != 0.0f)
             {
                 percent = currentPosition / Duration;
             }
             LayerState.instantlyApplyBlendPercent(percent);
             LayerState.timedApply(Duration - currentPosition);
             TransparencyController.ActiveTransparencyState = currentTransparencyState;
         }
         else
         {
             LayerState.instantlyApply();
             finished = true;
         }
     }
     else
     {
         //Could not find the specified window, so just apply to the active window.
         if (timelineTime <= EndTime)
         {
             float currentPosition = timelineTime - StartTime;
             TransparencyController.ActiveTransparencyState = TransparencyState;
             float percent = 1.0f;
             if (Duration != 0.0f)
             {
                 percent = currentPosition / Duration;
             }
             LayerState.instantlyApplyBlendPercent(percent);
             LayerState.timedApply(Duration - currentPosition);
         }
         else
         {
             LayerState.instantlyApply();
             finished = true;
         }
     }
 }
 public override void started(float timelineTime, Clock clock)
 {
     if (TransparencyController.hasTransparencyState(TransparencyState))
     {
         String currentTransparencyState = TransparencyController.ActiveTransparencyState;
         TransparencyController.ActiveTransparencyState = TransparencyState;
         LayerState.timedApply(Duration);
         TransparencyController.ActiveTransparencyState = currentTransparencyState;
         finished = false;
     }
     else
     {
         //Could not find the specified window, so just apply to the active window.
         LayerState.timedApply(Duration);
         finished = false;
     }
 }
        public string getValue(int column)
        {
            switch (column)
            {
            case 0:
                return(memberWrapper.getWrappedName());

            case 1:
                LayerState layerState = LayerState;
                if (layerState != null)
                {
                    return(LayerState.ToString());
                }
                return(null);
            }
            return(null);
        }
示例#13
0
        public void instantlyApplyBlended(LayerState end, float percent)
        {
            List <TransparencyInterface> unvisitedInterfaces = new List <TransparencyInterface>(TransparencyController.TransparencyInterfaces);

            foreach (LayerEntry entry in entries)
            {
                var   endEntry = end.entries.FirstOrDefault(e => e.TransparencyObject == entry.TransparencyObject);
                float endValue = 0.0f;
                if (endEntry != null)
                {
                    endValue = endEntry.AlphaValue;
                }
                entry.instantlyApplyBlended(unvisitedInterfaces, endValue, percent);
            }
            foreach (TransparencyInterface unvisited in unvisitedInterfaces)
            {
                unvisited.CurrentAlpha = 0.0f;
            }
        }
        public static PooledSceneView getSceneView(this TextureSceneViewPool pool, Vector3 translation, Vector3 lookAt, LayerState layers)
        {
            PooledSceneView pooledView = pool.getSceneView(translation, lookAt);

            layers.instantlyApplyTo(pooledView.SceneView.CurrentTransparencyState);

            return(pooledView);
        }
示例#15
0
 /// <summary>
 /// Push a new state onto the undo/redo buffer, will erase anything after the current undo.
 /// This will use the passed state as the undo state and the current muscle position of the scene
 /// as the redo state.
 /// </summary>
 public void pushUndoState(LayerState undoLayers)
 {
     pushUndoState(undoLayers, LayerState.CreateAndCapture());
 }
 public LayerChangeAction()
     : this(null, new LayerState())
 {
     LayerState.captureState();
 }
 public override void capture()
 {
     TransparencyState = TransparencyController.ActiveTransparencyState;
     LayerState.captureState();
 }
 public LayerChangeAction(String transparencyState, LayerState layerState, float startTime)
     : this(transparencyState, layerState)
 {
     this.StartTime = startTime;
 }
        public static void createFromPresets(this SceneViewController controller, SceneViewWindowPresetSet presets, bool keepOldSettings = true)
        {
            //Capture current window configuration info
            List <Bookmark> currentWindowConfig = new List <Bookmark>();

            if (keepOldSettings)
            {
                SceneViewWindow activeWindow = controller.ActiveWindow;
                if (activeWindow != null)
                {
                    TransparencyController.ActiveTransparencyState = activeWindow.CurrentTransparencyState;
                    LayerState layerState = new LayerState();
                    layerState.captureState();
                    currentWindowConfig.Add(new Bookmark("", activeWindow.Translation, activeWindow.LookAt, layerState));
                }
                foreach (MDISceneViewWindow window in controller.MdiWindows)
                {
                    if (window != activeWindow)
                    {
                        TransparencyController.ActiveTransparencyState = window.CurrentTransparencyState;
                        LayerState layerState = new LayerState();
                        layerState.captureState();
                        currentWindowConfig.Add(new Bookmark("", window.Translation, window.LookAt, layerState));
                    }
                }
            }

            //Create windows
            int windowIndex = 0;
            int zOrder      = 100;
            int zOrderInc   = 10;

            controller.closeAllWindows();
            MDISceneViewWindow camera;
            MDISceneViewWindow toSelect = null;

            foreach (SceneViewWindowPreset preset in presets.getPresetEnum())
            {
                if (windowIndex < currentWindowConfig.Count)
                {
                    Bookmark bmk = currentWindowConfig[windowIndex++];
                    camera = controller.createWindow(preset.Name, bmk.CameraPosition.Translation, bmk.CameraPosition.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                    bmk.Layers.instantlyApply();
                }
                else
                {
                    camera = controller.createWindow(preset.Name, preset.Position, preset.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    Bookmark bmk = null;
                    if (BookmarksController != null)
                    {
                        bmk = BookmarksController.loadBookmark(String.Format("Cameras/{0}.bmk", camera.CurrentTransparencyState));

                        if (bmk != null)
                        {
                            camera.setPosition(bmk.CameraPosition, 0.0f);
                            TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                            bmk.Layers.instantlyApply();
                        }
                    }
                }
                if (toSelect == null)
                {
                    toSelect = camera;
                }
                zOrder += zOrderInc;
            }
            if (toSelect != null)
            {
                controller.setActiveMdiWindow(toSelect);
            }
        }