I tried installing suit13 one but in that also I found only volume 1&2.
There are only two volumes for the Developer's Guide so this is correct. Unless you absolutely have to use an old version of the API, please use the newest you can. Unless you are "stuck" on Creator 4.1 and can't get a newer version of it, in which case you have to use API 4.1 to match. In other words, you should not use suite 13 API to make plugins for Creator 4.1. That is not supported.
Also Iââ¬â¢m finding little difficulty in configuring my compilers with api. Like preprocessors settings and all even after reading the guides.
Take a look at the samples that come with the API. For Suite 13 they will be located at:
PRESAGIS_OPENFLIGHT_API:/samples
which, if installed to the default location should be:
c:\presagis\suite13\OpenFlight_API\samples
There are sample RW apps and plugins here so choose a sample and copy the settings from that sample. Or simply use the sample and change it to be YOUR plugin.
I tried to get a sample by using plugin wizard, im getting this error in output window of Visual Studio. im not able to figure out.
1>------ Build started: Project: ChecklistSearch, Configuration: Debug Win32 ------
1>checklistsearch.rc(10): fatal error RC1015: cannot open include file 'afxres.h'.
1>
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
what version of the OpenFlight API?
what version of Creator?
what version of Visual Studio?
OpenFlight_API_4_1
Creator_4_1
Visual Studio Express 2013
Thanks, Visual Studio Express 2013 is a very "limited' version of Visual Studio. It does not support windows resource compilation (RC) - this is required to layout dialogs in Creator plugins . Also the binary file format created by Visual Studio express 2013 may not be compatible with Creator 4.1 which was released several years ago.
To build plugins for Creator 4.1, you have to have Visual Studio 2008.
Thank You ill try with VS 2008 and update you.
Ok, great.
Also note that even in you updated to Creator and API 13, Visual Studio Express 2013 would not be sufficient if you want to make plugins in Creator that have "dialogs". MicroSoft limits this "free version" of Visual Studio to try to force you to pay for a "real" copy of their IDE.
Finally i got my plugin first stage to be working with the help of plugin wizard thanks Steve sir and others.
Now i have a window(Dialog) in creator. I'll provide the screenshots as attachment. But im not able to add an icon to that.
Also i want you all to help with a sample code for a button in that window(Dialog). I have kept a button with name as "127". purpose of the button is like when user hits the button all the polygons with 127 as Primary color index should be selected. can someone help me out in that so that i can also learn how to assign functions to a button as im new to C language. Plugin name is kept as "Remote v2". Providing the codes below please tell me how to add button functions. :
remotev2.c
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>#include <mgapiall.h>
#include "resource.h"
typedef struct undorec_t {int something;
} undorec;
typedef struct toolrec_t {mgrec* db;
mgplugintool pluginTool;
mgresource resource;
undorec* undoRec;
mggui dialog;
mgeditorcontext editorContext;
} toolrec;
static void ToolNotifier (mgnotifier notifier, mgnotifierevent event,mgrec* db, mgrec* rec, void* userData)
{
toolrec* toolRec = (toolrec*) userData;
switch (event)
{
case MNOTIFY_CURRENTPRIMARYCOLORCHANGED:
break;
case MNOTIFY_CURRENTMATERIALCHANGED:
break;
}
}
static void LoadToolPreferences (toolrec* toolRec){
}
static void SaveToolPreferences (toolrec* toolRec){
}
static void UndoCleanupFunc (mgrec* db, mgundocleanupreason cleanupReason, void* userData){
undorec* undoRec = (undorec*) userData;
switch (cleanupReason){
case MUCR_AFTERUNDO: /* UndoFunc was called before cleanup */
break;
case MUCR_NOUNDO: /* UndoFunc was NOT called before cleanup */
break;
}
mgFree (undoRec);
}
static void UndoFunc (mgrec* db, void* userData);
static void RedoFunc (mgrec* db, void* userData)
{
undorec* undoRec = (undorec*) userData;
mgEditorAddUndoForRedo (UndoFunc, UndoCleanupFunc, undoRec);
}
static void UndoFunc (mgrec* db, void* userData){
undorec* undoRec = (undorec*) userData;
mgEditorAddRedo (RedoFunc, UndoCleanupFunc, undoRec);
}
static void ButtonFunc (mgeditorcontext editorContext, int whichButton, void* toolData){
toolrec* toolRec = (toolrec*) toolData;
switch (whichButton){
case MBT_CANCEL:
break;
case MBT_DONE:
break;
}
}
static void TerminateFunc (mgeditorcontext editorContext, mgtoolterminationreason terminateReason, void* toolData){
toolrec* toolRec = (toolrec*) toolData;
switch (terminateReason){
case MTRM_DONE:
mgEditorAddUndo (editorContext, MUML_USETOOLNAME, UndoFunc,
UndoCleanupFunc, toolRec->undoRec);
break;
case MTRM_CANCEL:
break;
case MTRM_SELF:
break;
case MTRM_SYSTEM:
break;
}
SaveToolPreferences (toolRec);}
// Gui Control Callback Functionsstatic void InitializeGuiCallbacks (toolrec* toolRec)
{
mggui gui = MG_NULL;
// Gui Control Callback Declarations}
static mgstatus DialogProc (mggui dialog, mgdialogid dialogId,
mgguicallbackreason callbackReason,
void* userData, void* callData)
{
toolrec* toolRec = (toolrec*) userData;
switch (callbackReason){
case MGCB_INIT:
{
mgeditorcontext editorContext = mgEditorGetContext (dialog);
toolRec->dialog = dialog;
toolRec->editorContext = editorContext;
InitializeGuiCallbacks (toolRec);
// Select the mouse input handling routine to make activemgEditorSelectMouseInput (editorContext, MMSI_NOINPUT);
// Register the notifiers of interestmgRegisterNotifier (toolRec->pluginTool, MNOTIFY_CURRENTPRIMARYCOLORCHANGED,
toolRec->db, MG_NULL, ToolNotifier, toolRec);
mgRegisterNotifier (toolRec->pluginTool, MNOTIFY_CURRENTMATERIALCHANGED,
toolRec->db, MG_NULL, ToolNotifier, toolRec);
}
break;
case MGCB_SHOW:break;
case MGCB_HIDE:
break;
case MGCB_DESTROY:
mgUnregisterAllNotifiers (toolRec->pluginTool);
mgFree (toolRec);
break;
}
return (MSTAT_OK);
}
static mggui CreateDialogFunc (mgplugintool pluginTool, void* toolData){
toolrec* toolRec = (toolrec*) toolData;
mggui dialog;
dialog = mgResourceGetDialog (MG_NULL, toolRec->resource, REMOTEV2DIALOG,
MGCB_INIT|MGCB_SHOW|MGCB_HIDE|MGCB_DESTROY,
DialogProc, toolRec);
return (dialog);
}
static mgstatus StartRemoteV2 (mgplugintool pluginTool, void* userData, void* callData){
mgeditorcallbackrec* cbData = (mgeditorcallbackrec*) callData;
mgresource resource = (mgresource) userData;
mgrec* db = mgGetActivationDb (cbData->toolActivation);
toolrec* toolRec;
toolRec = (toolrec*) mgMalloc (sizeof(toolrec));toolRec->db = db;
toolRec->resource = resource;
toolRec->pluginTool = pluginTool;
toolRec->editorContext = cbData->editorContext;
cbData->dialogRequired = MG_TRUE;cbData->toolData = toolRec;
return (MSTAT_OK);}
mgbool InitRemoteV2 (mgplugin plugin, mgresource resource, int* argc, char* argv []){
mgplugintool pluginTool;
mgpixmap pixmap = mgResourceGetPixmap (resource, "REMOTEV2.BMP");
pluginTool = mgRegisterEditor (plugin, "Remote V2",
StartRemoteV2, resource,
MTA_VERSION, "2.0",
MTA_PALETTELOCATION, MPAL_FACETOOLS,
MTA_PALETTEICON, pixmap,
MTA_TOOLTIP, "Remote V2",
MG_NULL
);
if (pluginTool){
mgEditorSetButtonFunc (pluginTool, ButtonFunc);
mgEditorSetTerminateFunc (pluginTool, TerminateFunc);
mgEditorSetCreateDialogFunc (pluginTool, CreateDialogFunc);
}
return (pluginTool ? MG_TRUE : MG_FALSE);
}
void ExitRemoteV2 (mgplugin plugin){
}
main.c
#include <mgapiall.h>
// Plug-in declarationmgDeclarePlugin(
/* vendor name */ MVENDOR_MULTIGEN,
/* plug-in name */ "Remote V2",
/* uuid string */ "e3b6e444-141f-49f0-a2e9-5a16e75277bb"
);
static mgresource Resource = MG_NULL;
// External declarations for Remote V2extern mgbool InitRemoteV2 (
mgplugin plugin, mgresource resource,
int* argc, char* argv []);
extern void ExitRemoteV2 (
mgplugin plugin);
// Plug-in initialization functionMGPIDECLARE(mgbool) mgpInit (mgplugin plugin, int* argc, char* argv [])
{
mgbool initOk;
mgmodulehandle moduleHandle;
moduleHandle = mgGetModuleHandle (plugin);Resource = mgLoadResource (moduleHandle);
// Initialize the tools declared by this plug-ininitOk = InitRemoteV2 (plugin, Resource, argc, argv);
return (initOk);}
// Plug-in termination functionMGPIDECLARE(void) mgpExit (mgplugin plugin)
{
// Terminate the tools declared by this plug-in
ExitRemoteV2 (plugin);
mgUnregisterAllTools (plugin);mgUnloadResource (Resource);
}
both are created with plugin wizard.
...But im not able to add an icon to that.
The code you wrote to create the mgpixmap is not correct:
mgpixmap pixmap = mgResourceGetPixmap (resource, "REMOTEV2.BMP");
You need to add a "Bitmap" resource to your .rc file. When you do this you bind a bitmap file (.bmp) to a resource id. Instead of passing the .bmp name to mgResourceGetPixmap you pass the resource id of the bitmap resource.
If programming with Windows Resource Files is new to you, you might need to study the MicroSoft help topics on line. Windows Resource Files are not specific to the OpenFlight API, they are a standard way for Windows applications to describe Graphical User Interfaces. Creator and plugins in Creator use this standard technology to make plugins GUIs.
You can also check the many sample plugins that came with the OpenFlight API SDK. The one called guitest might be of particular interest to you as it shows how to do many things in your dialog and will show you how to assign bitmap files to bitmap resources and then to your GUI elements.
Also i want you all to help with a sample code for a button in that window(Dialog). I have kept a button with name as ââ¬Å127ââ¬Â.
Use the function mgSetGuiCallback to assign a callback to a button (or any GUI item in your dialog).
Use the function mgFindGuiById to first "find" the GUI item in your dialog, then use mgSetGuiCallback to assign a callback function to it. You will do this in the function InitializeGuiCallbacks set up by the wizard.
Again, check the many samples to see how this is done.
Also when you run the Plugin Wizard, you could have told the Wizard about the buttons and other GUI items you wanted in your dialog and it would have made all the skeleton code for those items (including assigning a callback to your button). Sounds like you made a very simple plugin with the wizard and told the wizard you did not have anything in your dialog.
No worries, all you need is in the sample plugins. Also, all this information is contained in Volume 2 of the Developer/User Guide.
P.S. You probably don't want to refer to your control ids using numbers like 127. When you put them in your Windows Resource File, there will be a symbol defined for each control (typically IDC_XYZ - look at resource.h to see the exact #define symbols). You will want to refer to controls using the "symbol" defined for the number, not the number itself.
See the sample plugins to see what I'm talking about.
... as im new to C language.
Since this is the case, I understand why you might be struggling a bit here. I apologize (in advance) if you find Developer Guide a bit difficult to follow. It is written for developers who are familiar with C and have had experience creating GUI using Windows Resource Files.
Don't get discouraged, making plugins for Creator is really quite simple once you get some of the basics.
Continue to ask questions here and we'll help you all we can with your plugin.
And make sure you have all the resources available. Those include:
The 2 volumes of Developer Guide
The OpenFlight API Reference (HTML list of all the functions in the API and what they do)
The OpenFlight Data Dictionary (HTML list of all the OpenFlight Record and Data codes you will need to interface with elements in the OpenFlight Scene Graph)
All the samples (specifically sample plugins but really all the samples)
Good luck!
Thank you so much sir. I'm super excited. i'll post updates without fail...i started attaining a bit of training on c by myself.
If you dont mind Steve sir can you show me a sample code for a button. suppose my button id is BTN127. and the way it selects polygon with 127 as mgGetPolyColorName. That example can work as a fuel for my understandings.
Thank you.
If you dont mind Steve sir can you show me a sample code for a button. suppose my button id is BTN127. and the way it selects polygon with 127 as mgGetPolyColorName.
I suspect you might mean to find polygons with 127 as the color index, not the color name. Can you confirm? Either way, the sample will be very similar. I'll write one up and post it shortly.
You know I never asked, but why aren't you just using Attribute Search in Creator? Do you need a special plugin to do this? I understand if you just want to learn but do you really have a need for a special plugin to do what Attribute Search does already?
Craig
Hi,
I want to create a plugin in creator with customised attribute searches. can someone direct me how can i do it. like major steps. just like other tool boxes it should have a tool box.