Exemplo n.º 1
0
 /// <summary>
 /// Sets the provided IILayer by index to the current layer.
 /// </summary>
 /// <param name="index"></param>
 public static void SetCurrentLayer(int index)
 {
     using (IILayerProperties layerProps = GetLayerProperties(index))
     {
         layerProps.Current = true;
     }
 }
Exemplo n.º 2
0
        public static bool HasNode(this IILayer layer, IINode node, bool checkInChild = true)
        {
#if MAX2020
            ITab <IINode> nodes = Loader.Global.INodeTab.Create();
#else
            ITab <IINode> nodes = Loader.Global.INodeTabNS.Create();
#endif
            IILayerProperties layerProperties = Loader.IIFPLayerManager.GetLayer(layer.Name);
            layerProperties.Nodes(nodes);

            foreach (IINode n in Tools.ITabToIEnumerable(nodes))
            {
                if (node.Handle == n.Handle)
                {
                    return(true);
                }
            }

            for (int i = 0; i < layer.NumOfChildLayers; i++)
            {
                IILayer child = layer.GetChildLayer(i);
                if (child.HasNode(node, checkInChild))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public override Object GetAspect(Object rowObject)
        {
            LayerTreeNode layerTreeNode = rowObject as LayerTreeNode;

            if (layerTreeNode != null)
            {
                IILayer layer = MaxAnimatable.GetAnimByHandle(layerTreeNode.Handle) as IILayer;
                if (layer != null)
                {
                    IILayerProperties layerProps = MaxLayers.GetLayerProperties(layer);
                    return(layerProps.Current);
                }
            }
            FolderTreeNode folderTreeNode = rowObject as FolderTreeNode;

            if (folderTreeNode != null)
            {
                // Default behaviour of getFolderCheckState returns true.
                // Only get folder check state if necessary as it is
                // more expensive than returning false.
                if (folderTreeNode.Children.Count > 0)
                {
                    Boolean?checkState = getFolderCheckState(folderTreeNode);
                    if (checkState == true || checkState == null)
                    {
                        return(null);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns all child IINode objects of provided IILayer.
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        public static IEnumerable <IINode> GetChildNodes(IILayer layer)
        {
            IILayerProperties layerProps = GetLayerProperties(layer);
            ITab <IINode>     layerNodes = GlobalInterface.Instance.Tab.Create <IINode>();

            layerProps.Nodes(layerNodes);
            for (int i = 0; i < layerNodes.Count; i++)
            {
                yield return(layerNodes[(IntPtr)i]);
            }
        }
Exemplo n.º 5
0
        public static IEnumerable <IINode> LayerNodes(this IILayer layer)
        {
            IILayerProperties layerProp = Loader.IIFPLayerManager.GetLayer(layer.Name);

#if MAX2020
            ITab <IINode> nodes = Loader.Global.INodeTab.Create();
#else
            ITab <IINode> nodes = Loader.Global.INodeTabNS.Create();
#endif
            layerProp.Nodes(nodes);
            return(Tools.ITabToIEnumerable(nodes));
        }
Exemplo n.º 6
0
        public override void PutAspect(Object rowObject, Object newValue)
        {
            LayerTreeNode layerTreeNode = rowObject as LayerTreeNode;

            if (layerTreeNode != null)
            {
                IILayer layer = MaxAnimatable.GetAnimByHandle(layerTreeNode.Handle) as IILayer;
                if (layer != null)
                {
                    IILayerProperties layerProps = MaxLayers.GetLayerProperties(layer);
                    layerProps.Current = (Boolean)newValue;
                }
            }
        }
Exemplo n.º 7
0
        public static List <IILayer> RootLayers()
        {
            List <IILayer> rootILayers = new List <IILayer>();
            int            layerCount  = Loader.IIFPLayerManager.Count;

            for (int i = 0; i < layerCount; i++)
            {
                IILayerProperties l = Loader.IIFPLayerManager.GetLayer(i);
                if (l.ParentLayerProperties == null)
                {
                    rootILayers.Add(Loader.Core.LayerManager.GetLayer(i));
                }
            }

            return(rootILayers);
        }
Exemplo n.º 8
0
        public static void DeleteLayer(UIntPtr layerHandle)
        {
            IILayer layer = MaxAnimatable.GetAnimByHandle(layerHandle) as IILayer;

            if (layer == null)
            {
                return;
            }

            IILayerProperties layerProperties = MaxLayers.GetLayerProperties(layer);

            if (layerProperties.Current)
            {
                MaxLayers.SetCurrentLayer(0);
            }

            MaxInterfaces.Instance.FPLayerManager.DeleteLayer(layer.Name);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Deletes the provided IILayer object, and optionally all child nodes.
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="deleteNodes"></param>
        public static void DeleteLayer(IILayer layer, Boolean deleteNodes)
        {
            // Check if layer has any child nodes.
            // If layer has children, this prevents the layer from being deleted.
            // Loop through all the children and delete them.
            if (deleteNodes)
            {
                using (IILayerProperties layerProps = GetLayerProperties(layer))
                {
                    IEnumerable <IINode> maxNodes = GetChildNodes(layer);
                    foreach (IINode maxNode in maxNodes)
                    {
                        MaxNodes.DeleteNode(maxNode);
                    }
                }
            }

            MaxInterfaces.Instance.FPLayerManager.DeleteLayer(layer.Name);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sets the provided IILayer to the current layer.
        /// </summary>
        /// <param name="layer"></param>
        public static void SetCurrentLayer(IILayer layer)
        {
            IILayerProperties layerProps = MaxLayers.GetLayerProperties(layer);

            layerProps.Current = true;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the ILayerWrapper class.
 /// </summary>
 /// <param name="ilayer">The ILayer object to wrap.</param>
 /// <param name="ilayerProperties">The ILayerProperties of the ILayer to wrap.</param>
 public ILayerWrapper(IILayer ilayer, IILayerProperties ilayerProperties)
 {
    this.ilayer = ilayer;
    this.ilayerProperties = ilayerProperties;
 }
Exemplo n.º 12
0
      /// <summary>
      /// Initializes a new instance of the ILayerWrapper class.
      /// </summary>
      /// <param name="ilayerProperties">The ILayerProperties of the ILayer to wrap.</param>
      public ILayerWrapper(IILayerProperties ilayerProperties)
      {
         Throw.IfNull(ilayerProperties, "IILayerProperties");

         this.ilayerProperties = ilayerProperties;
      }