Start a new topic

Creator Plugin

Original Post by: Sat Oct 25 06:57:56 2014


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.


Original Post by: SteveThompson Mon Nov 24 16:54:32 2014


let's go line by line...


edata8 = fltLayerTexture1;

if (edata8 >=0)


This "if" will always evaluate to "true" because edata8 is the "code" for fltLayerTexture1 not the "value" for this attribute. This explains why all polygons are being affected. Perhaps what you meant here is to check if the "value" of this attribute was not -1. To do that, consider this code:


short indexOnLayer1;

mgGetAttList(rec, fltLayerTexture1, & indexOnLayer1, MG_NULL);

if (indexOnLayer1 >= 0)

{

...

}


mgSetAttList(rec,fltLayerData1,8);

First, in this statement you forgot the trailing MG_NULL. You MUST ALWAYS terminate the parameter list (in C) for mgSetAttList and mgGetAttList with MG_NULL. i.e.

mgSetAttList(rec,fltLayerData1,8, MG_NULL);

These functions are variable argument style so the MG_NULL is very important.



mgSetModelingMode(db, fltPolygon);


I am not sure why this here but if you really meant for your tool to set the modeling mode to polygon, so be it.

Original Post by: Sat Nov 22 17:56:57 2014


Hi Steve,

I wanted a button to apply Effect Data 8 to layer 1 of polygons which has a texture on fltLayerTexture1,

the code i wrote is not seems to be correct because when i click the particular button its applying Effect Data 8 to all polygons (even to the polygons whose fltLayerTexture1 is -1)

Following is the code, please have a look.


static mgbool eDataApply (mgrec* db, mgrec* parent, mgrec* rec, void* edata)

{

toolrec* toolRec = (toolrec*)edata;

int edata8;

if (mgGetCode(rec) == fltPolygon)

{

edata8 = fltLayerTexture1;

if (edata8 >=0)

{

mgSetAttList(rec,fltLayerData1,8);

mgSetModelingMode(db, fltPolygon);

}

}

return MG_TRUE;

}

Original Post by: SteveThompson Fri Nov 21 17:31:34 2014


i compiled and the plugins are working on my system but its not working on other systems when i tried copying it to others. What i did is i copied the dll file which is build and copied it to the plugins folder. Is there anything else i have to do in this.

Make sure exit and re-start Creator on that other system after you drop the DLL into the plugins folder.

Also make sure you are copying into the correct plugins folder in case you have multiple versions of Creator installed.


When Creator starts, it writes to the Status Log all the plugins it tries to load. Check Info>Status Log in case there is a message trying to tell you why this DLL could not load.

Original Post by: Fri Nov 21 12:15:44 2014


Thanks for the info on Editor and Viewer, i compiled and the plugins are working on my system but its not working on other systems when i tried copying it to others. What i did is i copied the dll file which is build and copied it to the plugins folder. Is there anything else i have to do in this.

Original Post by: SteveThompson Thu Nov 20 17:47:29 2014


But i want the window to be floated on till user manually closes it. now if i open another tool my dialog box is getting hidden or destroyed. i want to be remain opened unless user manually closes it.

That is because you made it an Editor tool. Only one editor tool can be open at one time per database. It is problematic if two tools are "changing" the database at the same time. If you want the tool to be open all the time you need to make it a Viewer tool. Since your tool only selects, making it a Viewer is certainly reasonable. If your tool, in any way, modifies the database, it should be an Editor.

Original Post by: Thu Nov 20 12:08:31 2014


I got my plugin working apart from selecting polygons,

now it will load materials and apply them according to database type, it will clear projections values, and all useful checklists. Thanks a lot Steve :).


But i want the window to be floated on till user manually closes it. now if i open another tool my dialog box is getting hidden or destroyed. i want to be remain opened unless user manually closes it.

Original Post by: SteveThompson Wed Nov 19 17:45:35 2014


sure sir.. i’ll.

Please, you can call me "Steve" ;-)

Original Post by: Wed Nov 19 17:34:29 2014


I can look at this code but I think you misunderstood my suggestion. At some point you will have to dig in and run your plugin using the "debugger" in Visual Studio. When you do this, you can determine exactly why some code works or does not work. We can "look" at code all day but you are the only one that can run it. You need to become comfortable with the VS debugger or will struggle a lot.


I'll look at this code while you dig into the debugger. And by that I mean you need to "step through" the code line by line, examine values of variables, follow if then else blocks etc. Once you master this, you will be able to tell why your code does not work.


sure sir.. i'll.

Original Post by: SteveThompson Wed Nov 19 17:19:55 2014


I don't see anything wrong with this code. The only thing that can solve this is you running the debugger. Good luck.

Original Post by: SteveThompson Wed Nov 19 17:17:03 2014


I can look at this code but I think you misunderstood my suggestion. At some point you will have to dig in and run your plugin using the "debugger" in Visual Studio. When you do this, you can determine exactly why some code works or does not work. We can "look" at code all day but you are the only one that can run it. You need to become comfortable with the VS debugger or will struggle a lot.


I'll look at this code while you dig into the debugger. And by that I mean you need to "step through" the code line by line, examine values of variables, follow if then else blocks etc. Once you master this, you will be able to tell why your code does not work.

Original Post by: Wed Nov 19 17:07:23 2014


Hi sir please find the attached code for the same and let me know what could be the reason.

there is no error or warnings while debug/build.

Also attaching the debug log.

Original Post by: SteveThompson Wed Nov 19 14:56:58 2014


Sir i tried the code you gave, and i leaned lot of things from that, but when i run the plugin nothing is happening to polygons, i mean they are not getting selected even if their primary color indices are 127.

Hmmm... not sure how I can help you with this one. The code I sent you worked in my sample plugin so I don't know why it would not work for you. Perhaps you could run it through the debugger and see what might be the problem. Since you "tweaked" it a bit perhaps something was not quite right. Your best plan would be to use the debugger to follow the code and see what parts are not working the way you expect.


BTW I know you plan to add additional searches on this plugin but Attribute Search can do this one very easily ;-) We're still happy to help with your plugin. Let us know what you find out in the debugger.

Original Post by: SteveThompson Wed Nov 19 14:48:40 2014


I’m still using the attribute search itself sir, there are few newbies joined our firm which they are getting familiar with checklists and terms, so they are finding difficult in searching appropriate attribute names from attribute search. so to make their and my tasks easy i’m trying to float all these searches and few other attributes accessible in one click.

Sorry if I’m disturbing you too much.

It is no bother. It just seems like a lot of work for you to make a plugin rather than figuring out the correct search terms in Attribute Search. We are happy to help in whatever you decide is best for your firm ;-)

Original Post by: Wed Nov 19 14:44:02 2014


Sir i tried the code you gave, and i leaned lot of things from that, but when i run the plugin nothing is happening to polygons, i mean they are not getting selected even if their primary color indices are 127.


As you mentioned i tweaked code to comply with C.

Please see the attached image for what i meant by 127 if i'm wrong this image can give you an idea of what i'm referring to. :)

Original Post by: Wed Nov 19 13:02:55 2014


...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.


I got hold on resources and the way to bind them. Thank you

Login to post a comment