Quick Start

For this section we'll be creating a simple model of 3 animal classes. We'll create a base Animal class, and then create Dog and Cat subclasses. We won't go into depth on what you can do, but rather just provide a simple example.

Open up your copy of the KlassModeler and you will see just a plain white screen. This is the canvas which you will fill with your model. You will notice a zoom drop down in the lower left, as well as the usual menu bar across the top. Most of the command you'll want to use are actually in the context menu, which you can access with your right mouse button.


Go ahead and right click on the model and select "Create Class." This will create a new class.


Double click on the title bar of that new class and you will see the class view dialog.


Now we're gonna want to fill out some fields to turn this into our parent class. In the "Class Name:" field go ahead and fill in Animal. Also fill in some documentation. From here we're going to want to create a constructor and destructor. In the class tree on the left, right click on "public:" and select "Create Method." Do this twice and you will see two new methods in the tree. Select the first one and the notebook on the right will change to show you info about that method.


This is going to be our constructor, so under the "Method Name:" field fill in Animal. Since constructors don't have a return type, empty out the "Method Type:" field. Finally fill in some documentation for your new constructor. Next select the second "void NewMethod()" that you created and turn this into the destructor.


Let's create a variable that counts the number of legs our animal will have. Right click on "private:" and select "Create Variable." Select this new variable and fill in the fields to customize it. And of course we'll want a pair of accessors for this variable. Create a new public and protected method. Your model should look like this:


I'm a bit picky about the order of my methods, and I don't like that our new method is now on top of our constructor and destructor. So go ahead and left click on that new method and drag it to our destructor. You can drag and drop any methods or variables to change their order within the class, or move them between classes. If you hold down the ctrl key while you drag you can copy them between classes. For now select your newly moved public method and turn it into a GetLegCount accessor. Notice that I ticked the "const" box to make this a const function.


Since this kind of accessor is easy to place in the header, go ahead and select the "Code" tab and fill in the body of the method. When the KlassModeler generates this header file it will fill in exactly what you write in the Code section immediately following the function.


Now we want to make a SetLegCount function. Highlight the new protected method and fill in the fields. For this function we'll need to take one argument. To add an argument you right click on the method and select "Add Arg." You should see a new argument appear in the tree. Go ahead and select this and fill in the information in the notebook:


Okay, our class is all done. One last thing we'll want to do is fill in the name of the header and HTML files for this class. Select the class name at the top of the tree. The notebook will now show the class information. Click on the "Misc" tab and you will see an entry box for the files. Go ahead and fill these in.


We're all done with this class. Press the Ok button and you'll be back to the model view.


The next thing we want to do is create a subclass named Dog, and have it inherit from our Animal class. So right click and select "Create Class."


To create the inheritence you right click on the title bar of the child class, in this case the Dog, and select "Inherit From." Next click on the parent class, Animal, and a line will appear.


You can now feel free to open up the class dialog for the child class and create all of the members and variables like we did with the Animal class. For this tutorial I ended up creating this simple model:


You can find this model in the Docs directory under the name quickstart.kml. The rest of this document will take a deeper look into the parts of the model that we either glanced over or skipped entirely.