From: <le...@us...> - 2007-01-21 23:36:02
|
Revision: 228 http://svn.sourceforge.net/qcell/?rev=228&view=rev Author: lessm Date: 2007-01-21 15:35:58 -0800 (Sun, 21 Jan 2007) Log Message: ----------- - local function is editable - k?\195?\147zka work for 1D and 2D(3D not tested) Modified Paths: -------------- trunk/qcell/baseheaders/Calculator.h trunk/qcell/baseheaders/LocalFunction.h trunk/qcell/baseheaders/Renderer.h trunk/qcell/baseheaders/functiontable.h trunk/qcell/baseheaders/functiontable.ui trunk/qcell/baseheaders/simulationwindow.h trunk/qcell/baseheaders/simulationwindow.ui trunk/qcell/basesources/Calculator.cpp trunk/qcell/basesources/LocalFunction.cpp trunk/qcell/basesources/Renderer.cpp trunk/qcell/basesources/functiontable.cpp trunk/qcell/basesources/simulationwindow.cpp trunk/qcell/visgui/MainWindow.cpp Modified: trunk/qcell/baseheaders/Calculator.h =================================================================== --- trunk/qcell/baseheaders/Calculator.h 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/Calculator.h 2007-01-21 23:35:58 UTC (rev 228) @@ -22,7 +22,7 @@ private: protected: - char *tempData; + char *tempData, *calcBuffer; bool haveForeignOutputDataPointer; QVector<int> tempDataSize, calculationSpaceStart, calculationSpaceEnd; Neighbourhood *neighbourhood; @@ -33,16 +33,18 @@ BORDER borderType; - // kuska + // k\xD3Zka int startX, startY, startZ, startT; int storedCounter; + bool wasFreezed; + int functionIndex; protected: void clearTempData(void); void copyData(void); bool resizeTempDataBuffer(bool dataCopy=0, char *dataPointer=NULL); void updateBorder(void); - // for kozka + // for k\xD3Zka void storeSetings(void); //************************************************* public: @@ -54,11 +56,13 @@ void setLocalFunction(LocalFunction *f); int getTempDataSizeInByte(void); + + bool calculate(void); - // for kozka - void calculate(void); + // for k\xD3Zka bool isFreezed(void); - void resumeCalculation(void); + QVector<int> freezedCoords(void); + int getUnknowFunctionRuleIndex(void); // ************************************************ Calculator & operator = (CalculationData &cData); Modified: trunk/qcell/baseheaders/LocalFunction.h =================================================================== --- trunk/qcell/baseheaders/LocalFunction.h 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/LocalFunction.h 2007-01-21 23:35:58 UTC (rev 228) @@ -72,6 +72,7 @@ int numArg, maxArgVal, numElements, maxRetVal; QString script, coment; + int unknowValueIndex; protected: //public: @@ -99,6 +100,8 @@ QVector<int> indexToFreeArgs(int index); QVector<int> indexToSums(int index); + + public: LocalFunction(); @@ -158,6 +161,9 @@ void setComent(QString &text); QString getComent(void); + //k\xD3zka + int lastUnknownValueIndex(void); + signals: // signal emit when resolv used void valueCalculate(QVector<int> args); Modified: trunk/qcell/baseheaders/Renderer.h =================================================================== --- trunk/qcell/baseheaders/Renderer.h 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/Renderer.h 2007-01-21 23:35:58 UTC (rev 228) @@ -140,6 +140,8 @@ void showObserver(bool flag); void setObserverPosition(int x, int y, int z); + void selectCell(int x, int y, int z); + QList< QVector<int> > getSelectData(void); void maskSet(int x, int y, int z); Modified: trunk/qcell/baseheaders/functiontable.h =================================================================== --- trunk/qcell/baseheaders/functiontable.h 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/functiontable.h 2007-01-21 23:35:58 UTC (rev 228) @@ -26,6 +26,7 @@ ~FunctionTable(); void setFunctionPointer(LocalFunction *f); + void selectCell(int index); protected slots: void functionEdit(int row, int column); Modified: trunk/qcell/baseheaders/functiontable.ui =================================================================== --- trunk/qcell/baseheaders/functiontable.ui 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/functiontable.ui 2007-01-21 23:35:58 UTC (rev 228) @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>491</width> + <height>376</height> </rect> </property> <property name="windowTitle" > Modified: trunk/qcell/baseheaders/simulationwindow.h =================================================================== --- trunk/qcell/baseheaders/simulationwindow.h 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/simulationwindow.h 2007-01-21 23:35:58 UTC (rev 228) @@ -138,6 +138,8 @@ //for test only FunctionTable * getFunctionTable(void); + void setSelectedCell(QVector<int> coord); + void setSelectedFunctionRule(int index); }; #endif // SIMULATIONWINDOW_H Modified: trunk/qcell/baseheaders/simulationwindow.ui =================================================================== --- trunk/qcell/baseheaders/simulationwindow.ui 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/baseheaders/simulationwindow.ui 2007-01-21 23:35:58 UTC (rev 228) @@ -36,7 +36,7 @@ <enum>QTabWidget::Rounded</enum> </property> <property name="currentIndex" > - <number>5</number> + <number>4</number> </property> <widget class="QWidget" name="view3D" > <attribute name="title" > Modified: trunk/qcell/basesources/Calculator.cpp =================================================================== --- trunk/qcell/basesources/Calculator.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/basesources/Calculator.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -130,6 +130,9 @@ startX = startY = startZ = startT = 0; storedCounter = 0; + wasFreezed = 0; + functionIndex = -1; + calcBuffer = NULL; } Calculator::~Calculator() @@ -138,6 +141,8 @@ haveForeignOutputDataPointer = 0; neighbourhood = NULL; localfunction = NULL; + if(calcBuffer) + delete calcBuffer; } void Calculator::setNeighbourhood(Neighbourhood *n) @@ -228,9 +233,9 @@ return 0; } -void Calculator::calculate(void) +bool Calculator::calculate(void) { - int counter = 0; + int counter = storedCounter; char temp[8] = {0,0,0,0,0,0,0,0}; int sx = sizeX, sy = sizeY, sz = sizeZ, st = sizeT; QVector<int> coordinates(dimension, 0); @@ -244,11 +249,12 @@ if(st==0) st=1; - copyData(); + if(!wasFreezed) + copyData(); for(int t=startT;t<st;++t) { - if (dimension = 4) + if (dimension == 4) { coordinates[3] = t; } @@ -286,27 +292,47 @@ if(*((int *)temp)<0) { /// @todo k\xD3Zka - return; + startX = x; + startY = y; + startZ = z; + startT = t; + wasFreezed = 1; + storedCounter = counter; + functionIndex = localfunction->lastUnknownValueIndex(); + return 0; } emit calculated(coordinates, neighbourhood->valuesToVector_i(), (int)*temp); - memcpy(data + counter, temp, dataSize); + //memcpy(data + counter, temp, dataSize); + memcpy(calcBuffer + counter, temp, dataSize); counter += dataSize; } } } } - + storedCounter = 0; + startT = startZ = startY = startX = 0; + wasFreezed = 0; + memcpy(data, calcBuffer, getSizeInByte()); + return 1; } bool Calculator::isFreezed(void) { - return 0; + return wasFreezed; } -void Calculator::resumeCalculation(void) +QVector<int> Calculator::freezedCoords(void) { + QVector<int> out; + out<<startX<<startY<<startZ<<startT; + return out; } +int Calculator::getUnknowFunctionRuleIndex(void) +{ + return functionIndex; +} + Calculator & Calculator::operator = (CalculationData &cData) { if(cData.getDimension()!=getDimension() || cData.getSizeX() != getSizeX() || cData.getSizeY() != getSizeY() || cData.getSizeZ() != getSizeZ() || cData.getSizeT() != getSizeT()) @@ -336,6 +362,7 @@ void Calculator::setupSpace(void) { + if(neighbourhood) { minBorder = neighbourhood->getMinNeighbourhoodValues(); @@ -355,6 +382,15 @@ tempDataSize[3] = -minBorder[3] + maxBorder[3] + sizeT; resizeTempDataBuffer(); neighbourhood->calculateOffsets(tempDataSize[0], tempDataSize[1], tempDataSize[2], tempDataSize[3], getDataType()); + } - } + // 2nd buffer + + if(calcBuffer) + delete calcBuffer; + calcBuffer = new char[getSizeInByte()]; + + storedCounter = 0; + startT = startZ = startY = startX = 0; + wasFreezed = 0; } Modified: trunk/qcell/basesources/LocalFunction.cpp =================================================================== --- trunk/qcell/basesources/LocalFunction.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/basesources/LocalFunction.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -326,6 +326,7 @@ LocalFunction::LocalFunction() { functionMode = LocalFunction::SWITCH; + unknowValueIndex = -1; } LocalFunction::~LocalFunction() @@ -588,6 +589,7 @@ // for kuska if(valueTable[index]<0) emit unknownValue(index); + unknowValueIndex = index; //*********************** return valueTable[index]; @@ -786,4 +788,9 @@ QString LocalFunction::getComent(void) { return coment; -} \ No newline at end of file +} + +int LocalFunction::lastUnknownValueIndex(void) +{ + return unknowValueIndex; +} Modified: trunk/qcell/basesources/Renderer.cpp =================================================================== --- trunk/qcell/basesources/Renderer.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/basesources/Renderer.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -1046,6 +1046,12 @@ localObserverCoords[2] = z; } +void Renderer::selectCell(int x, int y, int z) +{ + selectetObjects.clear(); + selectetObjects<<(x + y * storage.getSizeX() + z * storage.getSizeX() * storage.getSizeY()); +} + QList< QVector<int> > Renderer::getSelectData(void) { int index; Modified: trunk/qcell/basesources/functiontable.cpp =================================================================== --- trunk/qcell/basesources/functiontable.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/basesources/functiontable.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -15,7 +15,14 @@ for(int j=0;j<ui.functionTable->columnCount();++j) { item = new QTableWidgetItem; - item->setText(tr("%1").arg(function->getValueAt(counter))); + if(function->getValueAt(counter)<0) + { + item->setText("?"); + } + else + { + item->setText(tr("%1").arg(function->getValueAt(counter))); + } item->setTextAlignment(Qt::AlignCenter); ui.functionTable->setItem(i, j, item); ++counter; @@ -47,12 +54,43 @@ init(); } +void FunctionTable::selectCell(int index) +{ + int counter = 0; + QTableWidgetItem *item; + for(int i=0;i<ui.functionTable->rowCount();++i) + { + for(int j=0;j<ui.functionTable->columnCount();++j) + { + item = ui.functionTable->item(i, j); + if(counter==index) + item->setSelected(1); + else + item->setSelected(0); + counter++; + } + } +} + void FunctionTable::functionEdit(int row, int column) { QString temp; QTableWidgetItem *item; item = ui.functionTable->item(row, column); - temp.setNum(item->text().toInt()); - item->setText(temp); - function->setValueAt(temp.toInt(), row * ui.functionTable->columnCount() + column); + if(item->text()=="?") + function->setValueAt(-1, row * ui.functionTable->columnCount() + column); + else + { + temp.setNum(item->text().toInt()); + if(temp.toInt()<0) + { + function->setValueAt(-1, row * ui.functionTable->columnCount() + column); + item->setText("?"); + } + else + { + item->setText(temp); + function->setValueAt(temp.toInt(), row * ui.functionTable->columnCount() + column); + } + } } Modified: trunk/qcell/basesources/simulationwindow.cpp =================================================================== --- trunk/qcell/basesources/simulationwindow.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/basesources/simulationwindow.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -104,6 +104,8 @@ view3DTools->move(width() - 116, basetools->height() + 1); view2DTextTools->move(width() - 116, basetools->height() + 1); view1DTextTools->move(width() - 116, basetools->height() + 1); + + ft->resize(ui.functionTab->width() - 10 , ui.functionTab->height() - 10); } void simulationWindow::paintEvent(QPaintEvent * event) @@ -1328,3 +1330,44 @@ { return ft; } + + +void simulationWindow::setSelectedCell(QVector<int> coord) +{ + QTableWidgetItem *item; + switch(getStorage()->getDimension()) + { + case 1: + + for(int i=0;i<table1D->columnCount();++i) + { + item = table1D->item(0, i); + if(i==coord[0]) + item->setSelected(1); + else + item->setSelected(0); + } + break; + case 3: + renderer->selectCell(coord[0], coord[1], coord[2]); + case 2: + for(int i=0;i<table2D->rowCount();++i) + { + for(int j=0;j<table2D->columnCount();++j) + { + item = table2D->item(i, j); + if(i==coord[1] && j==coord[0] && z_plane==coord[2]) + item->setSelected(1); + else + item->setSelected(0); + } + } + break; + } +} + +void simulationWindow::setSelectedFunctionRule(int index) +{ + ft->selectCell(index); + ui.tabWidget->setCurrentIndex(5); +} Modified: trunk/qcell/visgui/MainWindow.cpp =================================================================== --- trunk/qcell/visgui/MainWindow.cpp 2007-01-21 19:45:41 UTC (rev 227) +++ trunk/qcell/visgui/MainWindow.cpp 2007-01-21 23:35:58 UTC (rev 228) @@ -526,10 +526,17 @@ { /// @todo Use the updated API of Calculator /// @todo Pass the calculated CalculationData to the data list - calc.calculate(); - CalculationData *temp = new CalculationData; - *temp = calc; - data<<temp; + if(calc.calculate()) + { + CalculationData *temp = new CalculationData; + *temp = calc; + data<<temp; + } + else + { + sw->setSelectedCell(calc.freezedCoords()); + sw->setSelectedFunctionRule(calc.getUnknowFunctionRuleIndex()); + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |