void FlowModel::reportParallel(){ QFuture<void> future = QtConcurrent::run(this,&FlowModel::reportIt);}
void FlowModel::reportIt(){//Генерация отчета QAxObject* WordApplication = new QAxObject("Word.Application"); if( WordApplication->isNull() ){ QMessageBox::warning(this,tr("Нету MS Word!"), tr("Внимание! На компьютере не установлен Microsoft Word или установлена версия Starter. Продолжение невозможно."), tr("Понял")); return; } QVector<QVector<QPointF>> points = mainWidget->getPoints(); double Qc = mainWidget->getQc(); QAxObject* WordDocuments = WordApplication->querySubObject("Documents()"); QAxObject* NewDocument = WordDocuments->querySubObject("Add()"); QAxObject* ActiveDocument = WordApplication->querySubObject("ActiveDocument()"); QAxObject* Range = ActiveDocument->querySubObject("Range()"); Range->querySubObject("Font")->setProperty("Size", 18); QString temp = tr("Моделирование процесса течения жидкости (%1)").arg(mainWidget->getMaterialName()) + "\n"; int range = temp.size(); Range->querySubObject("InsertAfter(QString)",temp); Range->querySubObject("InsertAfter(QString)",tr("\n")); Range = ActiveDocument->querySubObject("Range(QVariant&)", range); Range->querySubObject("Font")->setProperty("Size", 14); temp = tr("Длина %1 м").arg(mainWidget->lLine->text()) + "\n"; Range->querySubObject("InsertAfter(QString)",temp); range += temp.size(); temp = tr("Ширина %1 м").arg(mainWidget->wLine->text()) + "\n"; Range->querySubObject("InsertAfter(QString)",temp); range += temp.size(); temp = tr("Глубина %1 м").arg(mainWidget->dLine->text()) + "\n"; Range->querySubObject("InsertAfter(QString)",temp); range += temp.size(); temp = tr("Скорость верхней крышки %1 м\с").arg(mainWidget->sLine->text()) + "\n"; Range->querySubObject("InsertAfter(QString)",temp); range += temp.size(); temp = tr("Температура верхней крышки %1 С").arg(mainWidget->tLine->text()) + "\n"; Range->querySubObject("InsertAfter(QString)",temp); range += temp.size(); QAxObject* Tables = ActiveDocument->querySubObject("Tables()"); Range = ActiveDocument->querySubObject("Range(QVariant&)", range); QAxObject* Table = Tables->querySubObject("Add(Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior)", Range->asVariant(), points[0].size() + 1, 3, 1, 1); temp = "z (0 <= z <= L)"; QAxObject* Cell = Table->querySubObject("Cell(Row, Column)", 1, 1); QAxObject* CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", temp); range += temp.size(); delete CellRange; delete Cell; temp = "Температура"; Cell = Table->querySubObject("Cell(Row, Column)", 1,2); CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", "Температура"); range += temp.size(); delete CellRange; delete Cell; temp = "Вязкость"; Cell = Table->querySubObject("Cell(Row, Column)", 1,3); CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", "Вязкость"); range += temp.size(); delete CellRange; delete Cell; for(int i = 0; i < points[0].size(); i++){ temp = QString("%1").arg(points[0][i].x(),0,'f',1); Cell = Table->querySubObject("Cell(Row, Column)", i+2,1); CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", temp); range += temp.size(); temp = QString("%1").arg(points[0][i].y(),0,'f',2); delete CellRange; delete Cell; Cell = Table->querySubObject("Cell(Row, Column)", i+2,2); CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", temp); range += temp.size(); temp = QString("%1").arg(points[1][i].y(),0,'f',1); delete CellRange; delete Cell; Cell = Table->querySubObject("Cell(Row, Column)", i+2,3); CellRange = Cell->querySubObject("Range()"); CellRange->dynamicCall("InsertAfter(Text)", QString("%1").arg(points[1][i].y(),0,'f',1)); range += temp.size() + 4; delete CellRange; delete Cell; }Range->dynamicCall("InsertAfter(Text)","\n ");range += 5;QAxObject *newRange = ActiveDocument->querySubObject("Range(const QVariant&)", range);QAxObject *inlineShapes = newRange->querySubObject("InlineShapes()");table->saveTempPlots();QString lol = QCoreApplication::applicationFilePath() + "/temp1.png";lol.replace("/MainModule.exe","");inlineShapes->querySubObject("AddPicture(const QVariant&)", lol);temp = "Рис. 1 - Распределение температуры по длине канала\n\n";newRange->dynamicCall("InsertAfter(Text)",temp);range += temp.size() + 3;lol = QCoreApplication::applicationFilePath() + "/temp2.png";lol.replace("/MainModule.exe","");newRange = ActiveDocument->querySubObject("Range(const QVariant&)", range);inlineShapes = newRange->querySubObject("InlineShapes()");inlineShapes->querySubObject("AddPicture(const QVariant&)", lol);temp = "\nРис. 2 - Распределение вязкости по длине канала\n\n";newRange->dynamicCall("InsertAfter(Text)",temp);range += temp.size();newRange = ActiveDocument->querySubObject("Range(const QVariant&)", range);newRange->querySubObject("Font")->setProperty("Size",9);QDateTime curDate = QDateTime::currentDateTime();newRange->querySubObject("InsertAfter(QString)",QString(tr("Отчет был создан %1 в программе %2©")). arg(curDate.toString()).arg("Chemical View"));WordApplication->setProperty("Visible", true); delete newRange; delete inlineShapes; delete Range; delete Table; delete Tables; delete ActiveDocument; delete NewDocument; delete WordDocuments; delete WordApplication;}