• Catia 二次开发资料(转)


    Catia 二次开发

    CATIA V5在开发之初就遵循面向对象的设计思想(OO),构建了完全基于组件的体系结构(PPR: Products,Process,Resource),有效地解决了维护、管理、扩展的困难,并大量使用了最新的计算机技术和标准以及软件工程技术,其中包括基于组件架构思想的JAVA BEAN 、COM/OLE、CORBA 技术和Web技术、C++语言、Visual Basic Journaling 、STEP-SDAI、XML、OpenGL等,这使CATIA V5具有与众不同的鲜明的特点:数据结构单一,各个模块全相关,某些模块之间还是双向相关;端到端的集成系统,拥有强大的专业应用扩展能力。
         1.软件组件结构(SCI: Software Component Infrastructure)的基本概念
          软件组件结构(SCI)是软件工程继过程模型和面向对象模型的下一代逻辑模型。面向对象技术已在许多重要应用中取得成功。
          但是,随着更多面向对象解决方法的开发和使用,很显然的是,单单采用面向对象技术难以与软件日益增长的复杂性抗衡。因为,对象只构成应用程序的一部分。它完全不能把握应用程序的结构(控制流)。只能通过重用类库里有的类来实现有限的重用。但实际情况是,大量应用程序,特别是同一领域(DOMAIN)中的应用程序,分享相似的结构。不同的程序员使用不同的技术去把握和实现这些相似的结构。结果,这些结构并没有经过通常的面向对象技术而被重用。
               面向对象技术只能通过重用类库已有的类来实现有限的重用,而软件组件结构(SCI)提供了最高层次的代码重用。
              软件组件结构(SCI:Software Component Infrastructure)有三个基本的概念:框架(FRAMEWORK)、组件(Component)和对象总线(Products Bus)。
             组件(Component):是软件的基本量子(单元)。组件既应当足够小,以便于维护;又应足够大,可具备相当的功能,可以被打包和插用。由于传统的客户/服务器应用不能应付软件应用日益增加的复杂性。它们不能加入到即插即用的环境之中。组件的特征提供了将一个应用程序分成若干个组件的机制。每个组件提供了一个相当专门的功能,它向框架的其余部分描述自己,以便别的组件能够访问它的功能。描述是通过说明性语言如IDL实现的,它本质上是把组件的接口与实现分离开来。由于组件是可单独维护、升级的,因此,组件不直接与别的组件通信是至关重要的。它必须通过使用框架或对象总线来实现组件之间的交互。
          框架(FRAMEWORK):框架提供对所有应用程序有用的功能(如接口、存储)。它提供了统一的总设计。框架是对相似应用程序集合的一个部分(统一但不完整)解决方案。开发者的任务是用这不完整的解决方案加上必要的代码建立完整的应用。在领域(DOMAIN)内的一个应用包括不变部分和可变部分。不变部分由框架把握,一般可占到80%,可变部分由开发者把握,一般可占到20% 。开发者通过向框架添加变化部分的代码把握其动作,而形成新的特定应用。框架根据是否针对特殊领域还是若干领域,可分为水平框架、垂直框架、复合文挡框架。 
           对象总线:对象总线是基本的中间件。它允许成千上万能够相互理解接口定义语言IDL的对象相互发生作用。这种作用对对象来说是完全透明的。对象总线把组件和框架的能力扩展到开放网络和其它伙伴应用程序。它使成千上万独立的软件单元在由不同操作系统、语言、硬件平台和编译工具组成的环境下互相无缝地交互运作。对象总线不仅提供对象之间的连接,它还提供对在总线上所有对象都有用的核心服务集(对象服务)。如:生命周期服务程序、安全性、持久性、命名等。    通过组件构造/修改软件,用框架把握软件结构,用对象总线连接事务,支持即插即用(Plug & Play)功能的扩展。   2.CATIA V5体系结构(Architecture Infrastructure)   CATIA V5的体系结构(Architecture Infrastructure)是一种面向行业应用的垂直框架体系结构,组件是CAD/CAM系统的各种几何特征和管理、分析单元。框架是一些应用如:2D/3D建模、分析、混合建模、制图、数控加工等,CATIA V5也称为领域(DOMAIN)或应用(APPLICATION)。并通过3D PLM PPR(PRODUCTS,PROCESS, RESOURCE)HUB产品总线连接起来。

    1、Application window和document window类似于mfc中的CMainFrame和CView的关系

    2、workshop是workbench的一个集合

    3、CATIWorkbenchTransition interface

    4、CATApplicationFrame

    5、CATFrmEditor 类起检索按钮是否可用的功能等

    6、In Short
    The CAA V5 application window includes commands which are common to all documents in menus and in the standard toolbar. Each document type is associated with a workshop which includes commands arranged in menus and toolbars which are added to the common menus and to the standard toolbar. Changing the active document to another document changes the active workshop if the new active document's type is different from the type of the previous document. A workshop can include workbenches to gather commands dedicated to specific tasks to structure the end user interface. One workbench only can be active at a time.

    7、The application layout is provided by the non-exposed CATApplicationDocument class

    8、The main methods of the CATApplicationFrame class are:

    GetFrame             This static method returns the unique instance of this class.
    SetMessage       To set a message in the status bar. 
    GetApplicationDocument This method returns the CATApplicationDocument class instance
    GetMainWindow    This method returns: 

    9、CATIDocumentEdit interface is used to create the default window to display the document

    10、The CATFrmLayout Class
    This class manages all the windows created. It

    11、The CATFrmLayout class enables you to activate a new window

    12、You have to respect only one rule: all the dialog objects must be inside a frame created by the CATFrmWindow class:

    13、HRESULT CAAEMyInterface::CreateWindow() 
    {
       1/ Creating the new window
       2/ Managing the base name
       3/ Declaring the window as current
    }
    ...   

    14、In Short
    This article enables you to understand the role of the main objects defining or managing the V5 interactive application.

    CATApplicationFrame
    This class has only one instance during the session. You essentially use it to retrieve the dialog parent of your dialog box.

    CATFrmLayout
    This class has only one instance during the session. Its role is to manage all the document windows. You use it to retrieve windows and to define the current one.

    CATFrmEditor
    This class controls the visualization and the interactivity of the document. It is the C, in the MVC paradigm, where M is the document and V the window.

    CATFrmWindow
    It is the base class of all the classes defining a window to display a document.

    15、The CATApplicationFrame class
     This CATApplicationDocument class instance is built by the CATApplicationFrame class instance.

    The main methods of the CATApplicationFrame class are:

    GetFrame             This static method returns the unique instance of this class.
    SetMessage       To set a message in the status bar. 
    GetApplicationDocument This method returns the CATApplicationDocument class instance
    GetMainWindow    This method returns: 

    MyDialogBox will be automatically hidden when the editor will be deactivated. Therefore if you need a dialog box always visible, and independent of the life of the document, its parent must be the CATApplicationDocument class instance returned by the GetApplicationDocument method. You can also read the "Defining Headers in CATIAfrGeneralWksAddin Implementations" section in the technical article about the command headers

    A property sheet is a tabbed dialog box, each tab containing a property page

    This  CATEditorManager  object is used by the application to create and manage property pages

    The CSO contents is retrieved and passed to the ExtractFromSelection method of each property editor

    These methods are those of the CATIEditProperties interface and are either pure virtual or empty in their CATEditor implementation. You should provide their body to make them play the following role:

    ExtractFromSelection returns the list of objects found in the Current Set of Objects (CSO) that implement the property interface
    GetEditorTitle returns the property page title
    SetEditorSize lets you request which size you need to accommodate your property page, among the possible values: small, medium, or large
    BuildEditor instantiates the associated dialog class
    SetPropertyValue sets the values and options in the property page dialog from the objects
    CommitModification applies to the selected objects the modifications made to values and options in the property page dialog.
    CancelModification is empty, but exists and could be used to delete temporary objects that could possibly be allocated in previous methods
    CloseWindowFromEditor is called whenever the end user selects another property page.
    The methods ExtractFromSelection, GetEditorTitle, SetEditorSize, BuildEditor, and SetPropertyValue are executed in this order when instantiating the property page.

    When the end user clicks:

    OK, the CommitModification method is executed and the window is closed
    Apply,  the CommitModification method is executed, but the window is not closed
    Cancel, the CancelModification method is executed and the window is closed
    Close, the window is closed.
    SetPropertyValue, CommitModification, and CancelModification call in turn the methods with the same name of the associated dialog class.

    Current Set of Objects (CSO),

    In memory the setting file is represented by a setting repository, an instance of the CATSettingRepository class

    A property page divided in sections
    This dialog is a class that derives from CATDlgFrame

    Creating a property page for the Tools/Options menu implies to create a property page editor factory, a property page editor class instantiated by this factory, and to supply a property page dialog class gathering the controls to access the parameters and values you let the end user access and modify.

    Setting Attributes versus Parameters
    The setting repository contains setting attributes accessible thanks to the ReadSetting and WriteSetting methods. Using these methods ties the code to the formats and locations of the attributes

    Model View Controller (MVC

    What Is a CAA Command?
    A CAA command is an instance of a class deriving from the CATCommand class and that supports these interactive mechanisms:

    Desactivate is called when a shared command takes the focus from the active command

    A command header instance is always an instance of a class deriving from the CATCommandHeader class

    To avoid to fill up uselessly the list of CATCommandHeader instances, it is recommended to make the command header instantiation only in the following methods because these methods are called once for each instance of editor: CreateCommands of the workbench implementations [4] CreateCommands of the add-in implementations (*) [5]

    To create a standard command header class, you can use the MacDeclareHeader macro. It creates for you a class which derives from CATCommandHeader which is the base class for command headers and should never be directly instantiated.

    This Dialog command contains:

    The list of current entities. This list is always in this order:
    The workshop defined by the frame application (CATAfrGeneralWks)
    The current workshop (those of the current UI-active object)
    The Add-ins of the current workshop
    The current workbench
    The Add-ins of the current workbench

    The Dialog box must manage its life cycle. When the end user clicks the Close button, or the Close/Cancel buttons if they exist, the Dialog box is deleted (by a RequestDelayedDestruction on itself)

     command header stands for a command and avoids to load the command when the end user does not require it. A command header is an instance of a command header class. This class can be used for several commands, and can be created either using a macro or explicitly if the command header should manage availability information or customize its representation.

    It is possible to re-use command header identifiers, but there are two rules to respect:

    In a workbench or in an add-in (workshop/workbench) avoid to use an identifier coming from another workbench or workbench's Add-in.
    In a contextual menu do not use an identifier coming from a workbench or a workbench's Add-in, but only coming from the workshop or an workshop's add-in.
    The "Workshop Exposition" command enables you to retrieve the command header identifiers.

    There are two command header resource files:

    The resource file containing the title and help messages in the English language, and that can be translated into other languages. It is suffixed using CATNls
    The resource file containing the icons and other resources that should not be translated. It suffixed by CATRsc

    In Short
    The command header resources are provided in two files whose names are the command header class, or the name set by the CATImplementHeaderResources macro in the command header cpp file. One file is for those that can be translated and is suffixed CATNls, the other for the icon names or pointer to a help file and is suffixed CATRsc. The resources are provided using keys built with the identifier of the object to which they apply.

    In Short
    The workshop resources are provided in two files whose names are the workshop identifier. One file is for those that can be translated and is suffixed CATNls, the other for the icon names and is suffixed CATRsc. The resources are provided using keys built with the identifier of the object to which they apply.

    public class CATCommandHeader

    Class to create a command header.
    Role: Each command you want to make available in your workshop or workbench must have a command header. It holds the necessary information to load the command, such as the name of the shared library in which the command's executable code is located, the name of the command class, and the data to pass to the command's code when this command becomes the current one.

    The command header has resources for each command to display, such as the command name shown to the end user, its ToolTip displayed in a balloon, it help message, and its icon. This enables the workshop or workbench to be displayed, that is loaded in memory, without any of its commands being itself loaded, except the default one, spares memory space, and improves performance. The end user can see the icons in the toolbars, the items in the menu bar, can ask for help on a given command, without the command being loaded. It is only when he/she clicks on the menu item or on the icon that the command code is actually loaded.

    You cannot directly instanciate a CATCommandHeader, you must derive this class. The easiest way is using the MacDeclareHeader macro such that:

        #include "CATCommandHeader.h"
        MacDeclareHeader(MyHeader);

    System Macro CATImplementClass
    Macro CATImplementClass (Class,Typeofclass,Basemeta,Impmeta)

    Declares an implementation or extension class.
    Role: Declares that the current class is either an implementation or an extension class. The class must derive from CATBaseUnknown. Use this macro in the class source (.cpp) file in conjunction with CATDeclareClass in the class header file. End it with a semicolon.

    System Macro CATDeclareClass
    Macro CATDeclareClass (private)

    Declares an implementation or extension class.
    Role: Declares that the current class is either an implementation or an extension class. The class must derive from CATBaseUnknown. Use this macro in the class header file in conjunction with CATImplementClass in the class source (.cpp) file. End it with a semicolon.
    --------------------------------------------------------------------------------
    This object is included in the file: CATMacForIUnknown.h

  • 相关阅读:
    前端工程化
    前端模块化CommonJS&ES6
    为什么浮点型运算结果会有误差?
    RequestAnimationFrame知多少?
    CSS三栏布局
    秋招面试
    实现Storage
    Angular
    TypeScript
    微服务架构设计模式
  • 原文地址:https://www.cnblogs.com/tdskee/p/3796198.html
Copyright © 2020-2023  润新知