Events and methods of applied task

Print Previous page Top page Next page

For creation of object the Application in the main library of application the function of the following type should be:extern "C"

{

 HMAPTASK WINAPI __declspec (dllexport)

  CreatePanTask (HMAPDOC hdoc,TASKPARM * parm,const char * dllname)

  {

    // To create object the Application

    TPanTask * task = new TUserTask(hdoc,parm,dllname);

   if (task == 0) return 0;

    if (task->GetTaskIdent () == 0)

      {

        delete task;

        task = 0;

   return 0;

      }

   return task->GetTaskIdent();

  }

}  // extern "C"

When programming in Delphi the function should take appropriate action to create an instance of an object.

Types of variables and structures HMAPTASK, HMAPDOC, TASKPARM are declared in the MAPTYPE.H file.

The description of TPanTask class is contained in the PANTASK.H file, the implementation - in the PANTASK.CPP file. Files are located in the folder \SDK12\PANTASK of examples of applications programming in the GIS "Panorama" 12.

The class of the user task should be derived from the TPanTask class.

Constructor of a class automatically creates object the Window of digital map and establishes connection with library MAPTASK.DLL (MAPTASK64.DLL) which is responsible for supporting PANAPI interface.

At successful creation of the object instance its property GetTaskIdent returns nonzero value of the task's identifier assigned by interface PANAPI. This property cannot be redefined.

Panorama system operates in multiple document (multiwindow) mode. At running the user task, so many instances of objects are automatically created, how many documents (digital maps) are opened. Creation is carried out by a call of the CreatePanTask function, removal is carried out by calling the destructor of the task.

The call of destructor, as well as other functions of classes, is executed from corresponding functions (utsDeletePanTask, utsSetFocus, utsGetAction...), implemented in the main application library.

Texts of all necessary functions of access to methods of classes from system of Panorama are contained in the PANTASK.CPP file, and should not be modified by the application developer.

At a choice by the user of a document window and at opening of a new document automatically the method (event is generated) SetFocus is invoked.

At changing the composition of the data in the document (the user map is added, the matrix is constructed, etc.) there is automatically invoked the method (event is generated) ChangeData.

At changing the language of dialogues and messages the method (event is generated) ChangeLanguage is automatically invoked.

An application task can support several modes of operation, which a user can change by pressing the corresponding button on the taskbar. By pressing the button the message is generated to the active document with the button identifier. In this case, the task automatically invokes the method GetAction (event is generated). For definition of availability of the task's mode the method (event is generated) EnableAction is automatically invoked.

When running multiple instances of objects the Application with different documents windows simultaneously Panorama can be active the different modes of operation.

At change by the user of an active window of the document, the Panorama system automatically changes the status of tasks panels (presses and releases the necessary buttons). If the task is working with its dialogues (database tables, diagrams, etc.), their activation can be performed upon obtaining the SetFocus event.

To access the functions of processing a digital map of the MAPAPI interface, the TPanTask interface contains the pointer to the class of the open data of the map document HMap (type HMAP)..

To send messages to the main application window the MainMessage method is used, which is based on the SendMessage of WINAPI-function.

The most important methods of TPanTask class are SetFocus, GetAction, EnableAction.

Processing commands coming into GetAction method can be performed in two ways: by calling the appropriate methods that have been added in a derived from TPanTask class, or creation of  an instance of the object the Command handler that works interactively.

The general view of implementation of GetAction method can be the following:

HMAPACTION TUserTask::GetAction(int comid, int run)

{

  // To request the base list of commands

  HMAPACTION action;

  if ((action = TPanTask::GetAction(comid,run)) != 0)

    return action;

  // Execution of commands that do not require the handler

  // CM_MED_STEPSIZE    - the command ID;

  // void CmStepSize(void)  - method executing the given command;

  // IDN_HLP_STEPSIZE    - the Help topic identifier, the reaction to F1.

  SeekCommand(comid,run)

   {

     CheckCommand (CM_MED_STEPSIZE,CmStepSize,IDN_HLP_STEPSIZE);

     // ...

   }

  // Execution of commands by means of the handler

  // TMoveObject - a class derived from TPanAction.

  SeekAction(comid,run)

   {

     CheckAction(CM_MED_MOVEOBJECT,TMoveObject,IDN_HLP_MOVEOBJECT);

     CheckAction(CM_MED_CREATEOBJECT,TCreateObject,IDN_HLP_CREATEOBJECT);

     // ...

   }

  ReturnAction();

}

Realization of EnableAction method is based on a call of GetAction method with the "run" parameter, equal to zero. Thus, the sign of support of the requested command in the task is returned. Further additional conditions of execution of a command are checked (presence of data in the database table, presence of the selected object, presence of the user map or a matrix, etc.). If the command is not accessible - the method should return a zero.

The example of implementation of the application task is contained in the folder \SDK12\Ready\Image3D\ of the examples of applications programming in GIS "Panorama" 12.