iOS: DWG Editor
The DWG Editor carries the basic features and extends the creation and editing capabilities of entities.
Features
Create new drawings
Change system variable CECOLOR
Offer basic drawing and editing tools
List and insert existing block definitions
DWG Editor - Create new drawings OBJ-C
The DWG Editor uses the command SMARTNEW to create a new document. The command is executed with -(void)runCommand:(NSString*)command method of the singleton [CFxARESInstance instance]. Once the drawing is loaded the CFxAresDelegate triggers -(void)documentCreated and the CFxARESDocumentView can become visible.
Note: Templates can be opened with command NEW. A possible command expressions will work like this "_NEW\n" + fileName + "\n";
File: ViewController.m
-(void)viewDidAppear:(BOOL)animated
{
...
if ([m_sDrawingName length] == 0)
{
// SMARTNEW command will create new document.
[[CFxARESInstance instance] runCommand:@"_SMARTNEW\n"];
[[CFxNativeConnection GetNativeConnection] AddSheetButtonsTo:m_StackSheets.firstObject];
return;
}
...
}
DWG Editor - Change system variable CECOLOR OBJ-C C++
The DWG Editor uses a native method to change the database variable CECOLOR, the current entity color when created. The offered color indexes are provided by a custom color panel. The necessary native method -(void)SetCEColor:(NSInteger)color is called when the dedicated color button is tapped. The method accesses the C++ part of the application and must be executed within the working thread. A suitable method +(void)runOnWorkingThread:(dispatch_block_t)block is provided by [CFxARESInstance]
File: ViewController.m
-(void)onColorSelected:(UIButton*)button
{
[[CFxNativeConnection GetNativeConnection] SetCEColor:button.tag];
}
File: CFxNativeConnection.mm
-(void)SetCEColor:(NSInteger)color
{
[CFxARESInstance runOnWorkingThread:^
{
OdCmColor odColor;
if ( color == OdCmEntityColor::kByLayer )
odColor.setColorMethod( OdCmEntityColor::kByLayer );
else
odColor.setColorIndex( color );
OdEditorImplPtr pEditor = odedEditor();
pEditor->fire_modelessOperationWillStart( L"CECOLOR" );
ACTIVE_DOCUMENT()->GetFxDatabase()->setCECOLOR( odColor );
pEditor->fire_modelessOperationEnded( L"CECOLOR" );
}];
}
DWG Editor - Offer basic drawing and editing tools OBJ-C
The DWG Editor resorts to commands like LINE, CIRCLE and POINT to provide basic 2D drawing tools and commands like MOVE, SCALE and DELETE for basic editing features. The commands can be easyly executed with -(void)runCommand:(NSString*)command method of the singleton [CFxARESInstance instance].The commands to choose are offered by a custom command panel. All commands require user actions to start. User actions are controlled by the default user input interface.
Note: The DWG Expert explains how to overwrite the default user input and create a custom feature that fits better inside the host application.
File: ViewController.m
DWG Editor - List and insert existing block definitions OBJ-C C++
The DWG Editor uses a native method -(void)GetBlocksWithHandler: to get all available block definitions of the drawing when - (IBAction)onInsertBlockPressed: is triggered. The DWG Editor provides a button “INSERT BLOCK”, when tapped a list of all available blocks is processed and shown with a simple UIAlertController. When a block is chosen , a suitable command expression using the command -INSERTBLOCK is created and executed with -(void)runCommand:(NSString*)command method.
File: CFxNativeConnection.mm
File: ViewController.m