Project Westcott RPE (Upgrade)

There was a #include "Instrument.h" in the Instruments.cpp file, but I moved that to the Wescott_P2.h file, good move?...

Totally lost now, I'll start again and see if I can get the Instruments.cpp and Instuments.h files to compile and link. They did yesterday, so I've obviously chopped a , or a ; off somewhere.

Thanks, N.
 
well, remember that ".h" files are completely ignored unless you include them in the current CPP (that just gets compiled) - every CPP that relies on the interfaces defined in the header file has to include the header - either directly by a #include statement, or indirectly by getting included by an header file that was already included by the CPP (directly or indirectly).

If you have multiple CPP files in your project, that all refer to the same header, every CPP file has to include this header. There is no implicit inclusion of the header files.
 
Thanks Urwumpe, another little? thing I didn't know. Back to the cut&paste..

N.
 
Thanks Urwumpe, another little? thing I didn't know. Back to the cut&paste..

N.

Well, that is pretty deep under the hood of C++.

Every .cpp is compiled independently into a so-called object file, and these object files are after all cpp files had been compiled, joined together by the linker to form the module.

The header files are the only parts that are really shared between the object files and should only contain interface definitions, but no executable code (Except short inline functions, inline functions are short snippets of code that are copied into the place in which you call the inline function, different to normal function calls, which permits optimizing each "function call" for the context, making your program faster). You should define the interfaces of all your functions in the appropriate header file, such forward declarations help you finding errors later, even if you don't always need them.

In brief: In the headers you describe how the functions are called or how the data structures look like, in the cpp files you describe how they behave.
 
Plodding on...
Getting this error:

http://i89.photobucket.com/albums/k207/Notebook_04/WestcottP2_5_.jpg

Dosen't like y0/y1 being re-defined, don't particulary want to, but how do I stop it?

The constants in this group are ones I just made up, trying to get it to compile/link at the moment.

Haven't altered the Instrument.h/cpp files yet.

All help appreciated.

N.
 
Write constants with capital letters for remembering yourself that they are constants... this also renames them for removing the name collision.
 
Oh, right, let me have a go at that!

N.
 
Oh, right, let me have a go at that!

N.

You should maybe also think about the scope of your constants - they look a bit like they are limited to a single instrument, but you don't say by the constant name, which instrument. You could also define such constants closer to where they are needed.
 
Good news is it compiles and link, and dosen't crash in orbiter.
Just shows the panel background and the left MFD(MAP) it gets from the scenario entry I assume?

I haven't put in the second code entry from Part Two
http://www.orbiter-forum.com/blog.php?b=576
Don't understand the Font system yet, also commented out the oapiBlt entries. Just wanted to get the buttons to show.

I don't understand about the scope of the constants, are they global at the moment, and should be in a class in the Westcott_P2.h file?

N.
 
I don't understand about the scope of the constants, are they global at the moment, and should be in a class in the Westcott_P2.h file?

Not syntactical scope, rather: What do they mean and how do you use them? Is the constant named in a way that you can identify it quickly in the code. Do you only use it once in a single CPP? Or multiple times?
 
Ah, now I get it. Not so much where they are, as what they do!

My problem is I don't understand this program yet, so I can't put meaningful comments or names to things. Hopefully that will change.

No sign of the butons yet, but I'm working on it...:hmm:

N.
 
No sign of the butons yet, but I'm working on it...:hmm:

Well, AFAIR, the blt(block transfer) operation isn't unimportant there. as I found out during the SimpleLCC project, the textures you use for the panel2D don't support drawing lines or text on them, only blt operations. So for such painting operation, you draw the text and lines on a memory bitmap, and then blt the data from there onto the texture.
 
Thanks Urwumpe, If I replace my
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
Westcott_P2::panel2dtex = oapiLoadTexture("panel2d.dds");
return new Westcott_P2 (hvessel, flightmodel);
}
"panel2d.dds" texture with a suitable graphic, I should be able to use some of the "off-screen" area for the button graphics?

N.
 
Thanks Urwumpe, If I replace my
"panel2d.dds" texture with a suitable graphic, I should be able to use some of the "off-screen" area for the button graphics?

N.

Sure, no problem. You just need take this in account when setting the texture coordinates in the panel mesh
 
Replaced the white-field panel with a copy of the dg's, then un-commented the oapiBlt function.

Before:
http://i89.photobucket.com/albums/k207/Notebook_04/WestcottP2_6_.jpg
http://i89.photobucket.com/albums/k207/Notebook_04/11051315-49-17Westcott_P2.jpg

and after:
http://i89.photobucket.com/albums/k207/Notebook_04/WestcottP2_7_.jpg
http://i89.photobucket.com/albums/k207/Notebook_04/11051315-57-02Westcott_P2.jpg

Seems to work!(always surprises me), not as tidy as Bibi Uncle's, but I just put random numbers in. At least its blitting onto the bit map.
Try and sort the numbers now.

N.
 
Just a quick question, this is the MFDButtonCol declaration? in the .h file.

class MFDButtonCol: public PanelElement {
public:
MFDButtonCol (VESSEL3 *v, DWORD _lr);
bool Redraw2D (SURFHANDLE surf);
bool ProcessMouse2D (int event, int mx, int my);

private:
DWORD lr; // left (0) or right (1) button column
DWORD xcnt; // central axis of button column in texture
DWORD ytop; // top edge of label in topmost button
DWORD dy; // vertical button spacing
};

This is in the .cpp file, the definition?
MFDButtonCol::MFDButtonCol (VESSEL3 *v, DWORD _lr)
: PanelElement (v)
{
lr = _lr;
xcnt = 40 + lr*380; // adjust according to geometry
ytop = 300; // same here
dy = 38; // same here
}
Why has _lr the underline before it, and why is it copied to lr?

Many thanks, n.
 
Why has _lr the underline before it, and why is it copied to lr?

'_lr' is a local parameter of the function / constructor, which will be no longer valid after that function returns execution one level up, and that's why it's copied to 'lr', which is more permanent part of the class (as it's existing in the class between memory allocation by 'new' and deallocation by 'delete' for the class).

I'm guessing MFDButtonCol is "MFD button column", so 'lr' is used for making different buttons drawn in left and right column, and that's why it needs to be stored in the class.
 
Thanks Orb, that all makes sense.
Yes, _Lr is
DWORD lr; // left (0) or right (1) button column

So, when that class is declared, it makes room for "extra" variables in the ':Private' section?
And
MFDButtonCol (VESSEL3 *v, DWORD _lr);
are the minimum paramaters I need to make it work?

Edit: Not being rude, : next to P comes out as...don't know how to get round it.

N.
 
Last edited:
So, when that class is declared, it makes room for "extra" variables in the ':Private' section?
Not when the class is declared, but when its instance is created (I'm looking for more proper word for it). Room is made for every non-static variables then, so not only for private but public & protected too. Only static variables have their memory already allocated when the class is declared.

And are the minimum paramaters I need to make it work?
Depends on what is in other functions, like in Redraw2D, but since the beginning 'y' and 'x' are defined in the constructor, this is sufficient.

Edit: Not being rude, : next to P comes out as...don't know how to get round it.
You can use [noparse][/noparse] around the part of the text that shouldn't have smilies or links parsed. I thought there was an option to disable smilies for the whole post when posting, but I can't find it right now (EDIT: It's only in "Quick Reply").
 
thanks again Orb, sinking in slowly.

N.
 
Back
Top