Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The DWG Viewer explains how to embed the framework into a stand alone application and covers basic viewing and editing capabilities.

...

Image Added

Features

  • Viewer object

  • Load drawing

  • Close drawing

  • Change viewing modes

  • Change layout background color

  • Switch between model and sheets

...

DWG Viewer - Viewer object

...

Status
titleJAVA

The most important step is to embed the viewer object and connect it with the host application. The viewer object com.graebert.aresinstance.CFxARESDocumentView can be used and configured in a layout file. The next step is to bind the layout object with a property of type CFxARESDocumentView using findViewById().  This object is a member of the host application. The host application is connected to a class ARESDelegate.java extended by CFxARESInstanceDelegate and is initialized with the singleton CFxARESInstance.instance(). The core starts to render the drawing into the CFxARESDocumentView object that will be accessed by getDocumentView()  when a document is loaded and activated successfully.

Note: The host application may be directly used as CFxARESInstanceDelegate .

File: content_main.xml

Code Block
<com.graebert.aresinstance.CFxARESDocumentView

...



     android:id="@+id/id_aresview"

...



     android:layout_width="0dp"

...



     android:layout_height="0dp"

...



     android:visibility="gone"

...



     app:layout_constraintBottom_toTopOf="@id/id_bottompanel"

...



     app:layout_constraintEnd_toEndOf="parent"

...



     app:layout_constraintStart_toStartOf="parent"

...



     app:layout_constraintTop_toBottomOf="@id/id_background" />

File: MainActivity.java

Code Block
@Override

...



protected void onCreate(Bundle savedInstanceState)

...



{

...



...

...



m_ARES = new ARESDelegate( this );

...



m_CommonUI = new CommonUIDelegate();

...



...

...



CFxARESInstance.instance().delegate = m_ARES;

...



CFxARESInstance.instance().start( this );

...



CFxCommonUI.instance().startWithDelegate( m_CommonUI );

...



...

...



m_ARESView = findViewById( R.id.id_aresview )

...



...

...



}

File: ARESDelegate.java

Code Block
@Override

...



public CFxARESDocumentView getDocumentView()

...



{

...



   return m_Host.m_ARESView;

...



}

3.1.2. DWG Viewer - Load drawingJava

Status
titleJAVA

The DWG Viewer reads all drawings from the assets/resources of the APK. 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() and the CFxARESDocumentView can become visible.  Once the drawing is loaded the CFxARESDelegate triggers documentCreated() followed by documentActivated(). 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 events.

...