© 2011 autodesk porting objectarx ® applications and user interfaces to autocad ® for mac ®...

34
© 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

Upload: hortense-melton

Post on 24-Dec-2015

261 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Porting ObjectARX® Applications and User Interfaces to AutoCAD® for Mac®

Asheem MamoowalaSoftware Engineer, Autodesk

Page 2: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Agenda

Introduction Brief History of AutoCAD for Mac Compare Windows and Mac APIs Cross Platform Development Basics Mac User Interface Overview CUI Auto Loader

Page 3: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Introduction

Page 4: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Class Summary

This class shows how to completely port your existing Windows®-based ObjectARX applications to AutoCAD for Mac. Watch live coding demonstrations that will show you how to quickly compile your existing ObjectARX code for commands and custom entities on the Apple® Mac with XCode® developer software. Learn to re-create your dialogs and palettes using the Cocoa® framework and how to autoload your applications and CUI files into AutoCAD for Mac.

Page 5: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Learning Objectives

At the end of this class, you will be able to: Describe cross-platform coding techniques Port your code to Apple Mac Integrate your commands with AutoCAD for Mac menus and toolbars Develop native Apple user interfaces for AutoCAD for Mac

Page 6: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

AutoCAD for Mac

Page 7: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

AutoCAD for Mac History

AutoCAD supported 10+ platforms up to the early 90s This supported was dropped due to limited users

AutoCAD for Mac dropped after 2 releases (R12 and R13) Used cross-platform UI components including DCL

Mac support brought back with AutoCAD for Mac released in October 2010, and September 2011 Mac product line includes AutoCAD, AutoCAD LT, and AutoCAD WS

Page 8: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

AutoCAD for Mac

AutoCAD for Mac is 64-bit only

Supports OSX 10.6+ and Intel-based Macs

Uses Cocoa framework for UI Not cross-platform

Page 9: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

API Comparison

API Windows Mac

C++ (ObjectARX) YES YES

Win32 YES PARTIAL

MFC/ActiveX/COM YES NO

.NET (C#/XAML/WinForms/WPF)

YES NO

LISP YES YES

DCL YES NO

Qt YES YES

Objective-C/Cocoa NO YES

Page 10: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

API Comparison

On Windows, AutoCAD uses Fibers as an alternative to Threading.

Fibers are not available on the Mac CP322-1 Migrating AutoCAD Apps to the Fiberless Environment (AU 2010)

Page 11: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Porting and Development

Page 12: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Cross Platform Development Basics

64-bit Migration required ObjectARX provides polymorphic data types

String Handling OSX uses Unicode UTF16 whereas Windows uses UTF8 Conversion required between wchar_t or CString and NSString Careful about Unicode format differences

File paths Forward slash supported on all platforms Back slash only on Windows

Page 13: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Porting ObjectARX Code

Separate the commands and core logic from Windows-code Share static libs or source files between Windows/MFC DLL and Mac Bundle

Use Compiler to address warnings and errors Conflicting types Windows dependencies Compiler differences

Templates Unavailable APIs

Use polymorphic type Adesk::Int64 and Adesk::Boolean

Page 14: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

DEMO

Page 15: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Linking modules for Runtime

OSX has a couple different strategies for dynamically linking modules Dependent libraries

Loaded together Runtime-loaded libraries

Dynamically loaded

Requires setting up the Xcode confiugration files correctly Install Name and path Run-path Library search paths correctly

Otool –L <modulename> Tool for inspecting file references inside a compiled module

Page 16: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk 16

Linking modules for Runtime

Page 17: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

User Interface

Page 18: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

User Interface Overview

Uses Cocoa framework

Follows Apple OSX User Interface guidelines

Cocoa has equivalent controls for most MFC/Windows controls

Ribbon is replaced by ToolSets Customizable through CUI

Contextual Ribbon is replaced by Visor

Page 19: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Objective-C++

Allows mixing C++ and Objective-C in a single source file

Use ObjectARX APIs and C++ in the same module

Some ObjectARX types conflict with Apple’s Carbon/Cocoa APIs Be careful with .h includes

Objective-C++ only works if the .mm file type is used

Page 20: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Cocoa

Similar architecture to WPF

Uses the Model-View-Controller pattern Stricter than MFC Stray too much and bugs will be harder to fix

UI Controls expose delegates as an alternative to sub classing

Objects are reference counted and need to be managed correctly

Page 21: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Modal Dialog

Use Interface Builder to Layout controls Associate with Action methods in Code Data binding

Show a dialog using [NSApp runModalForWindow:]

NSWindowController

In .mm files you can mix Objective-C with ObjectARX’s C++ APIs

Page 22: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

DEMO

Page 23: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Modeless Windows

Use NSPanel subclass of NSWIndow AutoCAD Palettes do not use the Cocoa HUD-

Style

Show a palette using [NSWindowController showWindow:]

Use reactor notifications same as you would in MFC

Must un-bind elements when closing or unloading the window

Page 24: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

CUI and AutoLoader

Page 25: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

CUI

Supports a subset of the CUI extensibility that Windows does Add Command Macros

Includes Icons and Tooltips Add entire ToolSets, or panels to existing ToolSets Add Menus

The format of the .CUIx file is shared

CUI Command and dialog have been ported partially and can be used to create and edit CUI files

Page 26: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Partial CUI

ObjectARX applications can provide a partial CUI for their own Commands

Must be installed inside your ARX bundle in MyArx.bundle/Contents/Resources

Place reference images in the same folder

No Debug tools available for errors when loading Partial CUIs Create entries in the AutoCAD for Mac CUI dialog Extract from the CUI file /Users/<username>/Library/Application Support/Autodesk/roaming/AutoCAD

2012/R18.2/enu/Support/

Page 27: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Partial CUI Sample

Page 28: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

AutoLoader

New system for automatically loading 3rd party ARX applications into AutoCAD

Requires Installation of ARX bundles to /Application/Autodesk/ApplicationPlugins/ Inclusion of a PackageContents.xml definition file

AutoCAD will auto-load your components ARX applications Partial CUI files LISP files

Page 29: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

AutoLoader PackageContents

Page 30: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

DEMO

Page 31: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Summary

Port Windows ARX application by separating core logic from Windows-specific code

Implement Mac UI in Cocoa

Use Partial CUI to integrate your application into AutoCAD for Mac

Leverage the autoloader feature to deploy and load your ARX application

Page 33: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Thank you!

Page 34: © 2011 Autodesk Porting ObjectARX ® Applications and User Interfaces to AutoCAD ® for Mac ® Asheem Mamoowala Software Engineer, Autodesk

© 2011 Autodesk

Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2011 Autodesk, Inc. All rights reserved.