Commit 7ee8e9f1 authored by Jonathan Carter's avatar Jonathan Carter

Initial commit

parents
- Display list mode doesn't render sea on Lenovo S10e with Debian/Lenny.
Also Ubuntu VMs.
Hmmm works fine on 64bit Debian/Lenny with Nvidia OpenGL.
Seems to be mesa-only problem.
GL_MAX_ELEMENTS_VERTICES & GL_MAX_ELEMENTS_INDICES are only 3000 on mesa.
Seems to be a GL error in display list.
- GL area dies on Ubuntu in virtualbox when widget is minimised then restored.
(Partial fix in code is to recreate GL area when terrain regenerated)
- Sparc etch build doesn't display on Nvidia i386 machine.
However, nvidia OpenGL i386 build does display on the sparc.
- The Ubuntu dapper built packages seem to have some problems
when meshes are drawn with glDraw[Range]Elements
(NB the problem seems to be in the built app, NOT the xserver).
The confusion seems to occur above the 1k primitives mark.
Reducing the number of primitives per glDrawRangeElements
seems to help although some xservers seem to spew
X Error: GLXBadLargeRequest.
and give a blank view. If this happens, increase the
Create/Colours/...emissive...
spinbox from zero; this uses a different render path.
[I did wonder if this was something to do with Ubuntu using
the mesa GL libraries and Debian using the XFree86 versions:
dpkg-query -S /usr/include/GL/gl.h
Sarge: xlibmesa-gl-dev: /usr/include/GL/gl.h
Dapper: mesa-common-dev: /usr/include/GL/gl.h
But building the package on Debian Etch against
libgl1-mesa-dev,libglu1-mesa-dev,mesa-common-dev
(add them into the yadda build dependencies in the mkdeb script)
doesn't reproduce the problem there.
Both platforms are gcc 4.0.3.
It's a mystery! Any help gratefully received.]
Haven't tried edgy yet.
- fracplanet running on 64 bit lenny shows missing polys
(all sea?) when viewed by display list from 32bit lenny mesa
- Bear in mind that selecting display list rendering means a copy
the GL system takes a copy of the triangle mesh. This needs memory;
if there isn't enough the application may crash (some drivers
may crash if the display list doesn't fit on the graphics card).
- Base land height doesn't affect noise-only terrain
(when vertical perturbation is reduced to zero; probably because
it's expressed as a proportion of vertical perturbation - should
just be absolute).
- Blender seems to ignore alpha in the cloud layer, and renders
it as solid. It doesn't pass per-vertex alphas out to yafray either.
This may just be some material flag which needs setting, but haven't
been able to discover a solution. Any help appreciated.
The workround is to emit an opaque pre-blended cloud layer.
- River generation can be VERY slow (especially at high levels of subdivision)
due to the time taken to fill up large lakes (just like in the real world,
strangely enough :^): raising the water level slightly to the level of a
potential outflow currently necessitates adjusting the height of all the
points in the lake, which takes a long time with big lakes. The progress
dialog gives a bit more feedback about this now. It WILL complete;
just give it time.
- Flat (non-planet) terrain mostly disappears when viewed from beneath due
to back-face culling.
- Export to Blender doesn't support emissive terrain.
- Doing the clouds as a mesh might seem pointless but there
are plans to perturb the mesh to produce weather systems.
Maybe add some height too.
#!/bin/sh
echo "***"
echo "*** This script assumes Debian's Qt setup with a qtchooser supporting the -qt=5 option."
echo "*** On Debian Squeeze, change to use -qt=4 instead."
echo "*** Other Qt setups may require removing the -qt=5 option from qmake and setting QTDIR and PATH as usual."
echo "***"
VERSION_NUMBER=`./VERSION`
qmake -qt=5 "VERSION_NUMBER=$VERSION_NUMBER" fracplanet.pro && make -j 4
This diff is collapsed.
Release 0.5.1:
- Tweaks for Debian/buster.
- Rename BUILD to BUILD.sh; ditch configure; move built-in USAGE processing to USAGE-update.sh and put usage_text.h under version control.
- Some tweaks to code; split Qt includes from common.h to qtcommon.h
Release 0.5.0:
- Verified works with Qt 5.9.1 ("official" Qt release) and g++ 6.3.0 (Debian Stretch version)
- Ditch use of precompiled headers; compilers are awesome these days.
- Increase initial subdivision level to 8.
From release 0.4.0:
- Bump version to 0.4.1
- Fix linkage for Ubuntu Karmic. Seems to work on Lenny too.
- SourceForge platform upgrade. Used:
svn switch --relocate https://fracplanet.svn.sourceforge.net/svnroot/fracplanet "svn+ssh://timday@svn.code.sf.net/p/fracplanet/code"
- Save-for-blender updated (courtesy of Lawrence D'Oliveiro https://github.com/ldo ) ; works with Debian/Wheezy's blender 2.63
From release 0.3.3:
- Bump version number to 0.4.0 (0.4.0dev while under development)
- Migrate sourceforge repository to svn
- Port to Qt4
- Enable multisampling in OpenGL window
- Restructure startup
- Precompiled headers
- CHANGES renamed to NEWS
- License boilerplate managed by "headache"
From release 0.3.2:
- Bump version number to 0.3.3 (dev while under development)
- Add menu entry
- Update for etch & edgy (warning-free c++, package building)
From release 0.3.1:
- Bump version number to 0.3.2 (dev while under development)
- Reinstate weather systems (spinbox to control number).
- Various commandline options (uses boost::program_options).
- Save to texture, shaded and unshaded.
- Illumination direction control
From release 0.3.0:
- Bump version number to 0.3.1dev
- Use boost's mt19937 for random number generation.
- Minor GUI improvement (terrain type pull down).
- Add simple man page.
- Deb building script.
From release 0.2.0:
- Bump version number to 0.3.0
- Different flat terrain types
- Blender export (faux alpha for clouds).
- Internal changes (RGB to RGBA, overload alpha for emission)
- Built in docs
- Cloud layer (with Blender and POV support).
- Render (OpenGL) background colour control
From release 0.1.0:
- Bump version number to 0.2.0
- Progress dialog separated and better behaved
- Variation uses % scale for consistency (was 1/1000ths before)
- Cosmetic changes
- Add multiscale Perlin noise step
- River generation faster and more reliable.
- Subdivision enumerated as 1...levels in progress dialog (not from zero)
- Improvements to river generation memory usage.
- Saved povray file no longer needs colors.inc
From release 0.0.3:
- Bump version number to 0.1.0
- Support emissive oceans and rivers (including POV save)
- Fix .inc filename bug (spurious ")
- Update docs
- Viewer to separate top-level.
- Don't burn CPU when OpenGL area not visible.
- Crude flight-simulator mode. Joystick-mouse selector.
- Save uses Qt file-picker dialog
- Slider control of ambient
- Amount of movement independent of FPS rate.
- Clean up bogus files in CVS
From release 0.0.1:
- Bump version number to 0.0.3 (0.0.2 omitted docs)
- Add fracplanet.htm, fracplanet.css user documentation.
- Minor changes to code (compiles on RH9)
- Tweak doxygen.cfg
- Display list option
- Frame rate display
- VERSION and mktgz done evolvotron style
From release 0.0.0:
- CHANGES file added.
- lake_becomes_sea initialisation changed from 5 to 0.05 (so displays "5" on controls instead of "100").
- Remove .qmake.internal.cache from CVS control (don't you just HATE it when that happens)
- Move hardwired colours into ParametersTerrain class (in anticipation of control from GUI).
- Add colour picking to GUI.
- Bump version number to 0.0.1 (appears only in control_about.cpp)
- Generated .pov file correctly includes basename.inc (was always including terrain.inc before).
ABOUT
=====
Fracplanet generates random planets and terrain areas with oceans,
mountains, icecaps, lakes and rivers. Parameters are specified interactively
and the results displayed using OpenGL. The generated objects can be
exported as Pov-Ray or Blender models, or as textures.
It uses C++ (with STL and boost), Qt and OpenGL.
Home page: http://www.bottlenose.demon.co.uk/share/fracplanet
Author: timday at timday dot com
LICENSE
=======
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
[The license should be in the LICENSE file in this directory]
BUILDING
========
Either
qmake VERSION_NUMBER=x.x.x && qmake
or
./BUILD.sh
will do the same thing using the version number from ./VERSION.
(BUILD.sh assumes a Debian qt setup where a -qt=5 option can be used to select qt version; -qt=4 should also work).
This should give you a "fracplanet" executable which you can run with
./fracplanet
or copy to wherever you like (see INSTALL section below).
Besides the basic manual page in man/man1/fracplanet.1. there's some usage documentation in fracplanet.htm.
This is processed into a usage_text.h included in the build by the builtin-docs-update.sh script.
But usage_text.h is under version control and bundled in the release tarball so there shouldn't be any need to run builtin-docs-update.sh unless you edit fracplanet.htm.
BUILD OPTIONS
=============
Qt's qmake builds the Makefile used to build the application
so to change compile options you should mess with the fracplanet.pro
(if you do change it, do a "make distclean" before
you rebuild to make sure Makefiles are rebuilt)
or provide overrides on qmake's command line.
USAGE
=====
User documentation is contained in fracplanet.htm and accessible
from the ABout tab of the application while running.
If you just want to dive in all you need to know is this:
After changing ANY of the terrain generation parameters, you must
hit "regenerate" to create and display a new model.
This keeps the random seeds for terrain and river generation the same.
There are a couple of extra buttons which also change the random seed
for the terrain or river network before regenerating,
Most of the parameter entry fields have tooltips on them which
give an idea of what they're about.
To begin with it's best to start by making small changes
to most parameters, especially the number of subdivisions.
PERFORMANCE
===========
The biggest factor influencing performance (both generation and
display) is the degree of subdivision. For 9 subdivisions
(for a planet) around 260MB of memory is required. 10 subdivisions
needs just over a gigabyte. Needless to say, if it starts swapping,
it's not pretty.
Generation of rivers and lakes can also be time consuming.
FSAA/MULTISAMPLING
==================
In the past, fracplanet has been got to run nicely antialiased on NVidia hardware and drivers simply by doing
__GL_FSAA_MODE=7 ./fracplanet
Check your graphics card's documentation for current relevant options.
INSTALL
=======
Doing
make install
no longer attempts to do anything useful.
The only build product is the executable "fracplanet";
simply copy it wherever you like.
Other files of interest are:
man/man1/fracplanet.1
fracplanet.htm fracplanet.css
BUGS TODO THANKS NEWS
OTHER STUFF
===========
Probably only of interest to those actively developing the code:
- mktgz builds the tarballs released on sourceforge.
- mkdeb builds .deb binary installables for Debian systems.
(It probably assumes you have things pbuilder set up in a certain way).
- mkdoc (in the CVS, not distributed) builds source-code
documentation using doxygen.
THANKS
======
For update to blender export code for more recent blender:
Lawrence D'Oliveiro https://github.com/ldo
For bug reports, feedback and patches:
Tobias Klausmann
Frank Plohmann
Steve Roylance
Leon Brooks
Selden E Ball Jr
- Needed for Debian "buster": use Qt5
- Suggestions from HolgerOhmacht:
1. missing equatorial mass distribution of rotational spheric objects in space (by planet option)
2. snow option check box
3. maybe size of planet in textbox
4. missing zoom slider
- Suggestion from "floatingw" at
https://sourceforge.net/projects/fracplanet/forums/forum/239388/topic/3497745/index/page/1
"I just realized that by saving the terrain and river seeds you're able to go back to a previous planet after you've pressed the "generate new seed" buttons. Still, I think that there ought to be a method to save all of the current settings in a custom fracplanet file format. That's probably in the roadmap and you just haven't gotten to it yet.
It also would be handy if the settings could be output as comments in the .pov and .py outputs; I now have several planets that I spent lots of time sifting through to find, but I only have the .pov, .py, and texture files for them because I didn't realize that I could just write down the seed numbers."
- Suggestion from Stéphane Mellerio:
Commandline version of tool. Unclear whether it would emit meshes or rendered images (or both).
- stopping flying should hold position and allow spin and tilt manipulation
(have planet rotate under current viewpoint)
- cancel button on progress bar
- plate tectonics simulation:
Use zero contour of multiscale noise field to modulate heights (gives some boundary-like features).
Maybe another field to modulate activity level there (subduction vs collision; fall vs raise terrain?)
- coding style is a mess of _-prefixed and not prefixed members.
Cleanup should include stronger use of accessors.
- Get models into K3D somehow
Generating python for K3D's idea of a mesh_source script seems most promising.
Does seem to allow setting of vertex properties.
Imported file formats all too limiting, and python API maybe better documented
than K3D's XML file format.
- Sourceforge tracker reports problems with Beryl/Compiz.
Try it out now have this working with Debian/lenny.
- Export Ogre .xml mesh files:
http://www.ogre3d.org/wiki/index.php/Creating_a_triangle_strip
http://www.ogre3d.org/phpBB2/viewtopic.php?p=228739#228739
http://www.ogre3d.org/wiki/index.php/Ogre_meshxml_DTD
- Debian transitioning Apps to Applications (post Etch) see bug 361418
- Look at Art of Illusion. Try it's .pov import.
(It can also import .obj, but that doesn't support per-vertext colour).
- Texture export should have the option of a .obj file for the DEM.
- Export to wings3d ? Would probably be via .obj
- If you checkout fracplanet to say fracplanet-0.3.3 then mktgz script doesn't like it.
(Not clear how useful this is in practice because you wouldn't tag it in cvs without building
tgz first to check testtgz and mkdeb; maybe something like -0.3.3rc1 though ?).
- .debs should create a menu entry.
They do, but yada bug (Debian #419878) getting in the way.
Doesn't work on Ubuntu either (install to wrong dir? no update menu?)
- DEB_BUILD_OPTIONS should also recognize debug ? (and do same as noopt probably)
It's not actually in the policy manual.
- Check clouds tab's documentation.
- More control over clouds.
- Texture render should also output a specular map for celestia.
- Add an option to load vertex heights from a DEM
(would replace mid-point perturbation during subdivision;
would retain our colouring rules, ability to add noise, rivers etc).
- Texture render for clouds.
Will end up with duplicate code in cloud mesh's ScanConvertHelper; use boost MPL/Fusion
to produce generic version operating on general tuples ?
- Craters.
- X gets bigger when using display lists (remote only?) ? Need to delete on exit ?
- Find out what the errors are this guy mentions:
http://douglas.nerad.org/journal/2006/04/03/
- More control over weather and clouds.
- Another noise fn to modulate (c.f add) subdivided terrain.
Might help reduce middle-of-continent highlands.
- Another noise fn to modulate power law
(could get a mix of highland mesas and deposited lowlands).
- Use Qtime (getCurrentTime) instead of time (more portable ?).
- Abort on progress bar (throw exception out to top level ? Hmmm)
- Make colours depend on more interesting things than height (e.g slope)
- Reshow, so don't need to regenerate after hiding viewer
- Save to texture with shading for spheres should have the option of some
sort of "atlas shading": effectively local illumination giving
impression terrain has been "unpeeled" then illuminated.
- Does POV-Ray mesh support given vertex normals ?
Renderings show facet shading with smooth colouring, which is
legitimate but maybe not what's wanted.
(Hmmm can't actually remember how fracplanet does this but it doesn't
show facets).
- Move blender/pov save parameters into nested classes,
pass parameters into lowest-level save fns rather than multiple args.
- Scale parameter for blender output.
- Ability to load/save fracplanet parameters (simple keyword=value text file)
- Mesh optimisation.
- Save clouds as some more blender-friendly texture type thing.
- Rename Save to Export.
(Eventually want Save/Load/Export POV-Ray/Export Blender/Export Texture/Import Texture).
- Cloud controls. Noise parameters and thresholds.
- More control over cloud undersides, shadowing etc (c.f on/off in POVRay).
(Add checkboxes to POVRay save dialog).
Maybe need better control over ambient, or actually use the ambient
parameter on the render tab (move to colours). Then shadows
wouldn't be black; wouldn't get a night-side though, without varying
ambient around sphere.
- Give cloud illusion of depth using GLSL (parallax effects).
- Use GLSL to get hard edged rivers.
Not so useful without some way of exporting to PovRay/Blender (texture and texture co-ords?)
- Shadows of clouds on ground in OpenGL (needs shaders, shadow buffers etc).
- Optimise matix33 inversion
- End abuse of alpha as flag; just use it as the emissive quantity.
Mesh then gets a flag for meaning of alpha channels.
- Terrain patches but with planetary geometry (ie curvature).
This would give a sensible horizon when near the centre of the patch.
- Control over treeline and shoreline heights (these are hardwired currently).
- Clean up progress stuff; push steps->% (rate management) into progress API.
- std::auto_ptr sucks; use something better from boost
- Add perturbation decay rate for subdivision too.
- Noise perturbation in X&Y too;
might help break up subdivision ridge artefacts
- Basic "man" page besides HTML
- Make more keys do stuff in fly mode (e.g home to return to start).
- Console mode app: read parameters, generate planet.
- Fix river/lake hang for high subdivision levels
- Perlin noise to modify terrain colours.
- Continue GUI procesing when progressing.
- More feedback (progress bar?) when building display list
(unfortunately a lot of the delay happens in OpenGL when the list is completed)
- Borrow some improvements from sister evolvotron project
- Check for OpenGL errors
- Add control over heights at which colours switch.
- Improve code documentation.
- Save/load parameters. Automatic mode (load parameters, generate model, exit).
- Seasonal variations.
e.g snowline, ice packs on ocean.
- Ability to save sequences of models
(probably by offline generation for parameter file load)
- Are we 64bit ready ? Onwards to subdivision levels 12,13,14...
- Put ONLY the terrain data in the .inc file; rest in .pov or a different .inc
- Split up mesh file (3 parts: vertices, colours, meshing)
- Ringworld and Dyson sphere/hollow-Earth starting geometries for fun.
- yafray export (note povray not available for sparc, but yafray is)
Could do, but rejected:
- Build for ultrasparc
./configure 'QMAKE_CXXFLAGS_RELEASE += -mcpu=ultrasparc'
but it's no faster
#!/bin/bash
# Script to echo the current version number.
# THIS IS THE ONLY PLACE A VERSION NUMBER SHOULD BE SPECIFIED
# NB If you edit this, you will need to "make distclean" and then rebuild (./BUILD) as there is no dependency checking
# Avoid '-' or '_' in the version as it confuses mkdeb.
# Use dev or wip qualifier while working to a release.
echo "0.5.1"
/**************************************************************************/
/* Copyright 2009 Tim Day */
/* */
/* This file is part of Fracplanet */
/* */
/* Fracplanet is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Fracplanet is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
/**************************************************************************/
#include "common.h"
void fatal_error(const char* msg)
{
std::cerr
<< "\n*** Fatal error: "
<< msg
<< " ***\n";
exit(1);
}
void fatal_internal_error(const char* src_file,uint src_line)
{
std::cerr
<< "\n*** Fatal internal error in "
<< src_file
<< " at line "
<< src_line
<< " ***\n";
exit(1);
}
void constraint_violation(const char* test,const char* src_file,uint src_line)
{
std::cerr
<< "\n*** Constraint \""
<< test
<< "\" violated in file"
<< src_file
<< " at line "
<< src_line
<< " ***\n";
exit(1);
}
/**************************************************************************/
/* Copyright 2009 Tim Day */
/* */
/* This file is part of Fracplanet */
/* */
/* Fracplanet is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Fracplanet is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
/**************************************************************************/
#ifndef _common_h_
#define _common_h_
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
#include <boost/random.hpp>
#include <boost/range.hpp>
#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
#define stringify(S) __STRING(S)
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;
template <class T> inline const T maximum(T a,T b) {return (a>b ? a : b);}
template <class T> inline const T minimum(T a,T b) {return (a<b ? a : b);}
template <class T> inline const T maximum(T a,T b,T c) {return maximum(a,maximum(b,c));}
template <class T> inline const T minimum(T a,T b,T c) {return minimum(a,minimum(b,c));}
template <class T> inline const T maximum(T a,T b,T c,T d) {return maximum(maximum(a,b),maximum(c,d));}
template <class T> inline const T minimum(T a,T b,T c,T d) {return minimum(minimum(a,b),minimum(c,d));}
template <class T> inline const T sqr(T a) {return a*a;}
template <class T> inline const T clamped(T v,T lo,T hi) {return (v<lo ? lo : (v>hi ? hi : v));}
template <class T> inline void clamp(T& v,T lo,T hi) {v=(v<lo ? lo : (v>hi ? hi : v));}
template <class T> inline void exchange(T& a,T& b) {const T x(a);a=b;b=x;}
extern void fatal_error(const char*);
inline void fatal_error(const std::string& s)
{
fatal_error(s.c_str());
}
extern void fatal_internal_error(const char* src_file,uint src_line);
extern void constraint_violation(const char* test,const char* src_file,uint src_line);
#define constraint(TEST) {if (!TEST) {constraint_violation(#TEST,__FILE__,__LINE__);}}
#endif
#!/bin/sh
echo "***"
echo "*** This script assumes Debian's Qt setup with a qtchooser supporting the -qt=5 option."
echo "*** On Debian Squeeze, change to use -qt=4 instead."
echo "*** Other Qt setups may require removing the -qt=5 option from qmake and setting QTDIR and PATH as usual."
echo "***"
VERSION_NUMBER=`./VERSION`
qmake -qt=5 "VERSION_NUMBER=$VERSION_NUMBER" "$@" fracplanet.pro && make -j 4
/**************************************************************************/
/* Copyright 2009 Tim Day */
/* */
/* This file is part of Fracplanet */
/* */
/* Fracplanet is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Fracplanet is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
/**************************************************************************/
#include "control.h"
Control::Control()
:QWidget()
{
setLayout(new QVBoxLayout());
}
Control::~Control()
{}
void Control::pickColour(QPushButton* button,FloatRGBA& colour)
{
const ByteRGBA col_old(colour);
QColor qcol_old(col_old.r,col_old.g,col_old.b);
QColor qcol_new=QColorDialog::getColor(qcol_old,this);
if (qcol_new.isValid())
{
colour=FloatRGBA(ByteRGBA(qcol_new.red(),qcol_new.green(),qcol_new.blue(),255));
QPixmap pmap(16,16);
pmap.fill(qcol_new);
button->setIcon(QIcon(pmap));
}
}
/*! Used when initialising colour-chooser buttons.
*/
QIcon Control::build_icon_of_colour(const FloatRGBA& col)
{
QPixmap pmap(16,16);
const ByteRGBA bcol(col);
pmap.fill(QColor(bcol.r,bcol.g,bcol.b));
return QIcon(pmap);
}
/**************************************************************************/
/* Copyright 2009 Tim Day */
/* */
/* This file is part of Fracplanet */
/* */
/* Fracplanet is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Fracplanet is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
/**************************************************************************/
/*! \file
\brief Interface for class Control.
*/
#ifndef _control_h_
#define _control_h_
#include "common.h"
#include "rgb.h"
#include "qtcommon.h"
//! Base class for other controls; useful for shared stuff.
class Control : public QWidget
{
public:
Control();
~Control();
//! Use Qt's colour-picking dialog to replace the referenced colour
void pickColour(QPushButton* button,FloatRGBA& colour);
protected:
//! Utility function to build a small Qt icon of the specified colour.
static QIcon build_icon_of_colour(const FloatRGBA& col);
};
#endif
/**************************************************************************/
/* Copyright 2009 Tim Day */
/* */
/* This file is part of Fracplanet */
/* */
/* Fracplanet is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Fracplanet is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
/**************************************************************************/
#include "control_about.h"