扩展opencascade的tcl命令vdisplayall

occ每次都要通过vdisplay name才能显示

而vdisplayall只能显示被隐藏的对象,而且需要打很多字符

比较讨厌,可以扩展一下直接显示所有对象,并使用很短的命令名称,方便使用

 

方法:

打开项目TKViewerTest》ViewerTest.cxx

添加代码:

static int VDisplay2(Draw_Interpretor&, Standard_Integer, const char**);
static int VDisplayAllMy(Draw_Interpretor& di,
    Standard_Integer  theArgNb,
    const char** theArgVec)
{
    char* args[] = { "", 0 };
    NCollection_Map<Handle(Draw_Drawable3D)>::Iterator aMapIt(Draw::getDrawables());
    for (; aMapIt.More(); aMapIt.Next()) {
        const Handle(Draw_Drawable3D)& D = aMapIt.Key();
        if (!DBRep::GetExisting(D->Name()).IsNull()) {
            args[1] =(char*) D->Name();
            VDisplay2(di, 2, (const char**)args);       
        }
    }
    return 0;
}


搜索 vdisplayall, 在下面添加代码:

  theCommands.Add("vdisplayall",
      "vdisplayall"
      "\n\t\t: Displays all erased interactive objects (see vdir and vstate).",
      __FILE__, VDisplayAll, group);
  theCommands.Add("mydisplayall",
      "mydisplayall"
      "\n\t\t: Displays all interactive objects",
      __FILE__, VDisplayAllMy, group);

打开项目TKDraw》Draw_VarialbeCommands.cxx, 找到theVariables定义,增加:

static NCollection_Map<Handle(Draw_Drawable3D)> theVariables;
const NCollection_Map<Handle(Draw_Drawable3D)>& Draw::getDrawables(){
    return theVariables;
}

同时在Draw.hxx增加导出声明

  Standard_EXPORT static const NCollection_Map<Handle(Draw_Drawable3D)>& getDrawables();

 

posted @ 2021-05-28 13:40  wiki3D  阅读(183)  评论(0编辑  收藏  举报