OPM中细节设置

news/2024/11/24 9:04:04/

OPM中提供属性分类

常规的使用如下方法

BEGIN_OPMPROP_MAP()
OPMPROP_ENTRY(0, DispID, PROPCAT_Data,0, 0, 0, “”, 0, 1, IID_NULL, IID_NULL, “”) 
END_OPMPROP_MAP()

其中DispIDP是R属性的 显示ID;OPCAT_为前缀的就是已经预定义的属性分类,其数值范围是-1~-25。

如果需要自定义分类,则需要在PROPCAT_的位置上设为自定义的数值,然后 在头文件中改写

STDMETHODIMP GetCategoryName(
/* [in] */ PROPCAT propcat,
/* [in] */ LCID lcid,
/* [out] */ BSTR* pbstrName)
{if (propcat == 1){*pbstrName = ::SysAllocString(L”SQSize”);return S_OK;}elsereturn S_FALSE;
}

注意看原来例程的写法,按照那个写法程序不会调用这个函数。我也不知道为什么。
执行完这个函数后,GetElementStrings函数被调用。
这个函数的作用就是分解复杂的属性,如当你所描述的属性是一个点时,你需要将x,y,z的坐标同时显示在属性窗
口中。 这个函数就是你实现如何分解这些属性。当然也可以不实现它。
AsdkSquareWrapper例程里没写清楚地好像就是这些了。我的表达能力不好,希望大家能看明白。

OPM中属性的下拉列表的支持

扩展属性中实现 下拉列表

接口需要继承

    public IOPMPropertyExtensionImpl

实现其中的

//OPM calls this function for each property to obtain a list of strings and cookies if they are available.
//For our textstyle property we would like to display all the textstyles currently available in the database.
//This function is declared on the IPerPropertyBrowsing interface. Our IOPMPropertyExtensionImpl
//class implements this member by reading the values in the OPM property map. (You set this up in your
//head file when you use BEGIN_OPMPROP_MAP, OPMPROP_ENTRY, END_OPMPROP_MAP macros.)
//Since we need a dynamic list of entries in this drop down list and a static map cannot implement this, 
//we need to override this function a provide dynamic list of text styles to OPM.STDMETHOD(GetPredefinedStrings)(/* [in] */ DISPID dispID,/* [out] */ CALPOLESTR *pCaStringsOut,/* [out] */ CADWORD *pCaCookiesOut);//OPM calls this function when the user selects an element from a drop down list. OPM provides
//the cookie that we associated with the element in the GetPredefinedStrings function. We are
//responsible for mapping this cookie back to a value that the properties corresponding put_ function
//can understand. 
//In this particular case all we need to do is to provide the name of the text style as
//the put_TextStyle method needs that.STDMETHOD(GetPredefinedValue)(/* [in] */ DISPID dispID, /* [out] */ DWORD dwCookie, /* [out] */ VARIANT *pVarOut);

具体实现的思路就是根据不同的 dispID 设置不同的列表
具体实现方法可以参考polysamp
注意:上述函数返回值是和get/put系列函数的形参严格对应,自动过滤掉不符合的项。


How to create a polyline-like vertex edit with a spin control in OPM?

http://adndevblog.typepad.com/autocad/2012/12/how-to-create-a-polyline-like-vertex-edit-with-a-spin-control-in-opm.html
By Gopinath Taget

The following snippets of code can be used to implement a polyline-like vertex edit in OPM (Object Property Manager) using IOPMPropertyExpander interface for a custom entity.

Lets assume the custom object (called AsDkRings) has two new variables to reflect an array of vertices:

AcGePoint3d m_polyline[5]; int m_numbervertices;

For simplicity, lets say the custom entity has a maximum of five vertices.

The custom class also has two corresponding access functions. (Note the vertex number parameter):

Acad::ErrorStatus AsDkRings::polyline(AcGePoint3d& vertex, int vertexNumber)Acad::ErrorStatus AsDkRings::setPolyline(AcGePoint3d vertex,int vertexNumber)

In AsDkRings:: subWoldDraw(), we draw a polyline connecting the five vertices.

The key to getting a spin control in OPM is to return a grouping number. This number will determine the number of elements to group together.

//IOPMPropertyExpanderSTDMETHODIMP CRings::GetElementGrouping(/* [in] */ DISPID dispID,/* [out] */ short *groupingNumber){..........................} else if (dispID == 5){*groupingNumber = 4;return S_OK;}return E_NOTIMPL;}

A grouping number of 4 means there is one entry (called "Vertex") plus 3 entries (Vertex X, Y and Z) to group together into one property. What this would do is put a spin control into the first item (vertex in this case), so that this could be used to traverse an array of 3 remaining grouped items (which is Vertex X, Y and Z).

Next, we should specify the number of items that the property is going to display. Here this would be the number of vertices = 5. This would mean that the spin contol can go up to a maximum of 5 steps, for five vertices.

//IOPMPropertyExpanderSTDMETHODIMP CRings::GetGroupCount(/* [in] */ DISPID dispID,/* [out] */ long *nGroupCnt){...............................} else if (dispID == 5){*nGroupCnt = m_numbervertices; // Number of verticesreturn S_OK;}return E_NOTIMPL;}

Next, we set the string to display in the OPM.

//IOPMPropertyExpanderSTDMETHODIMP CRings::GetElementStrings(/* [in] */ DISPID dispID,/* [out] */ OPMLPOLESTR __RPC_FAR *pCaStringsOut,/* [out] */ OPMDWORD __RPC_FAR *pCaCookiesOut){................................................................} else if (dispID == 5){// For the VerticespCaStringsOut->cElems = 4;pCaStringsOut->pElems = (LPOLESTR*)CoTaskMemAlloc(sizeof(LPOLESTR)*4);pCaStringsOut->pElems[0] = SysAllocString(L"Vertex");pCaStringsOut->pElems[1] = SysAllocString(L"Vertex X");pCaStringsOut->pElems[2] = SysAllocString(L"Vertex Y");pCaStringsOut->pElems[3] = SysAllocString(L"Vertex Z");pCaCookiesOut->cElems = 4;pCaCookiesOut->pElems = (DWORD*)CoTaskMemAlloc(sizeof(DWORD)*4);pCaCookiesOut->pElems[0] = 10;pCaCookiesOut->pElems[1] = 1;pCaCookiesOut->pElems[2] = 2;pCaCookiesOut->pElems[3] = 3;return S_OK;}return E_NOTIMPL;}

The cookies count is the unique identifier for each property item that will be used to get and set values. The table below will give you an idea of cookie value for each vertex value. Please remember that vertex entry has a spin control that goes like 1, 2, 3, 4.........and so on.

Property StringCookie Value
Vertex = 1Vertex = 2Vertex = 3Vertex = 4....and so on
Vertex04812....and so on
Vertex X15913....and so on
Vertex Y261014....and so on
Vertex Z371115....and so on

So just by using the cookie values, you must get the vertex number and find out if it is an x, y, or z coordinate. The following code does that.

// Get the coordinate index (x=0, y= 1, z=2) from dwCookie

for (int i = 1; i < 4; i++) {vertex = (double(dwCookie) - i) / 4;if( vertex == (double(dwCookie) - i) / 4) {index = i -1;break;}}

index will return 0 for vertex X, 1 for vertex Y and 2 for vertex Z for the corrosponding cookie values.

So this is all that is needed to implement a poly-line vertex edit.

转载于:https://www.cnblogs.com/kevinzhwl/p/3897702.html


http://www.ppmy.cn/news/706071.html

相关文章

cad考试题库绘图题答案_CAD考试试题库和参考答案解析

CAD WORD资料.可编辑 CAD考试试题库及参考答案 一、单项选择 1、AUTOCAD的坐标体系,包括世界坐标和( D )坐标系。 A、绝对坐标 B、平面坐标 C、相对坐标 D、用户坐标 2、当进入了AUTOCAD环境中(即AUTOCAD的图形编辑器)时,缺省时所建立的坐标系统为( B ) A、用户坐标系 B、世界…

ObjectARX自定义对象的OPM

在AutoCAD绘图工作中&#xff0c;经常用到特性面板&#xff0c;它可以方便地查询、修改CAD对象的详细信息&#xff0c;如颜色、线型等&#xff0c;它是一个非常实用且便捷的工具。如果能为自定义对象添加一个特性面板&#xff08;OPM&#xff09;,这无疑是众多初学者极感兴趣的…

cesium时间轴格式化为北京时间

中心思想&#xff1a;使用JulianDate.addHours()方法&#xff0c;将时间8. 效果&#xff1a; 初始配置&#xff1a;创建viewer时打开时间轴的配置&#xff08;默认打开&#xff09;&#xff0c;动画配置shouleAnimate为true。 // timeline: false, // animation: false, shou…

高压线路零序电流方向保护程序逻辑原理(三)

四、零序保护故障处理程序原理 零序保护逻辑程序可分为三个模块&#xff1a;快速动作部分、全相循环和非全相循环模块。这是根据零序保护的特点而设计的。任何一种高压线路保护都要求快速处理I段范围内的严重故障&#xff0c;所以零序保护与距离保护一样配有快速动作部分程序模…

一卡通管理系统需求分析

一卡通管理系统需求分析业务需求 1&#xff0e;业务目的&#xff1a;将校园的各类消费与身份认证功能集成在一卡通&#xff0c;实现“一卡在手&#xff0c;走遍校园”。为在校的师生和教学管理人员提供具有开放性的、灵活性的管理平台。 2&#xff0e;业务目标&#xff1a;实现…

0602 信用卡防盗刷学习总结

前言 国内出境游高企,为了方便游客,很多银行都推出了支持境外消费的信用卡。然而,近年来卡未离身却遭遇境外网上盗刷的案件呈高发态势,其原因在于国外信用卡网上消费的验证程序与国内不同,像亚马逊、eBay等国外电商,其网络消费仅需信用卡卡号及卡片背面的CVV2码(签名档…

如何实现多 Tab 同步登陆和退出

一. 场景再现 前两天接到一个需求&#xff0c;要求实现类似于 B站 的那种&#xff0c;当我同时打开多个 Tab 标签的时候&#xff0c;如果我在某一个窗口退出了&#xff0c;那么其它窗口的登陆状态也需要同步退出。如下图&#xff0c;我同时打开了两个 tab 。 当我点击其中一个…

基于jsp+Servlet+mysql的汽车销售系统

基于jspServletmysql的汽车销售系统 一、系统介绍二、功能展示1.项目骨架2.登录界面3.首页4.购物车5.添加车辆6、编辑车辆信息 四、其它1.其他系统实现五.获取源码 一、系统介绍 项目类型&#xff1a;Java web项目 项目名称&#xff1a;基于JSPServlet的汽车销售系统 项目架…