IOS中浏览和编辑CAD图纸
安装解压控件xcode开发包从我们官网下载“ MxDraw6.0iOs(20160923)TryVersion.exe”文件是个windows的rar自解压缩包,在Windows系统上,双击它解压,得到所有例子文件,开发库文件,如下:http://help.mxdraw.com/images/editor/20180118/15162413455134672.png把解压的目录,拷到MAC电脑上。
运行控件自带的例子
运行Xcode软件,打开控件例子, SRC\MxDraw6.0\Ios\Test\Test.xcodeproj ,如:https://admin.mxdraw3d.com/images/ueditor/1357929896021725184.png目前控件提供的开发包,只有真机运行的开发库,所以需要在MAC电脑上,连接iPhone手机,然后选择它,点运行即可。https://admin.mxdraw3d.com/images/ueditor/1357929970986520576.png
新建ios工程
运行Xcode软件,点新建工程,如下:http://help.mxdraw.com/images/editor/20180118/15162413954355878.png点击:“ Next”按钮,输入工程名MyTest,然后“Next”http://help.mxdraw.com/images/editor/20180118/15162414014931013.png工程路径选择控件安装目录下的Ios目录:http://help.mxdraw.com/images/editor/20180118/15162414104672697.png点击 Create 创建工程完成。
工程设置
设置 Other Linker Flags 增加连接设置 ,如下:-lsisl -lTD_Alloc -lTD_Root -lTD_DbRoot -lTD_Db -lTD_Ge -lTD_Gs -lTD_Gi -lTD_SpatialIndex -lTD_ExamplesCommon -lRecomputeDimBlock -lRasterProcessor -lModelerGeometry -lModelerCommands -lRxRasterServices -lTD_Br -lTD_BrepRenderer -lTD_AcisBuilder -lTD_PdfExport -lTD_PDFToolkit -lstsflib -lqpdf -lsisl -lpcre
如下抓图:http://help.mxdraw.com/images/editor/20180118/15162432997927259.png
设置 Library Search Paths 库文件搜索路径,如下:
$(SRCROOT)/../../../3rdparty/ODA/lib/iphone
$(SRCROOT)/../../../MxDraw6.0/prebuilt/iphone/release
如下抓图:https://admin.mxdraw3d.com/images/ueditor/1358312598533181440.png
设置 User Header Search Paths 头文件搜索路径 ,如下:
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/external
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/platform
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/platform/ios
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/editor-support
$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/external/glfw3/include/mac
$(SRCROOT)/../../MxInc
如下抓图:http://help.mxdraw.com/images/editor/20180118/15162433072035840.png
设置C语库使用:http://help.mxdraw.com/images/editor/20180118/15162433127538206.png
设置C++库使用:http://help.mxdraw.com/images/editor/20180118/15162433163473264.png
设置 C++语言宏定义:Debug定义:
DEBUG=1 $(inherited) CC_TARGET_OS_IPHONE USE_FILE32API COCOS2D_DEBUG=1
CC_ENABLE_CHIPMUNK_INTEGRATION=1 _MX_MACOSX _MXDRAW_SUPPORT_DWG
Release定义:
CC_TARGET_OS_IPHONE USE_FILE32API COCOS2D_DEBUG=0
CC_ENABLE_CHIPMUNK_INTEGRATION=1 _MX_MACOSX _MXDRAW_SUPPORT_DWG
如下抓图:http://help.mxdraw.com/images/editor/20180118/15162433219163771.png
禁用Bitcode:http://help.mxdraw.com/images/editor/20180118/15162433689083021.png
增加连需要库文件,在 SRC\MxDraw6.0\prebuilt\iphone\release 目录下,
libcocos2d iOS.alibMxArx60iOS.a libMxBase60iOs.a libMxBaseEx60iOs.a
libMxDraw60iOS.a libMxDwg60iOS.a libMxFile60iOS.a libMxGe60iOS.a
libMxKernel60iOS.a libMxPlatform60 IOS.a
如下图:http://help.mxdraw.com/images/editor/20180118/15162433323014722.png
http://help.mxdraw.com/images/editor/20180118/15162433379586058.png
增加梦想文件
拷贝 SRC\MxDraw6.0\Ios\Test\fonts 目录,到 SRC\MxDraw6.0\Ios\MyTest\fonts 。拷贝 SRC\MxDraw6.0\Ios\Test\mxdrawui 目录,到 SRC\MxDraw6.0\Ios\MyTest\mxdrawui 。把font目录和mxdrawui目录当前资源增加 Xcode工程中,如下:http://help.mxdraw.com/images/editor/20180118/15162442039246031.png
拷贝 SRC\MxDraw6.0\Ios\Test\Test\code 目录,到 SRC\MxDraw6.0\Ios\MyTest\MyTest\code 目录。在工程上,鼠标右键,在弹出菜单 上,点击“Add Files to "MyTest"”,把code下的文件增加到当前工程,如下:https://admin.mxdraw3d.com/images/ueditor/1358316788059869184.png
把文件ViewController.m改名为ViewController.mm,并在Xcode工程中,删除ViewController.m文件的引用,然后增加ViewController.mm。禁用新增加的ARC功能,使用 -fno-objc-arc 标志,如下:http://help.mxdraw.com/images/editor/20180118/15162442123941831.png
调用梦想cad
在新建的工程 UI增加一个按钮,并在按钮事件响应里调用如下代码,显示MxCAD:修改ViewController.mm文件:
#import "platform/ios/CCEAGLView-ios.h"
#import "cocos2d.h"
#import "mxcode/MxAppDelegate.h"
#import "mxcode/RootViewController.h"
RootViewController* viewController = nullptr;
CCEAGLView *eaglView = nullptr;
static MxAppDelegate s_sharedApplication;
在按钮点击事件里,显示 MxCAD代码:
- (IBAction)click:(UIButton *)sender {
if(viewController == nullptr)
{
cocos2d::Application *app = cocos2d::Application::getInstance();
s_sharedApplication.InitMxProtocol();
app->initGLContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
eaglView = .bounds
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
depthFormat: cocos2d::GLViewImpl::_depthFormat
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 4 ];
;
viewController = [ initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = eaglView;
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
cocos2d::Director::getInstance()->setOpenGLView(glview);
app->run();
cocos2d::Director::getInstance()->getEventDispatcher()->addCustomEventListener("returnCAD", [=](cocos2d::EventCustom* eve)
{
//call you return ;
[self present];
});
}
[self presentViewController:viewController animated:YES completion:nil];
}
所有工作已经完成,再在可以编译运行了。
页:
[1]