<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Isti&#039;s Blog &#187; Arthur Fractal Generator</title>
	<atom:link href="http://www.xistix.com/blog/category/arthur-fractal-generator/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xistix.com/blog</link>
	<description>Tutorials, examples, 42</description>
	<lastBuildDate>Mon, 19 Apr 2010 20:16:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Save and Load</title>
		<link>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/</link>
		<comments>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 09:18:06 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[finish]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=240</guid>
		<description><![CDATA[So far I was not a great finisher. I mean I usually didn&#8217;t finish my personal projects. After solving the challenging parts, I usually loose interest and abandon the project. I decided I will change and I will finish Arthur. If you followed this blog you might remember that the original goal was to get [...]]]></description>
			<content:encoded><![CDATA[<p>So far I was not a great finisher. I mean I usually didn&#8217;t finish my personal projects. After solving the challenging parts, I usually loose interest and abandon the project. I decided I will change and I will finish Arthur. If you followed this blog you might remember that the original goal was to get familiar with QT and not to write a full featured fractal generator. I think this mission is completed now, but the program itself was missing some crucial parts. Especially saving and loading the fractals. You could already save the generated images earlier, but you could not load the fractal for further editing. I really thought is is boring to write some code to save and load the necessary data. I can tell you it was boring <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  However I feel better now, since I have a more or less completed program.</p>
<p>OK. To make the boring stuff a bit more interesting I decided that I will store the fractal data in XML format. There is no particular reason for that apart from the fact that I am a great fan of XML. However it was a good opportunity to have a look at the XML library in QT. Yeah, nothing special. The usual stuff. If you used other XML libraries before, everything will be familiar.</p>
<p>While thinking what data I should actually save I faced a problem with the palette. Actually I was thinking whether I should save the palette or just a reference to the palette file. Finally I decided to put the palette to the fractal description file. This way it is easier it share fractal files, since everything is packed to one file. As a side effect I introduced a very simple XML format for the palette and added a new feature to Arthur that one can load the palette of a fractal.</p>
<p>From now on I will not develop Arthur further until someone starts begging to me to do so <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I admit there might be lots of design issues with it (it wasn&#8217;t actually designed eh eh) and it is far from industrial quality, but it was not the aim. I learned quite much about QT while I was making it and I hope some parts of it can be used as examples to solve your problems.</p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2009/01/fractal017.tgz">fractal017</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Newton</title>
		<link>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/</link>
		<comments>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 07:14:34 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[newton]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=226</guid>
		<description><![CDATA[I added two new fractals to Arthur. They are both calculated with Newton&#8217;s method, that is: z -&#62; z &#8211; f(z) / f&#8217;(z) Newton invented this formula to estimate roots of functions. The initial z is an estimation of the root. The calculated z is closer to the root that is a better estimation. If [...]]]></description>
			<content:encoded><![CDATA[<p>I added two new fractals to Arthur. They are both calculated with Newton&#8217;s method, that is:<br />
z -&gt; z &#8211; f(z) / f&#8217;(z)<br />
Newton invented this formula to estimate roots of functions. The initial z is an estimation of the root. The calculated z is closer to the root that is a better estimation. If we calculate the formula iteratively, z converges to one of the roots of f(z).</p>
<p>My newton fractals are colored according to the number of necessary iterations to get in a predefined distance with z from one of the roots.</p>
<p>The newton001 fractal is using the f(z) = z^3 &#8211; 1 polynomial.<br />
f&#8217;(z) = 3z^2</p>
<p>z -&gt; z &#8211; f(z) / f&#8217;(z) = z &#8211; (z^3 &#8211; 1) / 3z^2 = (2z^3 + 1) / 3z^2</p>
<p>The roots of f(z) are: 1, -0.5 + 0.86603i and -0.5 &#8211; 0.86603i</p>
<p>Here is an image of the fractal:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/newton001.jpg"><img class="alignnone size-medium wp-image-228" title="newton001" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/newton001-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The newton002 fractal is using the f(z) = z^4 &#8211; 1 polynomial<br />
f&#8217;(z) = 4z^3</p>
<p>z -&gt; z &#8211; f(z) / f&#8217;(z) = z &#8211; (z^4 &#8211; 1) / 4z^3 = (3z^4 + 1) / 4z^3</p>
<p>The roots of f(z) are: 1, i, -1 and -i</p>
<p>Here is an image of the fractal:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/newton002.jpg"><img class="alignnone size-medium wp-image-229" title="newton002" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/newton002-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You can get the newest sources of Arthur from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal016.tgz">fractal016</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; About</title>
		<link>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/</link>
		<comments>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 13:58:11 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[palette]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=213</guid>
		<description><![CDATA[This post is just about some minor updates on Arthur. I added a default palette menu point to Arthur to make the original palette available any time. I also added an about dialog. I created the about dialog mainly with Designer. Then I just connected its execution to the corresponding menu point signal. Here are [...]]]></description>
			<content:encoded><![CDATA[<p>This post is just about some minor updates on Arthur. I added a default palette menu point to Arthur to make the original palette available any time. I also added an about dialog. I created the about dialog mainly with Designer. Then I just connected its execution to the corresponding menu point signal.</p>
<p>Here are the newest sources: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal015.tgz">fractal015</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Loading Palette</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 21:45:28 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[palette]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=209</guid>
		<description><![CDATA[So far I didn&#8217;t spend too much time with the colors themselves in the palette. I used a palette which I generated by changing the rgb values linearly. I still do not want to spend time for figuring out new palette generation algorithms or implementing existing ones. Rather I added palette loading functionality to Arthur [...]]]></description>
			<content:encoded><![CDATA[<p>So far I didn&#8217;t spend too much time with the colors themselves in the palette. I used a palette which I generated by changing the rgb values linearly. I still do not want to spend time for figuring out new palette generation algorithms or implementing existing ones. Rather I added palette loading functionality to Arthur to load ready made palettes. This way palettes can be generated by other programs like GIMP. So I checked what palette file format gimp is using. It is very simple. The rgb values are stored in a text file. Each value is in its own line. Values are separated by white spaces. I wrote a loader that opens a text file and reads lines from it until the end of the file or until we filled all the 256 colors in the color table.</p>
<p>For each line I do the followings:</p>
<ol>
<li>Simplify the line (white spaces converted to spaces)</li>
<li>Split the line to items at each space</li>
<li>Remove empty items</li>
<li>If we had at least three items remained, try to convert the first three items to integer numbers.</li>
<li>If all the three conversion went fine, add the color to the color table</li>
</ol>
<p>If the file ends before we fill all the 256 colors, the loader fills the rest of the colors with black values.</p>
<p>If the file contains more than 256 color entries than the loader does not read further after the 256th color is loaded.</p>
<p>This way I can handle e.g. GIMP palette files (*.gpl) or anything that fulfills the rule of the algorithm above.</p>
<p>I added a palette folder to the sources and copied two palettes from GIMP as examples.</p>
<p>Here is a Julia fractal rendered with the Firecode.gpl palette:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/fire.png"><img class="alignnone size-medium wp-image-210" title="fire" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fire-277x300.png" alt="" width="277" height="300" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal014.tgz">fractal014</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Palette Rotation</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:36:09 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[palette]]></category>
		<category><![CDATA[rotation]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=201</guid>
		<description><![CDATA[Adding palette rotation to Arthur was fairly easy. All I had to do is to add some buttons to the UI for stepping and rotating back and forth and an additional stop button for stopping rotation. Then I connected the action handlers to the buttons. Since I handle the image as an indexed image, stepping [...]]]></description>
			<content:encoded><![CDATA[<p>Adding palette rotation to Arthur was fairly easy. All I had to do is to add some buttons to the UI for stepping and rotating back and forth and an additional stop button for stopping rotation. Then I connected the action handlers to the buttons. Since I handle the image as an indexed image, stepping the palette means stepping the colors in the palette. So I implemented a step forward method, which copies every color in the palette one position forward and copies the last color to the first place. I also made another method that does the same in the opposite direction. When I need step, I simply call the corresponding method. When I need continuous rotation I need to call these methods again and again. So I implemented the methods as slots. I introduced timers for the forward and backward rotation. And in the canvas constructor I connected the timer event signals to the corresponding palette step slots. The rotation activation means starting the corresponding timer. Stopping is just stopping the timer. Easy, isn&#8217;t it?</p>
<p>Here is a screenshot about Arthur with its new palette buttons:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/palettebuttons.png"><img class="alignnone size-medium wp-image-207" title="palettebuttons" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/palettebuttons-280x300.png" alt="" width="280" height="300" /></a></p>
<p>Here is an animated GIF. I saved the frames as PNG images from Arthur. I made one forward palette step before saving the next frame. Then I used GIMP to make an animated GIF from the PNGs.</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/paletterotation.gif"><img class="alignnone size-full wp-image-204" title="paletterotation" src="http://www.xistix.com/blog/wp-content/uploads/2008/12/paletterotation.gif" alt="" width="320" height="240" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal013.tgz">fractal013</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; New Canvas</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 08:53:46 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[selection]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=194</guid>
		<description><![CDATA[In the former posts I experimented with a custom widget containing a QImage. I integrated that widget to Arthur. I replaced the old QLabel and QPixmap based widget with this custom widget. This way I have more freedom with image handling. I could even have direct access to image memory etc. The other benefit is [...]]]></description>
			<content:encoded><![CDATA[<p>In the former posts I experimented with a custom widget containing a QImage. I integrated that widget to Arthur. I replaced the old QLabel and QPixmap based widget with this custom widget. This way I have more freedom with image handling. I could even have direct access to image memory etc. The other benefit is that QImage can handle indexed images, so I do not need a separate map for holding color indexes and I can also avoid copying the map to pixmap.</p>
<p>I also changed the way of selection a bit. Now the point, where the mouse is pressed first will remain in the center of the selection. This way the user can center the most interesting part in the resulting picture.</p>
<p>Here is a screenshot:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/mandelbrotnewcanvas.png"><img class="alignnone size-medium wp-image-195" title="mandelbrotnewcanvas" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/mandelbrotnewcanvas-281x300.png" alt="" width="281" height="300" /></a></p>
<p>There is no difference in appearance anyway <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal012.tgz">fractal012</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Julia</title>
		<link>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/</link>
		<comments>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 19:23:20 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[Julia]]></category>
		<category><![CDATA[mandelbrot]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=181</guid>
		<description><![CDATA[I have added a new fractal formula to Arthur. Now it is possible to select from two fractals Mandelbrot and Julia. Julia is very similar to the Manderlbrot. The difference is that Julia uses a constant in the equation, which remains the same for the whole set at any point. The most interesting Julia fractals [...]]]></description>
			<content:encoded><![CDATA[<p>I have added a new fractal formula to Arthur. Now it is possible to select from two fractals Mandelbrot and <span style="color: #ff6600;">Julia</span>. Julia is very similar to the Manderlbrot. The difference is that <span style="color: #ff6600;">Julia uses a constant</span> in the equation, which remains the same for the whole set at any point. The most interesting Julia fractals can be generated with <span style="color: #ff6600;">constants</span> which are <span style="color: #ff6600;">close to the boundaries</span> of the corresponding <span style="color: #ff6600;">Mandelbrot</span> set. I added a <span style="color: #ff6600;">dialog</span> to the <span style="color: #ff6600;">calculator constructor</span> which reads the <span style="color: #ff6600;">Julia constant from text line inputs</span>. To ease the selection of good values I also added a <span style="color: #ff6600;">label with a Mandelbrot set picture</span>. The label is promoted to an inherited class which handles mouse press events. With the help of <span style="color: #ff6600;">signals and slots</span> I connected the event handler to the <span style="color: #ff6600;">setText</span> <span style="color: #ff6600;">slots</span> of the line edits. The user can click somewhere around the boundary and get the corresponding Julia constant to the line edits.</p>
<p>Here is screenshot of the dialog:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/juliaconstantdialog.png"><img class="alignnone size-medium wp-image-182" title="Julia Constant Dialog" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/juliaconstantdialog-265x300.png" alt="" width="265" height="300" /></a></p>
<p>Here is a Julia fractal generated by Arthur:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/julia.jpg"><img class="alignnone size-medium wp-image-183" title="Julia" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/julia-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal011.tgz">fractal011</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; GPL License</title>
		<link>http://www.xistix.com/blog/2008/12/04/a-qt-project-fractal-generator-gpl-license/</link>
		<comments>http://www.xistix.com/blog/2008/12/04/a-qt-project-fractal-generator-gpl-license/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 15:48:38 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[License]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=178</guid>
		<description><![CDATA[Until now, I was too lazy to license Arthur. I should have done this right at the beginning. Now Arthur is published under the GNU General Public License. You can download Arthur here: fractal010]]></description>
			<content:encoded><![CDATA[<p>Until now, I was too lazy to license Arthur. I should have done this right at the beginning. Now Arthur is published under the <a href="http://www.gnu.org/licenses/gpl.txt">GNU General Public License.</a></p>
<p>You can download Arthur here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal010.tgz">fractal010</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/04/a-qt-project-fractal-generator-gpl-license/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Size and Status</title>
		<link>http://www.xistix.com/blog/2008/12/02/a-qt-project-fractal-generator-size-and-status/</link>
		<comments>http://www.xistix.com/blog/2008/12/02/a-qt-project-fractal-generator-size-and-status/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 19:12:04 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[size]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=174</guid>
		<description><![CDATA[In this vesrion I introduced resizing capabilities to Arthur. I simply added a size menu item to the main menu in designer. Into the submenu I added some standard screen sizes, Maybe later on I will add custom size, too. Then in main.cpp I connected to the action signals to some handlers in the ArthurActions [...]]]></description>
			<content:encoded><![CDATA[<p>In this vesrion I introduced <span style="color: #ff6600;">resizing</span> capabilities to Arthur. I simply added a <span style="color: #ff6600;">size menu item</span> to the main menu in designer. Into the submenu I added some <span style="color: #ff6600;">standard screen sizes</span>, Maybe later on I will add custom size, too. Then in <span style="color: #ff6600;">main.cpp</span> I <span style="color: #ff6600;">connected</span> to the action <span style="color: #ff6600;">signals</span> to some <span style="color: #ff6600;">handlers</span> in the <span style="color: #ff6600;">ArthurActions</span> class. In order to resize the fractal I implemented a <span style="color: #ff6600;">setSize</span> method to the <span style="color: #ff6600;">ArthurFractal </span>class.</p>
<p>I also wanted to add some <span style="color: #ff6600;">feedback</span> about the <span style="color: #ff6600;">drawing</span> in case it takes longer time. I added a <span style="color: #ff6600;">slot</span> to <span style="color: #ff6600;">ArthurCanvas</span> which <span style="color: #ff6600;">redraws</span> the image from the fractal data. The I added a <span style="color: #ff6600;">signal</span> to <span style="color: #ff6600;">ArthurFractal</span>, which is connected to that slot. This way I can send signals to the canvas  while calculating. I send the signal four times in a session. Maybe later I add some possibility to the ui to change this number.</p>
<p>You can get the source from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal009.tgz">fractal009</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/02/a-qt-project-fractal-generator-size-and-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Signals and Slots</title>
		<link>http://www.xistix.com/blog/2008/11/28/a-qt-project-fractal-generator-signals-and-slots/</link>
		<comments>http://www.xistix.com/blog/2008/11/28/a-qt-project-fractal-generator-signals-and-slots/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 08:06:21 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[signals]]></category>
		<category><![CDATA[slots]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=167</guid>
		<description><![CDATA[I went one step further with Arthur. I introduced some new menu items and icons. I mainly used Designer for this. I had a little problem to find some icons. I mean, not the finding was the problem, but find some open source ones. Then it came to my mind that Designer has some icons [...]]]></description>
			<content:encoded><![CDATA[<p>I went one step further with Arthur. I introduced some new <span style="color: #ff6600;">menu items</span> and <span style="color: #ff6600;">icons</span>. I mainly used <span style="color: #ff6600;">Designer</span> for this. I had a little problem to find some icons. I mean, not the finding was the problem, but find some open source ones. Then it came to my mind that <span style="color: #ff6600;">Designer has</span> some <span style="color: #ff6600;">icons</span> itself and they should be in the <span style="color: #ff6600;">qt sources</span> somewhere <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Let it be your homework where they are.</p>
<p>OK. So I added the icons to buttons, and had some <span style="color: #ff6600;">action signals</span> generated by the menu item and icon interactions. All what I had to do is to <span style="color: #ff6600;">connect</span> them to some <span style="color: #ff6600;">slots</span> which do something sensible. First of all I wanted to have <span style="color: #ff6600;">image saving</span> possibility. When the user clicks the corresponding icon the program should check whether we already have a <span style="color: #ff6600;">filename</span>. If yes, we <span style="color: #ff6600;">save</span> the file. If not we pop up a <span style="color: #ff6600;">save as</span> dialog.</p>
<p>The easiest place for the signal connection would be the ui class, but that is generated so I didn&#8217;t  want to mess up with that. So, I created a new class for <span style="color: #ff6600;">event handling</span>: <span style="color: #ff6600;">ArthurActions</span>. It is in the <span style="color: #ff6600;">arthur_actions.h</span> file. The class is inherited from <span style="color: #ff6600;">QObject</span> in order to introduce <span style="color: #ff6600;">slots</span>. So far I added two slots: <span style="color: #ff6600;">onSaveImageAs</span> and <span style="color: #ff6600;">onSaveImage</span>. I also added a private <span style="color: #ff6600;">pointer to the ui</span> and its <span style="color: #ff6600;">setUi</span> method, since I need access to the ui elements when handling ui events. E.g. in this case I need access to the pixmap of ArthurCanvas if I want to save it. When adding signals and/or slots you have to use the <span style="color: #ff6600;">Q_OBJECT</span> macro. See my former post about the nightmare it can cause eh eh. Especially when you are stupid like me <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can check the implementation of the class in <span style="color: #ff6600;">arthur_actions.cpp</span>. You will be surprised how simple it is. Saving the pixmap is the following with QT:</p>
<p><span style="color: #ff6600;">ui-&gt;label-&gt;pixmap()-&gt;save(imageFileName);</span></p>
<p>The file extension in the imageFileName controls the file format. I checked *.png *.xpm *.jpg *.bmp *.tif so far. All works. I start to like QT <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  OK. Forgetting the vtable game will take long time but this compensates somewhat. I also like the ready made <span style="color: #ff6600;">QFileDialog</span>. Really cool.</p>
<p>Whe the implementation was ready I just <span style="color: #ff6600;">connected</span> the <span style="color: #ff6600;">ui signals</span> to the <span style="color: #ff6600;">ArthurCanvas slots</span> in <span style="color: #ff6600;">main.cpp</span> and that is it.</p>
<p>Here is an example JPG which I saved with Arthur:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/11/mandelbrot.jpg"><img class="alignnone size-medium wp-image-168" title="Mandelbrot" src="http://www.kultatech.com/blog/wp-content/uploads/2008/11/mandelbrot-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You can download the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/11/fractal008.tgz">fractal008</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/11/28/a-qt-project-fractal-generator-signals-and-slots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
