Saving and Loading of Assistants

My first work in Krita was to add the feature of saving and loading of the Assistant tools. Krita has four Assistant tools – Ellipse, Spline, Perspective and Ruler. As their name suggest each Assistant is used to make an Assistant having shape of an ellipse, curve, quadrilateral grid and a line respectively. The purpose of these Assistants is to make a complex 3D mesh which can be painted on. Now, suppose someone has created a very complex structure of these assistants, but, has to shutdown his/her computer, (s)he would loose all the created assistants as there was no implementation of saving the Assistants. Here, is where my work came in.


A structure made using the assistants

As it can be seen in the above image, the structure is a half completed scene illustrating the use of the assistants in showing of depth in a 2D canvas. And this structure is also very time consuming and also something that can be reused. Thus, the saving of one’s work at such a stage is very vital requiring for the need to implement the saving of the same.


Even if all the assistants have a very different structure compared to each other, they all have common attributes. All the assistants have handles(the circles on each assistant in the image above)which give the individual assistants their shape and have only x-coordinates and y-coordinates as their attributes and type, which tells the program which type of assistant is being created.


Saving of assistants their important attributes had to be saved. Each assistant has the Type and Handles as its attribute. So, in order to save the assistants these attributes had to be saved. “How to save the assistants so that it is easy to load them back?” One big question which made me change my implementation of saving around three times. Well, now the assistants are saved in the following manner:

File structure

Following are the modifications which are done in the end of file/folder structure for saving of the assistants.

  1.  There is a list of assistants in the maindoc.xml  file which tells the program the type of the assistants and the filenames  in which the assistants are saved. The list has a n xml style formatting.
  2. Whenever there is at least an assistant to be saved, the program creates a new folder called “assistants” inside the folder having the name same as the name of the created document. Inside this folder are the files with the filenames as given in the list in maindoc.xml. These files individually contain the information of an assistant of the type as described in the list. The name of these files are of the form ‘typecount.assistant’ where count is between 0 and n-1(n = total number of that type of assistant), for e.g. ellipse0.assistant, ellipse1.assistant, perspective0.assistant, etc.
  3. Now, these files store data of an assistant each. These files also have xml format. they store the type and handles, where each handle then stores attributes like handle id(for using in shared pointer), x-coordinate and y-coordinate.


Now, the whole process of saving of the assistants is done in a systematic manner.

First, the list of assistants is stored in the maindoc.xml and then the assistants are saved in their respecitve files.


Because of the way assistants are saved, the loading part was rather simpler to implement.

First, the list of assistants is fetched from the maindoc.xml and stored in a QMap of filename -> type.

Second, The blank assistants are created on basis of the type using the Factory and once created the assistant is given its handles and inserted into a Qlist.

Finally, the Assistants are added to the Manager which is at last set to visible, making it possible to see the saved assistants.

Well, that is how the current implementation of the saving and loading of assistants is done and I have a request the wonderful artists who use Krita to use the assistants and help in making them better by the day.



About shivaraman iyer

I am B. tech. student in Dhirubhai Ambani Insititute of Information and Communication Technology. I love coding and observing wildlife. I guess I am a friendly person, a very talkative one too, a fast speaker. nothing else pops into my mind now. View all posts by shivaraman iyer

Share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: