|
From: <le...@us...> - 2007-01-24 14:37:45
|
Revision: 245
http://svn.sourceforge.net/qcell/?rev=245&view=rev
Author: lessm
Date: 2007-01-24 06:28:34 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
- Neighbourhood tab add
Modified Paths:
--------------
trunk/qcell/baseheaders/CalculationData.h
trunk/qcell/baseheaders/Neighbourhood.h
trunk/qcell/baseheaders/Renderer.h
trunk/qcell/baseheaders/simulationwindow.h
trunk/qcell/baseheaders/simulationwindow.ui
trunk/qcell/basesources/CalculationData.cpp
trunk/qcell/basesources/Calculator.cpp
trunk/qcell/basesources/Neighbourhood.cpp
trunk/qcell/basesources/Renderer.cpp
trunk/qcell/basesources/simulationwindow.cpp
trunk/qcell/visgui/MainWindow.cpp
Modified: trunk/qcell/baseheaders/CalculationData.h
===================================================================
--- trunk/qcell/baseheaders/CalculationData.h 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/baseheaders/CalculationData.h 2007-01-24 14:28:34 UTC (rev 245)
@@ -9,7 +9,6 @@
#include <QDomElement>
#include <QStringList>
#include "BaseDataTypes.h"
-#include "Neighbourhood.h"
class CalculationData : public baseDataTypes
{
@@ -86,7 +85,7 @@
CalculationData & operator = (CalculationData &cData);
- CalculationData & operator = (Neighbourhood &neighbourhood);
+ //CalculationData & operator = (Neighbourhood &neighbourhood);
signals:
void dataUpdated();
Modified: trunk/qcell/baseheaders/Neighbourhood.h
===================================================================
--- trunk/qcell/baseheaders/Neighbourhood.h 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/baseheaders/Neighbourhood.h 2007-01-24 14:28:34 UTC (rev 245)
@@ -5,6 +5,7 @@
#include <QVector>
#include <QDomElement>
#include <QDomDocument>
+#include "CalculationData.h"
#include "BaseDataTypes.h"
struct NContainer
@@ -17,6 +18,8 @@
bool bValue;
}value;
int offset;
+
+ //NContainer & operator = (NContainer &con);
};
@@ -68,6 +71,8 @@
QVector<int> getMaxNeighbourhoodValues(void);
QVector<int> getMinNeighbourhoodValues(void);
+ CalculationData toCalculationData(void);
+
};
#endif
Modified: trunk/qcell/baseheaders/Renderer.h
===================================================================
--- trunk/qcell/baseheaders/Renderer.h 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/baseheaders/Renderer.h 2007-01-24 14:28:34 UTC (rev 245)
@@ -72,6 +72,8 @@
QVector<int> maskValue;
+ bool showValues;
+
protected:
void initializeGL();
void paintGL();
@@ -145,6 +147,8 @@
QList< QVector<int> > getSelectData(void);
void maskSet(int x, int y, int z);
+ void showCellValues(bool show = 1);
+
protected slots:
void resizeDataEvent(void);
Modified: trunk/qcell/baseheaders/simulationwindow.h
===================================================================
--- trunk/qcell/baseheaders/simulationwindow.h 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/baseheaders/simulationwindow.h 2007-01-24 14:28:34 UTC (rev 245)
@@ -101,6 +101,8 @@
void localViewReinterprete(void);
int calculateDistans(int x, int y, int z, bool box=1);
+ Renderer *nRrenderer;
+
protected:
void update2DTable(bool forceUpdate=0);
void update2DGraph(void);
@@ -115,6 +117,7 @@
Renderer *getRenderer();
CalculationData *getStorage();
+ Renderer *getNeighbourhoodEditor(void);
protected slots:
void zPlaneChange(int i);
Modified: trunk/qcell/baseheaders/simulationwindow.ui
===================================================================
--- trunk/qcell/baseheaders/simulationwindow.ui 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/baseheaders/simulationwindow.ui 2007-01-24 14:28:34 UTC (rev 245)
@@ -36,7 +36,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" >
- <number>0</number>
+ <number>6</number>
</property>
<widget class="QWidget" name="view3D" >
<attribute name="title" >
@@ -116,6 +116,11 @@
<string>Function</string>
</attribute>
</widget>
+ <widget class="QWidget" name="NeighbourhoodTab" >
+ <attribute name="title" >
+ <string>Neighbourhood</string>
+ </attribute>
+ </widget>
</widget>
</item>
</layout>
Modified: trunk/qcell/basesources/CalculationData.cpp
===================================================================
--- trunk/qcell/basesources/CalculationData.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/basesources/CalculationData.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -953,7 +953,7 @@
fillData(cData.getDataPointer());
return *this;
}
-
+/*
CalculationData & CalculationData::operator = (Neighbourhood &neighbourhood)
{
clearData();
@@ -966,3 +966,4 @@
return *this;
}
+*/
\ No newline at end of file
Modified: trunk/qcell/basesources/Calculator.cpp
===================================================================
--- trunk/qcell/basesources/Calculator.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/basesources/Calculator.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -252,28 +252,27 @@
if(st==0)
st=1;
- if(!wasFreezed)
- copyData();
+ copyData();
- for(int t=startT;t<st;t++)
+ for(int t=0;t<st;t++)
{
if (dimension == 4)
{
coordinates[3] = t;
}
- for(int z=startZ;z<sz;z++)
+ for(int z=0;z<sz;z++)
{
if (dimension >= 3)
{
coordinates[2] = z;
}
- for(int y=startY;y<sy;y++)
+ for(int y=0;y<sy;y++)
{
if (dimension >= 2)
{
coordinates[1] = y;
}
- for(int x=startX;x<sx;x++)
+ for(int x=0;x<sx;x++)
{
coordinates[0] = x;
neighbourhood->resolveValues(tempData + (x - minBorder[0]) + ((y - minBorder[1]) * tempDataSize[0]) + (z - minBorder[2]) * (tempDataSize[0] * tempDataSize[1]) + (t - minBorder[3]) * (tempDataSize[0] * tempDataSize[1] * tempDataSize[2]) * dataSize);
@@ -295,12 +294,10 @@
if(*((int *)temp)<0)
{
/// @todo k\xD3Zka
- //startX = x;
- //startY = y;
- //startZ = z;
- //startT = t;
- wasFreezed = 1;
- //storedCounter = counter;
+ startX = x;
+ startY = y;
+ startZ = z;
+ startT = t;
functionIndex = localfunction->lastUnknownValueIndex();
return 0;
}
@@ -312,9 +309,6 @@
}
}
}
- storedCounter = 0;
- startT = startZ = startY = startX = 0;
- wasFreezed = 0;
memcpy(data, calcBuffer, getSizeInByte());
return 1;
}
Modified: trunk/qcell/basesources/Neighbourhood.cpp
===================================================================
--- trunk/qcell/basesources/Neighbourhood.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/basesources/Neighbourhood.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -1,5 +1,16 @@
#include "../baseheaders/Neighbourhood.h"
-
+/*
+NContainer & NContainer::operator =(NContainer &con)
+{
+ x = con.x;
+ y = con.y;
+ z = con.z;
+ t = con.t;
+ value = con.value;
+ offset = con.offset;
+ return *this;
+}
+*/
Neighbourhood::Neighbourhood()
{
dimension = 666;
@@ -472,3 +483,51 @@
{
return minValues;
}
+
+CalculationData Neighbourhood::toCalculationData(void)
+{
+ CalculationData out;
+ QVector<int> minv, maxv;
+
+ minv = getMinNeighbourhoodValues();
+ maxv = getMaxNeighbourhoodValues();
+
+ QVector<NContainer> ng = getNeighbours();
+
+ int sx = maxv[0] - minv[0], sy = maxv[1] - minv[1], sz = maxv[2] - minv[2];
+ if(minv[0]<0)
+ sx++;
+ if(minv[1]<0)
+ sy++;
+ if(minv[2]<0)
+ sz++;
+
+ switch(getDimension())
+ {
+ case 1:
+ out.resizeData(sx);
+ out.fillData(0);
+ for(int i=0;i<ng.size();++i)
+ {
+ out.setValueAt(i+1, ng[i].x - minv[0]);
+ }
+ break;
+ case 2:
+ out.resizeData(sx, sy);
+ out.fillData(0);
+ for(int i=0;i<ng.size();++i)
+ {
+ out.setValueAt(i+1, ng[i].x - minv[0], ng[i].y - minv[1]);
+ }
+ break;
+ case 3:
+ out.resizeData(sx, sy, sz);
+ out.fillData(0);
+ for(int i=0;i<ng.size();++i)
+ {
+ out.setValueAt(i+1, ng[i].x - minv[0], ng[i].y - minv[1], ng[i].z - minv[2]);
+ }
+ break;
+ }
+ return out;
+}
Modified: trunk/qcell/basesources/Renderer.cpp
===================================================================
--- trunk/qcell/basesources/Renderer.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/basesources/Renderer.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -317,7 +317,8 @@
if(workMode==1)
getStorage()->setValueAt(editValue, selectetObjects[0]);
QVector<int> sCoord = getSelectedCoord();
- emit objectSelected(sCoord[0], sCoord[1], sCoord[2]);
+ if(sCoord.size()>0)
+ emit objectSelected(sCoord[0], sCoord[1], sCoord[2]);
}
}
@@ -402,15 +403,18 @@
QVector<int> out;
out.resize(3);
- out[0] = index % getStorage()->getSizeX();
+ int sx = getStorage()->getSizeX();
+ int sy = getStorage()->getSizeY()==0 ? 1 : getStorage()->getSizeY();
+
+ out[0] = index % sx;
index /= getStorage()->getSizeX();
- if(index<getStorage()->getSizeY())
+ if(index<sy)
{
out[1] = index;
return out;
}
- out[1] = index % getStorage()->getSizeY();
- index /= getStorage()->getSizeY();
+ out[1] = index % sy;
+ index /= sy;
out[2] = index;
return out;
@@ -454,6 +458,7 @@
maskValue.resize(3);
maskValue[0] = maskValue[1] = maskValue[2] = -1;
+ showValues = 0;
}
Renderer::~Renderer()
@@ -495,7 +500,7 @@
minValIndex = selectBuffer[i + 3];
}
}
- if(minValIndex!=1)
+ if(minValIndex!=-1)
{
selectetObjects<<minValIndex;
updateGL();
@@ -678,6 +683,7 @@
int counter = 0, index;
bool selectTest;
float mx = -(float)storage.getSizeX(), my = -(float)storage.getSizeY(), mz = -(float)storage.getSizeZ();
+ makeCurrent();
if(renderGreed)
{
glDisable(GL_LIGHTING);
@@ -686,7 +692,13 @@
}
SYMBOL symbol;
- for(int z=0;z<storage.getSizeZ();++z)
+ int sx = storage.getSizeX();
+ int sy = storage.getSizeY()==0 ? 1 : storage.getSizeY();
+ int sz = storage.getSizeZ()==0 ? 1 : storage.getSizeZ();
+
+
+
+ for(int z=0;z<sz;++z)
{
if(maskValue[2]>-1)
if(maskValue[2]!=z)
@@ -694,7 +706,7 @@
counter += storage.getSizeY() * storage.getSizeX();
continue;
}
- for(int y=storage.getSizeY();y>0;--y)
+ for(int y=sy;y>0;--y)
{
if(maskValue[1]>-1)
if(maskValue[1]!=storage.getSizeY() - y)
@@ -702,7 +714,7 @@
counter += storage.getSizeY();
continue;
}
- for(int x=0;x<storage.getSizeX();++x)
+ for(int x=0;x<sx;++x)
{
if(maskValue[0]>-1)
if(maskValue[0]!=x)
@@ -776,24 +788,47 @@
}
}
}
- if(showLocalObserver && !selectionMode)
+ if(!selectionMode)
{
+ if(showLocalObserver)
+ {
- glPushMatrix();
- glTranslatef(mx + (float)localObserverCoords[0] * 2.0f , my + (storage.getSizeY() - (float)localObserverCoords[1]) * 2.0f, mz + (float)localObserverCoords[2] * 2.0f);
- glRotatef(rotation[2], 0.0f, 0.0f, -1.0f);
- glRotatef(rotation[1], 0.0f, -1.0f, 0.0f);
- glRotatef(rotation[0], -1.0f, 0.0f, 0.0f);
+ glPushMatrix();
+ glTranslatef(mx + (float)localObserverCoords[0] * 2.0f , my + (storage.getSizeY() - (float)localObserverCoords[1]) * 2.0f, mz + (float)localObserverCoords[2] * 2.0f);
+ glRotatef(rotation[2], 0.0f, 0.0f, -1.0f);
+ glRotatef(rotation[1], 0.0f, -1.0f, 0.0f);
+ glRotatef(rotation[0], -1.0f, 0.0f, 0.0f);
- glBlendFunc(GL_ONE, GL_ONE);
- glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE);
+ glEnable(GL_BLEND);
+ glDisable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
+ glCallList(observer);
+ glDisable(GL_TEXTURE_2D);
+ glEnable(GL_LIGHTING);
+ glDisable(GL_BLEND);
+ glPopMatrix();
+ }
+ if(showValues)
+ {
glDisable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
- glCallList(observer);
- glDisable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST);
+ QFont font("Curier New");
+ font.setStyleHint(QFont::AnyStyle, QFont::PreferBitmap);
+
+ for(int z=0;z<sz;++z)
+ {
+ for(int y=sy;y>0;--y)
+ {
+ for(int x=0;x<sx;++x)
+ {
+ renderText(mx + (float)x * 2.0f , my + (float)y * 2.0f, mz + (float)z * 2.0f, tr("%1").arg(storage.getValueAt_i(x, y-1, z)), font);
+ }
+ }
+ }
glEnable(GL_LIGHTING);
- glDisable(GL_BLEND);
- glPopMatrix();
+ glEnable(GL_DEPTH_TEST);
+ }
}
}
@@ -984,6 +1019,11 @@
maskValue[2] = z;
}
+void Renderer::showCellValues(bool show)
+{
+ showValues = show;
+}
+
void Renderer::setOrtoPerspective(bool noClear)
{
float aspect = (float)width()/(float)height();
Modified: trunk/qcell/basesources/simulationwindow.cpp
===================================================================
--- trunk/qcell/basesources/simulationwindow.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/basesources/simulationwindow.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -107,6 +107,8 @@
// view1DTextTools->move(width() - 116, basetools->height() + 1);
// ft->resize(ui.functionTab->width() - 10 , ui.functionTab->height() - 10);
+
+// nRrenderer->resize(ui.NeighbourhoodTab->width(), ui.NeighbourhoodTab->height());
}
void simulationWindow::paintEvent(QPaintEvent * event)
@@ -719,6 +721,11 @@
ui.functionTab->setLayout(new QVBoxLayout(ui.functionTab));
ft = new FunctionTable(ui.functionTab);
ui.functionTab->layout()->addWidget(ft);
+
+ ui.NeighbourhoodTab->setLayout(new QVBoxLayout(ui.NeighbourhoodTab));
+ nRrenderer = new Renderer(ui.NeighbourhoodTab);
+ ui.NeighbourhoodTab->layout()->addWidget(nRrenderer);
+ nRrenderer->showCellValues();
}
simulationWindow::~simulationWindow()
@@ -743,6 +750,11 @@
return renderer->getStorage();
}
+Renderer *simulationWindow::getNeighbourhoodEditor(void)
+{
+ return nRrenderer;
+}
+
void simulationWindow::zPlaneChange(int i)
{
z_plane = i;
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-24 13:47:27 UTC (rev 244)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-24 14:28:34 UTC (rev 245)
@@ -438,6 +438,11 @@
return;
}
+ //***************************************************
+ *sw->getNeighbourhoodEditor()->getStorage() = neighbourhood->toCalculationData();
+ sw->getNeighbourhoodEditor()->setTranslation(0.0f, 0.0f, -10.0f);
+ sw->getNeighbourhoodEditor()->setSymbolColor(1, QColor(128, 128, 128));
+ //***************************************************
calc.setNeighbourhood(neighbourhood);
// Enable saving menu for Neighbourhood
@@ -701,7 +706,7 @@
{
sw->setSelectedCell(calc.freezedCoords());
sw->setSelectedFunctionRule(calc.getUnknowFunctionRuleIndex());
- //iteration--;
+ iteration--;
}
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|