/*! \page CreatingYourPrototype_C \htmlonly

Creating a Prototype

The HOOPS/3dAF installation includes 'simple' applications for a wide variety of GUI technologies. These apps provide a framework for the tutorials discussed later in this guide, and can also serve as containers for HOOPS 3DF prototyping code. This section reviews how to start with a simple HOOPS 3DF application and insert a 'HelloWorld' text string in the scene-graph. Select the GUI technology that you wish to prototype with:


\endhtmlonly

MFC - Microsoft Foundation Classes

1.0 Using the MFC AppWizard

1.1 Installing the AppWizard on your System

A HOOPS 3DF AppWizard is provided with the installation and is the preferred approach to create a simple HOOPS 3DF application using MFC. It provides options to link in a variety of the HOOPS 3DF components, and allows you to create a custom-named application. The App Wizard is supported under Visual Studio 2008 or later.

Visual Studio 2008 (VC 9.0)

The HOOPS AppWizard files are in the demo/mfc/hoops_appwizard directory of the HOOPS 3DF installation. To install the AppWizard on your system you need to copy different files from this directory into your Microsoft Visual Studio 9 directory structure which is typically located in the 'Program Files' directory of your System. After you locate your Microsoft Visual Studio 9 install follow these simple steps to install the Appwizard.

Once you have completed this the HOOPS AppWizard should be available as an option when you create a New Visual C++ Project in Visual Studio 2009. To verify this you should verify that 'HOOPS Application' is an option if you try to create a new Visual C++ application from Visual C++.

newdialog

1.2 Setting Environment Variables

Before you can build your generated application you will need to make sure that you set some environment variables to allow the application makefiles to find the installation of the dependent components. The environment variables for each component is:

HOOPS

HOOPS_INSTALL_DIR

Location of HOOPS Installation

Example

C:/HOOPS-1400

Parasolid

PARASOLID_INSTALL_DIR

Location of libs within your Parasolid Installation

Example

C:/Parasolid/Kernel/v14.0/base

P_SCHEMA

Location of Schema Files

Example

C:/Parasolid/Kernel/v14.0/base/schema

ACIS *

A3DT

Location of ACIS Installation

Example

C:/Spatial/ACISR11

ARCH

Refer to the Spatial Documentation

Example (4 separate options)

NT_DLL, NT_DLLD, NT_NET_DLL or NT_NET_DLLD

* The ACIS Installer should set all environment variables required for ACIS and so you should not have to manually set any of these variables. All ACIS applications require a valid Spatial license key. This should be set via the unlock_str in the CApp::InitInstance() function.

Remember that after your application is built, you will then also need to ensure that the dependent DLLs are in your PATH.

1.3 Creating your Application with the AppWizard

Now you should be ready to use the Application Wizard to create your prototype application. To access the Wizard, simply select the HOOPS Application icon in the Visual C++ section of the 'New Project' dialog. As is standard with Visual Studio AppWizards, the name you choose for the application will be used for class and file names in the application the source of which will be placed in the specified folder.

AppWizards are very simple to use. You click through the three separate sections of the Wizard selecting which components you want to use and when you have things configured as required simply click on the Finish button and the source to the application will be generated and put into the specified folder. If you have the Environment Variables set the application should compile, link and run immediately. Below we review what the different options mean:

Choosing Application Type

Once this is done you can now define the type of application you want to create. The Appwizard allows you to create either an MFC based application, or a Win32-based 'standalone' application.

MFC Application

The AppWizard allows you to generate a Single Document or a Multiple Document Application. The underlying archtiecture in both cases is very similar and both rely on the MFC classes to create windows and handle the event loop.

Win32 Application

Selecting this option results in the creation of a 'standalone' Win32 Application that only links in the HOOPS/3dGS component, and does provide a GUI. This type of application is strictly intended for situations when you wish to rapid prototype HOPS/3dGS scene-graph creation. In particular if you create geometry under the ?picture segment you will see the object on the screen.

The precreated application is very basic; it simply reads in a file and allows you to manipulate the camera with the arrow keys. It can be built on any of the UNIX platforms by using the included makefile.

1.4 Choosing HOOPS Components

Once you've chosen your type of MFC Application, you need to decide whether you want your app to be hooked up to the HOOPS 3D Application Framework (3dAF) or just to the Graphics System (3dGS). Using 3dAF means that your application will be connected to the HOOPS/MVO classes, the HOOPS/Stream libraries, and finally an optional connection to the HOOPS/Net Server. Choosing just 3dGS means that you have a much lighter weight application which supports non-WYSIWYG Printing, Copy to Clipboard and Camera Orbit. It is strongly recommended that you choose the 3dAF option so that you can access powerful features of the 3dAF, and thus more easily create a rich prototype.

3dAF Application

When you create a 3dAF application in addition to creating a set of classes derived from the base MFC classes it also creates a set of classes derived from the base MVO classes. You should refer to the HOOPS/MVO Programming Guide for directions on how to use this component. However, if you want to quickly add some geometry or create some segments in your test application, you should do so in the segment referred to by HBaseModel::m_ModelKey.

Because the default application is hooked up to the 3dAF, you can read a variety of file formats into the viewer, including HSF, OBJ, and STL. The default 3dAF application also provides functionality to create spheres which demonstrates a very basic form of entity creation.

A 3dAF Application has a dependency on the HOOPS/MFC, HOOPS/Stream, HOOPS/MVO and HOOPS/3dGS components of the 3dAF.

3dGS-only Application

When you create a 3dGS-only application, the two primary classes you will be dealing with are the CDocument and CView derived classes. If you want to quickly add some geometry or create some segments in your test application, you should do so in the segment created in either the OnOpenDocument or OnNewDocument methods of the CDocument derived classes.

A 3dGS application only has a dependency on the 3dGS library.

Geometric Kernel

The AppWizard allows you to choose whether or not you want the application to be hooked up to any of the leading Geometric Kernels on the market today. This includes the ACIS Modelling Kernel from Spatial and the Parasolid Modelling Kernel from EDS. If you want to have support for a Geometric Kernel then you are expected to have an installation of that modelling kernel on your machine. The HOOPS media does not include any of Geometric Kernel libraries for build purposes.

2.0 HelloWorld

Begin by using the AppWizard to create a sample app called HelloWorld. We'll then add some code to display the 'Hello World' text each time a new document is opened. This is achieved by adding code to the CHelloWorldDoc::OnNewDocument method which does the following:

  1. Opens the HOOPS/3dGS segment associated with the model object. The numerical identifier of the segment (called a 'key') is accessed by calling the model object's HHelloWorldModel::GetModelKey method, and the segment is opened using the HOOPS/3dGS ::HC_Open_Segment_By_Key subroutine.
  2. Inserts a piece of text into the segment by calling ::HC_Insert_Text.
  3. Closes the segment by calling ::HC_Close_Segment.

The modified OnNewDocument method would look like the following:

\code
BOOL CHelloWorldDoc::OnNewDocument()
{
   if (!CHoopsDoc::OnNewDocument())
      return FALSE;

   // create a new HHelloWorldModel object for this Document
   m_pHoopsModel = new HHelloWorldModel();
   m_pHoopsModel->Init();

   HC_Open_Segment_By_Key(m_pHoopsModel->GetModelKey());
     HC_Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
   HC_Close_Segment();

   if (!m_pHoopsModel)
      return FALSE;

   return TRUE;
}
\endcode

Note that the sample code could have also been inserted in the HHelloWorldModel::Init method.

 


ATL

This tutorial describes how to take the reference ATL control (called the HOOPS 3D Stream Control), and display the text 'Hello World' in the viewport. It assume some familiarity with ATL. Developers are encouraged to read through the HOOPS/ActiveX documentation to get an idea of what the sample ATL control is all about.

The source source code and project files for the HOOPS 3D Stream Control is located in /demo/atl/Hoops3dStreamCtrl/source, Recompile and expermient with the control by going to the Streaming Gallery at www.hoops3d.com

Let's modify the application to display the 'Hello World' text each time a new window is opened. This can be achieved by adding code to the CHoops3dStreamCtrl::InitModel method which does the following:

  1. Opens the HOOPS/3dGS segment associated with the model object. The numerical identifier of the segment (called a 'key') is accessed by calling the model object's HBaseModel::GetModelKey method, and the segment is opened using the HOOPS/3dGS ::HC_Open_Segment_By_Key subroutine.
  2. Inserts a piece of text into the segment by calling ::HC_Insert_Text.
  3. Closes the segment by calling ::HC_Close_Segment.

The modified sample code for:

\code
void class CHoops3dStreamCtrl::InitModel()
{
    ...
    
    if (!m_pModel)
    {
        m_pModel = new HBaseModel ();
        m_pModel->Init();
	
        HC_Open_Segment_By_Key(m_pModel->GetModelKey());
          HC_Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
        HC_Close_Segment();
    }

}
\endcode

Generally, the reference control's source code should not be modified to dynamically create graphical primitives. Rather, it should be referenced on a webpage to automatically stream in pre-created HSF files, and/or could could be dynamically interacted with from a webpage via it's public COM interface. Again, the HOOPS/ActiveX documentation provides details.


Windows Forms

This tutorial describes how to take the precreated 'simple' HOOPS/Winforms application and display the text 'Hello World' in the viewport. You may wish to first review the HOOPS/Winforms documentation to get an idea of the structure of the provided application.

There are 2 HOOPS/Winforms examples, one for VB.Net and one for C#.Net. Their source code and project files are located in /demo/csharp/csharp_simple, and /demo/visual_basic/vb_simple. Compile and run the one that you're interested in to make sure your development environment is setup correctly.

Let's modify the application to display the 'Hello World' text each time a new window is opened. This can be achieved by adding code to the custom HSimpleModel constructor which does the following:

  1. Opens the HOOPS/3dGS segment associated with the model object. The numerical identifier of the segment (called a 'key') is accessed by calling the model object's HBaseModel::GetModelKey method, and the segment is opened using the HOOPS/3dGS ::HCS.Open_Segment_By_Key subroutine.
  2. Inserts a piece of text into the segment by calling ::HCS.Insert_Text.
  3. Closes the segment by calling ::HCS.Close_Segment.

The modified sample code for:

csharp_simple:

The sample code would be added to the HSimpleModel::Init method in SimpleHNPanel.cs

\code
public class HSimpleModel : HBaseModel
{
  ...
	
  override public void Init()
  {
    base.Init();
	
    HCS.Open_Segment_By_Key(GetModelKey());
	  HCS.Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
    HCS.Close_Segment();
  }
  
  ...
}
\endcode

 

vb_simple:

The sample code would be added to the HSimpleModel::Init method in SimpleHNPanel.vb

\code
Public Class HSimpleModel

    Inherits HBaseModel

    ...

    Public Overrides Sub Init()
	
        MyBase.Init()
		
        HCS.Open_Segment_By_Key(GetModelKey());
          HCS.Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
        HCS.Close_Segment();
		
    End Sub 'Init
	
    ...
	
End Class 'HSimpleModel
\endcode

QT

This tutorial describes how to take the precreated 'simple' HOOPS/QT application and display the text 'Hello World' in the viewport. You may wish to first review the HOOPS/QT documentation to get an idea of the structure of the provided application.

The source code to the simple HOOPS/Qt application is located in /demo/qt/qt_simple. (The QT4 variant is located in /demo/qt/qt_simple_4.) Compile and run it to make sure your development environment is setup correctly.

Let's modify the application to display the 'Hello World' text each time a new window is opened. This can be achieved by adding code to the custom HOOPS/QT widget's constructor which does the following:

  1. Opens the HOOPS/3dGS segment associated with the model object. The numerical identifier of the segment (called a 'key') is accessed by calling the model object's HBaseModel::GetModelKey method, and the segment is opened using the HOOPS/3dGS ::HC_Open_Segment_By_Key subroutine.
  2. Inserts a piece of text into the segment by calling ::HC_Insert_Text.
  3. Closes the segment by calling ::HC_Close_Segment.

The modified SimpleHQWidget constructor would look like the following:

\code
SimpleHQWidget::SimpleHQWidget(QWidget* parent, const char* name, const char * filename)
    : HQWidget( parent, name )
{
   CreateMenus();

   // Create and initialize HOOPS/MVO Model and View objects 
   m_pHBaseModel = new HBaseModel();
   m_pHBaseModel->Init();

   HC_Open_Segment_By_Key(m_pHBaseModel->GetModelKey());
     HC_Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
   HC_Close_Segment();

   // Initialize View object to null ; gets created in SimpleHQWidget::Init 
   m_pHView = 0;

   // if called with a file name we load it  
   // otherwise open an empty view 
   if(filename)
   m_pHBaseModel->Read(filename);

   // enable MouseMoveEvents  
   setMouseTracking(true);

   // enable key events 
   setEnabled(true);
   setFocusPolicy(QWidget::StrongFocus);
}
\endcode

Note that the sample code could have also been inserted in an overloaded method of HBaseModel::Init.


Java

This tutorial describes how to take the precreated 'simple' HOOPS/Java application and display the text 'Hello World' in the viewport. You may wish to first review the HOOPS/Java documentation to get an idea of the structure of the provided application.

The source code to the simple HOOPS/Java application is located in /demo/java/java_simple. Follow the steps in the readme.txt file to recompile and run it.

Let's modify the application to display the 'Hello World' text each time a new window is opened. This can be achieved by adding code to the Init method of the custom HBaseModel class (HSimpleModel::Init) which does the following:

  1. Opens the HOOPS/3dGS segment associated with the model object. The numerical identifier of the segment (called a 'key') is accessed by calling the model object's HBaseModel::GetModelKey method, and the segment is opened using the HOOPS/3dGS ::HJ.Open_Segment_By_Key subroutine.
  2. Inserts a piece of text into the segment by calling ::HJ.Insert_Text.
  3. Closes the segment by calling ::HJ.Close_Segment.

The modified HSimpleModel::Init method would look like the following:

\code
class HSimpleModel  extends HBaseModel
{
  ...

  public void Init()
  {
    super.Init();
		
    HJ.Open_Segment_By_Key(GetModelKey());
      HJ.Insert_Text(0.0f, 0.0f, 0.0f, "Hello World");
    HJ.Close_Segment();
  }
		
  ...
}
\endcode

Note that the sample code could have also been inserted in an overloaded method of HBaseModel::Init

*/