Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 10 Next »

The Android sample project includes multiple samples of how custom commands or database related features can be used inside a Java hosted application. The project provides the following samples:

  • DrawCirclesCommand

  • CustomEntity

  • CreateText

  • DrawTemporaryEntities

  • SelectObjects

  • DocumentCommands

  • GetClosestOsnap

Note: Additional samples will be included in further updates.

Module

Short Description

DrawCirclesCommand

The sample DrawCirclesCommand introduces the most important technique: the command. A command name must be unique and can be executed by runCommand(). The command (DrawCircleCommand) shows how to access the document database, invoke user prompts and create entities using a custom tracker (CDrawCircleTracker). For more details please also check the comments in the source and header files.

CustomEntity

The sample SpecialEntity demonstrates how a custom entity is created and registered. The custom entity inherits from base class OdDbCircle and is transformed visually by overwriting the entity's subWorldDraw() method. For more details please also check the comments in the source and header files.

CreateText

Coming soon …

DrawTemporaryEntities

Coming soon …

SelectObjects

Coming soon …

DocumentCommands

Coming soon …

GetClosestOsnap

Coming soon …

C++ Modules - OdRxModule and CFxCommand
This is a short summary about how a C++ module can be created, compiled and loaded into the host appliaction. All necessary steps are based on DrawCirclesCommand.

  1. Java: Create a nativ method

  2. C++: Create a matching implementation

  3. Store the C++ implementation inside a shared library

  4. Create C++ module

  5. Load C++ module

  6. Compile the shared library and module with CMake

  7. Load the shared library with System.LoadLibrary()

  8. Call native method to load C++ module inside Java host application

1. C++ Modules - Java: Create a nativ method

JNI.java

public static native void LoadJNI();

2. C++ Modules - C++: Create a matching implementation

ARESSimplified_JNI.cpp

JNIEXPORT void JNICALL Java_com_graebert_aressimplified_JNI_LoadJNI( JNIEnv * env, jclass clazz ){...}

3. C++ Modules - Store the C++ implementation inside a shared library

Check file CFx/AndroidSimplified_JNI/app/CMakeLists.txt for more details.
Check file CFx/DrawCirclesCommand/CMakeLists.txt for more details.
Check file CFx/CMakeLists.txt for more details.


4. C++ Modules - Create C++ module

See inside folder CFx/DrawCirclesCommand for more details.

A OdRxModule has two essential methods. The first method InitApp() is called when the module is loaded. InitApp() may be also used for further initialization purposes. The second method UnitApp() is called when the module is unloaded , you may clean up your pointers, references and objects carefully.

A CFxCommand  must be registered before being used. It is recommended to register any command inside InitApp() and to remove any command inside UninitApp(). The command can be registered with odedRegCmds()->addCommand() and removed with odedRegCmds()->removeCnd().

5. C++ Modules - Load C++ module

The module architecture is handled on C++ side and will be called inside the native method. All C++ modules will be loaded with odrxDynamicLinker()->loadApp().

ARESSimplified_JNI.cpp

JNIEXPORT void JNICALL Java_com_graebert_aressimplified_JNI_LoadJNI( JNIEnv * env, jclass clazz )
{
   odrxDynamicLinker()->loadApp( L"DrawCircleCommandModule" );
}

6. C++ Modules - Compile the shared library and module with CMake

See topic “Compile the shared library with CMake” for more information.
Android: Java and C++ synergy

7. C++ Modules - Load the shared library with System.LoadLibrary()

See topic “Load the shared library with System.LoadLibrary()” for more information.
Android: Java and C++ synergy

8. C++ Modules - Call native method to load C++ module inside Java host application

It is necessary to load all C++ modules before any features become active.

JNI.java

public static void Load()
{
...
   LoadJNI();
}


  • No labels