iBlockMgr.h

Go to the documentation of this file.
00001  /**********************************************************************
00002  
00003     FILE: IBlockMgr.h
00004 
00005     DESCRIPTION:  Public interface for working with blocks (the same 
00006                                 concept as Autocad Blocks)
00007 
00008     CREATED BY: Attila Szabo, Discreet
00009 
00010     HISTORY: - created Aug 08, 2002
00011 
00012  *> Copyright (c) 1998-2002, All Rights Reserved.
00013  **********************************************************************/
00014 
00015 #pragma once
00016 
00017 #include "iFnPub.h"
00018 #include "maxtypes.h"
00019 #include "GetCOREInterface.h"
00020 
00021 // --- Forward declaration
00022 class IBlockRefComponent;
00023 class INode;
00024 class INodeTab;
00025 
00026 // --- Interface IDs
00027 #define BLOCK_MGR_INTERFACE Interface_ID(0x327d3c71, 0x542b7dac)
00028 
00029 // class IBlockMgr
00030 //
00031 // This interface allows different parts of the system (max) and plugins
00032 // to work with blocks
00033 //
00034 // Right now, it provides very limitted functionality, the plan being to
00035 // extend it in the future as we identify functionality that can be factored 
00036 // out from FileLink into this object.
00037 class IBlockMgr : public FPStaticInterface
00038 {
00039     public:
00040     // Checks whether a node is a block instance. If yes, the method it returns 
00041     // a pointer to the block interface.
00042     // INode& n - is this node a block instance?
00043         virtual IBlockRefComponent* IsInstance(INode& n) const = 0;
00044 
00045         // Retrieves instances of a block. 
00046         // INode& source - The block whose instances are to be retrieved. 
00047         // INodeTab& instances - An array of nodes representing the instances the
00048         // given block. This array is cleared before collection of instances 
00049         // starts. The original object is also included in this array since every  
00050         // object can be thought of as having at least one instance. 
00051         // Return value - The number of instances found. There's always at least 1 instance found
00052         virtual unsigned long GetInstances(INode& source, INodeTab& instances) const = 0;
00053 
00054         // Extends a node with a IBlockRefComponent interface. 
00055         // If the node is a block component already, it does nothing
00056         virtual IBlockRefComponent* MakeBlockRefComponent(INode& n) const = 0;
00057 
00058         // Removes the IBlockRefComponent interface from the node
00059         virtual bool RemoveBlockRefComponent(INode& n) const = 0;
00060 
00061         // Returns the top block of the component passed in as param.
00062         virtual INode* GetTopBlock(INode& n) const = 0;
00063 
00064         // For each block in the node array that has components, 
00065         // adds these components to the array of nodes to be selected
00066         virtual void ExpandSelection(INodeTab& nodes) const = 0;
00067         
00068         // --- File I/O 
00069         virtual IOResult Save(ISave* isave) const = 0;
00070         virtual IOResult Load(ILoad* iload) = 0;
00071 
00072         static IBlockMgr* GetBlockMgr()
00073         {
00074             return static_cast<IBlockMgr*>(GetCOREInterface(BLOCK_MGR_INTERFACE));
00075         }
00076 }; 
00077 
00078 
00079 
00080