Commit 7ac5fa01 authored by Torsten Rahn's avatar Torsten Rahn
Browse files

More work towards an improved Model-View

	architecture.

	* src/lib/PlaceMarkLayout.cpp:
	* src/lib/PlaceMarkPainter.{h,cpp}:
	- More polishing in the layout/painter 
	  classes.

	* src/lib/TextureColorizer.cpp:
	* src/lib/texturepalette.cpp:
	* src/lib/ClipPainter.cpp:
	* tools/palettegen/palettegen.cpp:
	- Fixing tiny bug to improve render quality.
	- preparing further improved relief rendering.


svn path=/trunk/KDE/kdeedu/marble/; revision=717046
parent f1b608a9
2007-09-25 Torsten Rahn <rahn@kde.org>
* src/lib/PlaceMarkLayout.cpp:
* src/lib/PlaceMarkPainter.{h,cpp}:
- More polishing in the layout/painter
classes.
* src/lib/TextureColorizer.cpp:
* src/lib/texturepalette.cpp:
* src/lib/ClipPainter.cpp:
* tools/palettegen/palettegen.cpp:
- Fixing tiny bug to improve render quality.
- preparing further improved relief rendering.
2007-09-25 Inge Wallin <inge@lysator.liu.se>
Make BUGS file actually usable.
......
......@@ -28,7 +28,7 @@ ClipPainter::ClipPainter(QPaintDevice * pd, bool clip)
m_left = -1.0;
m_right = (double)(m_imgwidth);
m_top = 0.0;
m_top = -1.0;
m_bottom = (double)(m_imgheight);
// m_debugNodeCount = 0;
......
......@@ -55,7 +55,31 @@ PlaceMarkLayout::PlaceMarkLayout( QObject* parent )
m_fontascent = QFontMetrics( m_font_regular ).ascent();
m_labelareaheight = 2 * m_fontheight;
/*
// Old weightfilter array. Still here
// to be able to compare performance
m_weightfilter
<< 9999
<< 4200
<< 3900
<< 3600
<< 3300
<< 3000
<< 2700
<< 2400
<< 2100
<< 1800
<< 1500
<< 1200
<< 900
<< 400
<< 200
<< 0;
*/
m_weightfilter
<< 49300
<< 40300
......@@ -180,14 +204,10 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
const QVector<VisiblePlaceMark*> currentsec = rowsection.at( y / m_labelareaheight );
// Find out whether the area around the placemark is covered already.
QRect labelRect = roomForLabel( index, currentsec, x, y, textWidth );
// If there's not enough space free don't add a VisiblePlaceMark here.
if ( labelRect.isNull() )
{
// Don't add a VisiblePlaceMark here, as there are just too many
// other labels around it so there is no room.
continue;
}
QRect labelRect = roomForLabel( index, currentsec, x, y, textWidth );
if ( labelRect.isNull() ) continue;
// Make sure not to draw more placemarks on the screen than
// specified by "maxlabels".
......@@ -235,9 +255,9 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
for ( int i = 0; i < model->rowCount(); ++i )
{
const QModelIndex index = model->index( i, 0 );
QModelIndex index = model->index( i, 0 );
const int populationIndex = index.data( PlaceMarkModel::PopulationIndexRole ).toInt();
int populationIndex = index.data( PlaceMarkModel::PopulationIndexRole ).toInt();
// Skip the places that are too small.
if ( noFilter == false ) {
......@@ -274,8 +294,7 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
/**
* We handled selected place marks already, so skip here...
* Given that we assume that only a small amount of places is selected
* we check for the selected state after all filters that don't
* change the visible placemark lists.
* we check for the selected state after all other filters
*/
if ( isSelected )
continue;
......@@ -299,15 +318,11 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
// Choose Section
const QVector<VisiblePlaceMark*> currentsec = rowsection.at( y / m_labelareaheight );
// Find out whether the area around the placemark is covered already.
QRect labelRect = roomForLabel( index, currentsec, x, y, textWidth );
// Find out whether the area around the placemark is covered already.
// If there's not enough space free don't add a VisiblePlaceMark here.
if ( labelRect.isNull() )
{
// Don't add a VisiblePlaceMark here, as there are just too many
// other labels around it so there is no room.
continue;
}
QRect labelRect = roomForLabel( index, currentsec, x, y, textWidth );
if ( labelRect.isNull() ) continue;
// Make sure not to draw more placemarks on the screen than
// specified by "maxlabels".
......@@ -343,8 +358,7 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
m_paintOrder.append( mark );
}
m_placeMarkPainter->drawPlaceMarks( painter, m_paintOrder, selection, viewParams, imgwidth );
m_placeMarkPainter->drawPlaceMarks( painter, m_paintOrder, selection, viewParams );
}
inline bool PlaceMarkLayout::locatedOnScreen ( const QPersistentModelIndex &index,
......
......@@ -50,11 +50,12 @@ void PlaceMarkPainter::setLabelColor( const QColor &color )
void PlaceMarkPainter::drawPlaceMarks( QPainter* painter,
QVector<VisiblePlaceMark*> visiblePlaceMarks,
const QItemSelection &selection,
ViewParams *viewParams, int imgwidth )
ViewParams *viewParams )
{
QVector<VisiblePlaceMark*>::const_iterator visit = visiblePlaceMarks.constEnd();
VisiblePlaceMark *mark = 0;
int imageWidth = viewParams->m_canvasImage->width();
switch( viewParams->m_projection ) {
case Spherical:
......@@ -109,7 +110,7 @@ void PlaceMarkPainter::drawPlaceMarks( QPainter* painter,
}
for ( int i = tempSymbol;
i <= imgwidth;
i <= imageWidth;
i += 4 * viewParams->m_radius )
{
QRect labelRect( mark->labelRect() );
......
......@@ -44,7 +44,7 @@ class PlaceMarkPainter : public QObject
void drawPlaceMarks( QPainter* painter,
QVector<VisiblePlaceMark*> visiblePlaceMarks,
const QItemSelection &selection,
ViewParams *viewParams, int imgwidth = 0 );
ViewParams *viewParams );
/**
* Sets the @p color that shall be used for painting the labels.
......
......@@ -88,11 +88,24 @@ void TextureColorizer::colorize(ViewParams *viewParams)
emboss.buffer = emboss.buffer >> 8;
emboss.gpuint.x4 = grey;
if ( showRelief == true && emboss.gpuint.x1 > grey )
bump = ( emboss.gpuint.x1 - grey ) & 0x0f;
if ( showRelief == true )
{
bump = emboss.gpuint.x1 - grey;
if ( bump > 15 ) bump = 15;
if ( bump < 0 ) bump = 0;
}
else
bump = 0;
/*
if ( showRelief == true )
{
bump = ( emboss.gpuint.x1 + 7 - grey );
if ( bump < 0 ) bump = 0;
if ( bump > 15 ) bump = 15;
}
else
bump = 8;
*/
if ( *coastdata == landoffscreen )
*data = texturepalette[bump][grey + 0x100];
else {
......@@ -136,6 +149,20 @@ void TextureColorizer::colorize(ViewParams *viewParams)
emboss.buffer = emboss.buffer >> 8;
emboss.gpuint.x4 = grey;
if ( showRelief == true )
{
bump = ( emboss.gpuint.x1 - grey ) >> 1;
bendradius = bendReliefx * relief;
bump *= qRound( 1.0 - bendradius * bendradius );
if ( bump > 15 ) bump = 15;
if ( bump < 0 ) bump = 0;
}
else
bump = 0;
/*
if ( showRelief == true && emboss.gpuint.x1 > grey ) {
bump = ( emboss.gpuint.x1 - grey ) >> 1; // >> 1 to soften bumpmapping
......@@ -146,14 +173,10 @@ void TextureColorizer::colorize(ViewParams *viewParams)
// sqrt(dx^2 + dy^2) ~= 0.41 dx + 0.941246 +/- 3%
// cos(x) ~= 1-x^2
bendradius = bendReliefx * relief;
bump *= qRound( 1.0 - bendradius * bendradius );
bump &= 0x0f;
}
else
bump = 0;
*/
if ( *coastdata == landoffscreen )
*data = texturepalette[bump][grey + 0x100];
......
This diff is collapsed.
......@@ -79,7 +79,51 @@ int main(int argc, char *argv[])
}
painter.setBrush( gradient );
painter.drawRect( 0, 0, 256, 10 );
/*
int alpha;
if ( j < 8 ) alpha = j;
else alpha = 2 * (j - 7) + 7;
for ( int i = 0; i < 256; ++i) {
if ( filename == filelist[0] ) {
QRgb palcol = gradimg->pixel( i, 1 );
int red = qRed( palcol ) + 16 - alpha;
if ( red < 0 ) red = 0;
if ( red > 255 ) red = 255;
int green = qGreen( palcol ) + 16 - alpha;
if ( green < 0 ) green = 0;
if ( green > 255 ) green = 255;
int blue = qBlue( palcol ) + 16 - alpha;
if ( blue < 0 ) blue = 0;
if ( blue > 255 ) blue = 255;
palcol = qRgb( red, green, blue );
if ( i == 0 )
out << " { 0x" << (uint)palcol << "," << endl;
else
out << " 0x" << (uint)palcol << "," << endl;
}
else {
QRgb palcol = gradimg->pixel(i,1);
int red = qRed( palcol ) + 16 - alpha;
if ( red < 0 ) red = 0;
if ( red > 255 ) red = 255;
int green = qGreen( palcol ) + 16 - alpha;
if ( green < 0 ) green = 0;
if ( green > 255 ) green = 255;
int blue = qBlue( palcol ) + 16 - alpha;
if ( blue < 0 ) blue = 0;
if ( blue > 255 ) blue = 255;
palcol = qRgb( red, green, blue );
if ( i == 255 )
out << " 0x" << (uint)palcol << " }," << endl;
else
out << " 0x" << (uint)palcol << "," << endl;
// out << " " << (uint)gradimg->pixel(i,1) << "," << endl;
}
}
*/
int alpha = 2 * j;
for ( int i = 0; i < 256; ++i) {
......@@ -94,9 +138,9 @@ int main(int argc, char *argv[])
palcol = qRgb( red, green, blue );
if ( i == 0 )
out << " { 0x" << (uint)palcol << "," << endl;
out << " { 0x" << (uint)palcol << "," << endl;
else
out << " 0x" << (uint)palcol << "," << endl;
out << " 0x" << (uint)palcol << "," << endl;
}
else {
QRgb palcol = gradimg->pixel(i,1);
......@@ -109,10 +153,10 @@ int main(int argc, char *argv[])
palcol = qRgb( red, green, blue );
if ( i == 255 )
out << " 0x" << (uint)palcol << " }," << endl;
out << " 0x" << (uint)palcol << " }," << endl;
else
out << " 0x" << (uint)palcol << "," << endl;
// out << " " << (uint)gradimg->pixel(i,1) << "," << endl;
out << " 0x" << (uint)palcol << "," << endl;
// out << " " << (uint)gradimg->pixel(i,1) << "," << endl;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment