The DWG Viewer emphasizes how to embed the framework into a stand alone application and covers basic viewing and editing capabilities.
...
Features
Viewer object
Load drawing
Close drawing
Change viewing modes
Change layout background color
Switch between model and sheets
DWG Viewer - Viewer object
Status | ||
---|---|---|
|
The most important step is to embed the viewer object and connect it with the host application. The viewer object CFxARESDocumentView can be used and configured in a simple view controller or inside the storyboard. This object is a member of the host application. The host application’s main class is the AppDelegate that has a synergy with a class named CFxAresDelegate . The CFxAresDelegate is derived from CFxARESInstanceDelegate, is the core piece between the host application and the kernel SDK and must be initialized with the singleton [CFxARESInstance instance] from the main class. The kernel SDK starts to render the drawing into the CFxARESDocumentView object that will be accessed by getDocumentView from the CFxAresDelegate when a document is loaded successfully.
Note: The host application’s main class may be directly used as CFxARESInstanceDelegate but it is easier to split both parts of the application.
File: ViewController.h
Code Block |
---|
@property (weak, nonatomic) IBOutlet CFxARESDocumentView *m_DocumentView; |
File: AppDelegate.m
Code Block |
---|
-(void)startARESInstance:(NSString*)login password:(NSString*)password
{
...
aresDelegate = [[CFxAresDelegate alloc] init];
[CFxARESInstance instance].delegate = aresDelegate;
inputDelegate = [[UserInputDelegate alloc] init];
[[CFxARESInstance instance] userInput].inputDelegate = inputDelegate;
[[CFxARESInstance instance] startWith:login password:password];
uiDelegate = [[CommonUIDelegate alloc] init];
[CFxCommonUI startWithDelegate:uiDelegate];
...
} |
File: CFxAresDelegate.m
Code Block |
---|
-(CFxARESDocumentView*)getDocumentView
{
return [self getMainView].m_DocumentView;
} |
DWG Viewer - Load drawing
Status | ||
---|---|---|
|
The DWG Viewer reads all drawings from the Support folder of the IPA. This may result in a slower opening and rendering time. It is recommended to load drawings from a local or external folder of the device. The drawing is loaded with the OPEN command using the runCommand method of the singleton [CFxARESInstance instance]. Once the drawing is loaded the CFxAresDelegate triggers documentCreated and the CFxARESDocumentView can become visible. This is the time when additional user interfaces can show up or drawing content can be accessed. In general, the CFxAresDelegate informs the host application about all important drawing events.
Note: The framework supports opening DWG, DXF and DWT files.
File: CFxAresDelegate.m
Code Block |
---|
-(void)documentCreated
{
[CFxARESInstance runOnUiThread:^
{
[self getMainView].m_DocumentView.hidden = NO;
}];
} |
File: ViewController.m
Code Block | ||
---|---|---|
| ||
-(void)viewDidAppear:(BOOL)animated
{
...
NSString* command = @"_OPEN\n";
command = [command stringByAppendingString:document];
command = [command stringByAppendingString:@"\n"];
[[CFxARESInstance instance] runCommand:command];
...
} |
DWG Viewer - Close active drawing
Status | ||
---|---|---|
|
The active drawing is closed with the CLOSE command. When the document is closed the CFxARESDelegate triggers documentDestroyed , the drawing is removed from the memory and the CFxARESDocumentView can become hidden. The host application can set up the user interface for a new drawing like switching between state view controllers.
File: CFxAresDelegate.m
Code Block | ||
---|---|---|
| ||
-(void)documentDestroyed
{
[CFxARESInstance runOnUiThread:^
{
[self getMainView].m_DocumentView.hidden = YES;
...
}];
} |
File: ViewController.m
Code Block |
---|
-(IBAction)onClosePressed:(id)sender
{
...
[[CFxARESInstance instance] runCommand:@"_CLOSE\n"];
} |