void MainWindow::on_actionQueue2_triggered() { if(getRoot() == NULL) { QErrorMessage err; err.showMessage("Root does not exits"); err.exec(); return; } space * wp = (space*)getRoot(); if(wp->sublvl == NULL) { QErrorMessage err; err.showMessage("Stars does not exits"); err.exec(); return; } star ** st = (star**)wp->sublvl; int count_star = wp->sublvl_count; star * max = st[0]; QString result = "Biggest star:"; for(int i = 1;i < count_star;i++) { if(st[i]->sublvl_count > max->sublvl_count) { max = st[i]; }else if(st[i]->sublvl_count == max->sublvl_count){ if(st[i]->mass > max->mass){ max = st[i]; } } } result += " " + QString::fromStdString(max->name); QMessageBox::about(this,"Found data",result); }
void CParticleSystemPage::setPresetBehaviour(int index) { updateLifeMgtPresets(); if (index == _Node->getPSPointer()->getBehaviourType()) return; if (index == NL3D::CParticleSystem::SpellFX || index == NL3D::CParticleSystem::SpawnedEnvironmentFX) { NL3D::CPSLocatedBindable *lb; if (!_Node->getPSPointer()->canFinish(&lb)) { _ui.presetBehaviourComboBox->setCurrentIndex(_Node->getPSPointer()->getBehaviourType()); QErrorMessage *errorMessage = new QErrorMessage(); errorMessage->setModal(true); if (!lb) { errorMessage->showMessage(tr("Can't perform operation : the system is flagged with 'No max nb steps' or uses the preset 'Spell FX', " "and thus, should have a finite duration. Please remove that flag first.")); errorMessage->exec(); } else { errorMessage->showMessage(tr("The system must have a finite duration for this setting! Please check that the following object " "doesn't live forever or doesn't create a loop in the system :") + QString(lb->getName().c_str())); errorMessage->exec(); } delete errorMessage; return; } } _Node->getPSPointer()->activatePresetBehaviour((NL3D::CParticleSystem::TPresetBehaviour) index); updateLifeMgtPresets(); updateModifiedFlag(); }
//Function (slot) to read vtk image data void Application::openvtkclicked() { QString temp = QFileDialog::getOpenFileName(this, tr("Open VTK Data File"),"",tr("VTK Data (*.vtk)")); QFile data(temp); QString line; QTextStream in(&data); in.setCodec("UTF-8"); if (data.open(QFile::ReadOnly)) { line = in.readLine(); if(line.contains("vtk") == true) { do { line = in.readLine(); if(line.contains("DATASET") == true) { //call for slicers if(line.contains("STRUCTURED_POINTS") == true)//if dataset is compatible { dataset = line; currentfile = temp; viewstructuredpointslices(); //calls this function to display slices along axes showisotog(); //generates isosurface in case, isosurfacing is true Enableall(); } else { setStatusTip("Unsupported or Invalid Dataset!!"); QErrorMessage errmsg; errmsg.showMessage(tr("Unsupported or Invalid Dataset!!")); errmsg.setWindowIcon(QIcon(":/ICONS/Head.jpg")); errmsg.exec(); } break; } } while (!line.isNull()); } else { this->setStatusTip("Invalid VTK file or file corrupt!!"); QErrorMessage errmsg; errmsg.showMessage(tr("Invalid VTK file or file corrupt!!")); errmsg.setWindowIcon(QIcon(":/ICONS/Head.jpg")); errmsg.exec(); } data.close(); } else this->setStatusTip("File Opening Failed!!"); }
void MainWindow::volumeReconstruction() { std::cout<<"VOLUME RECONSTRUCTION"<<std::endl<<std::endl; if (!displayWidget->getVolumeImageStack().empty()) { VolumeReconstructionWidget * volumeReconstruction = new VolumeReconstructionWidget(); if (displayWidget->isVolumeImageStackLoaded){ volumeReconstruction->setVolumeImageStack(displayWidget->getVolumeImageStack()); volumeReconstruction->setTransformStack(displayWidget->getTransformStack()); } volumeReconstruction->setMainWindow(this); volumeReconstruction->show(); } else { QErrorMessage errorMessage; errorMessage.showMessage( "No volume data loaded, </ br> please data before reconstruct the volume"); errorMessage.exec(); } }
void MainWindow::checkCalibrationError() { std::cout<<"Check Calibration Error"<<std::endl<<std::endl; if (!displayWidget->getImageStack().empty()) { CheckCalibrationErrorWidget* checkCalibrationWidget = new CheckCalibrationErrorWidget(); if (displayWidget->isImageStackLoaded) checkCalibrationWidget->setImageStack(displayWidget->getImageStack()); else checkCalibrationWidget->setImage(displayWidget->getImageViewer()->GetInput()); displayWidget->setCalibrationErrorWidget(checkCalibrationWidget); displayWidget->setProbeFlag(false); displayWidget->startTracer(); checkCalibrationWidget->setMainWindow(this); checkCalibrationWidget->show(); } else { QErrorMessage errorMessage; errorMessage.showMessage( "No images loaded, </ br> please load an images before checking the calibration"); errorMessage.exec(); } }
void MainWindow::probeCalibration() { std::cout<<"Probe Calibration"<<std::endl; if (!displayWidget->getImageStack().empty()) { ProbeCalibrationWidget* probeCalibration = new ProbeCalibrationWidget(); if (displayWidget->isImageStackLoaded) probeCalibration->setImageStack(displayWidget->getImageStack()); else probeCalibration->setImage(displayWidget->getImageViewer()->GetInput()); displayWidget->setProbeFlag(true); // get left mouse pressed with high priority Connections->Connect(displayWidget->getQVTKWidget()->GetRenderWindow()->GetInteractor(), vtkCommand::LeftButtonPressEvent, probeCalibration, SLOT(getCoordinates())); probeCalibration->setMainWindow(this); probeCalibration->show(); } else { QErrorMessage errorMessage; errorMessage.showMessage( "No images loaded, </ br> please load an images before calibrate the probe"); errorMessage.exec(); } }
void cChatsView::chatroom_status(QString id, bool status, QString reason) { qDebug() << "[INFO]cChatsView::chatroom_status-> id:" << id << "status" << status; if (status) { for(int i = 0 ; i < m_chats.count() ; i++) {//Si ya le hemos creado no hacemos nada if (m_chats[i]->get_chatId() ==id) { qDebug() << "[INFO]cChatsView::chatroom_status-> ya le he creado!:" << m_chats[i]->get_chatId() << "/" << id; return; } } cChatView* chat = new cChatView(m_pClient,id,id,this); m_chats.append(chat); ui->tabWidget->addTab(chat,id); } else { QErrorMessage errorMessage; QString msg("No se ha podido conectar al chat:"); msg.append(id); msg.append(" Reason:"); msg.append(reason); errorMessage.showMessage(msg); errorMessage.exec(); } }
void ImageWidget::openWithVTK() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath()); if (!fileName.isEmpty()) { /* // This code is currently not used because the file is read with vtkImageReader2 // Obtain image information this->setImageProperties(fileName.toAscii().data(), true); // set itk image depending on the image type // if image type is grayscale if (imageType.compare("scalar") == 0) { // read the image typedef itk::ImageFileReader <ImageType> ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(fileName.toAscii().data()); reader->Update(); // set the image data provided by the reader itkImage = reader->GetOutput(); } else { // if the image is RGB typedef itk::ImageFileReader <RGBImageType> ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(fileName.toAscii().data()); reader->Update(); // set the image data provided by the reader rgbItkImage = reader->GetOutput(); } */ // reads a vtkImage for display purposes vtkSmartPointer <vtkImageReader2Factory> readerFactory = vtkSmartPointer <vtkImageReader2Factory>::New(); vtkSmartPointer <vtkImageReader2> reader = readerFactory->CreateImageReader2(fileName.toAscii().data()); reader->SetFileName(fileName.toAscii().data()); reader->Update(); vtkImage = reader->GetOutput(); this->isFlipped = true; this->displayImage(vtkImage); readerFactory = NULL; reader = NULL; } else { QErrorMessage errorMessage; errorMessage.showMessage("No file specified for loading"); errorMessage.exec(); return; } }
void JobEditorWindow::open() { try { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Job"), "", tr("Job (*.job)")); if ( fileName != NULL ) { openJob(rsString(fileName.toUtf8().data())); } } catch (const exception& e) { QErrorMessage errorMessage; errorMessage.showMessage(e.what()); errorMessage.exec(); } catch (...) { QErrorMessage errorMessage; errorMessage.showMessage("Unknown error while opening the job file"); errorMessage.exec(); } }
void SendEmail::errorMessage(const QString &message) { QErrorMessage err (this); err.showMessage(message); err.exec(); }
JobEditorWindow::JobEditorWindow(QMainWindow *parent) : QMainWindow(parent) { ui.setupUi(this); ui.pipelineWidget->removePage(0); try { createActions(); createMenus(); } catch (const exception& e) { QErrorMessage errorMessage; errorMessage.showMessage(e.what()); errorMessage.exec(); } catch (...) { QErrorMessage errorMessage; errorMessage.showMessage("Unknown error while intializing the application"); errorMessage.exec(); } currentJobPath = NULL; currentJob = NULL; }
void CParticleSystemPage::setNoMaxNBSteps(bool state) { _ui.maxStepsWidget->setEnabled(!state); if (state == _Node->getPSPointer()->getBypassMaxNumIntegrationSteps()) return; if (state && !_Node->getPSPointer()->canFinish()) { QErrorMessage *errorMessage = new QErrorMessage(); errorMessage->setModal(true); errorMessage->showMessage(tr("The system must have a finite duration for this setting! Please check that.")); errorMessage->exec(); delete errorMessage; _ui.maxStepsWidget->setEnabled(state); _ui.noMaxNBStepsCheckBox->setChecked(!state); return; } _Node->getPSPointer()->setBypassMaxNumIntegrationSteps(state); updateModifiedFlag(); }
/** * Starts the logging thread to a certain file */ void LoggingPlugin::startLogging(QString file) { qDebug() << "Logging to " << file; // We have to delete the previous logging thread if is was still there! if (loggingThread) delete loggingThread; loggingThread = new LoggingThread(); if(loggingThread->openFile(file,this)) { connect(loggingThread,SIGNAL(finished()),this,SLOT(loggingStopped())); state = LOGGING; loggingThread->start(); emit stateChanged("LOGGING"); } else { QErrorMessage err; err.showMessage("Unable to open file for logging"); err.exec(); } }
void MainWindow::on_actionSave_2_triggered() { if(getRoot() == NULL) { QErrorMessage error_mes; error_mes.showMessage("Node was not create"); error_mes.exec(); return; } FILE * f = fopen("STANDART.txt","wb"); if(f == NULL) { QErrorMessage err; err.showMessage("File open error"); err.exec(); return; } store((space*)getRoot(),f); }
void ConnectingDialog::error(QAbstractSocket::SocketError socketError) { QErrorMessage *msgD = new QErrorMessage(); QString msg = "Connection error: "; switch(socketError) { case QAbstractSocket::HostNotFoundError: msg.append("Host not found"); break; case QAbstractSocket::ConnectionRefusedError: msg.append("Connection refused"); break; case QAbstractSocket::RemoteHostClosedError: msg.append("Remote host closed the connection"); } msgD->showMessage(msg); msgD->exec(); reject(); }
void MainWindow::on_actionLoad_triggered() { QString file_name = QFileDialog::getOpenFileName(NULL, QString::fromUtf8("Chose file with data"), QDir::currentPath(),"(*.*)"); char * f_name = (char*)qPrintable(file_name); FILE * f = fopen(f_name,"rb"); if(f == NULL) { QErrorMessage err; err.showMessage(file_name + "File open error"); err.exec(); return; } space * root = restore(f); setRoot(root); show_tree(); }
bool XClient::connect (const char *ipcpath, const bool &sync, QWidget *parent) { bool tried_once = false; try_again: try { delete m_client; m_client = new Xmms::Client (m_name); if (!ipcpath || ipcpath == QLatin1String ("")) m_client->connect (NULL); else m_client->connect (ipcpath); } catch (Xmms::connection_error& e) { if (ipcpath == NULL && !tried_once) { QSettings s; if (s.value ("core/autostart", true).toBool ()) { if (!system ("xmms2-launcher")) { tried_once = true; goto try_again; } } } QErrorMessage *err = new QErrorMessage (parent); err->showMessage ("Couldn't connect to XMMS2, please try again."); err->exec (); delete err; return false; } m_client->setMainloop (new XmmsQT4 (m_client->getConnection ())); m_isconnected = true; // useing normal disconnect callback, if that causes problems, // an own method schould be created setDisconnectCallback (boost::bind (&XClient::disconnect, this)); emit gotConnection (this); return true; }
/* * Encrypts one character at a time from the input text box */ void Machine::encrypt_text() { QString input = ui.inputText->toPlainText(); QString::iterator itr; ui.outputText->clear(); reset_rotors(); QString output; try { for( itr = input.begin(); itr != input.end(); itr++ ) { output.append(encrypt((*itr).toAscii())); } ui.outputText->setPlainText(output); } catch( const CharacterException& e ) { QErrorMessage error; error.showMessage(e.what()); error.exec(); } }
void MainWindow::on_actionNatural_triggered() { if(getRoot() == NULL) { QErrorMessage err; err.showMessage("Root does not exits"); err.exec(); return; } int count_n = 0; space * wp = (space*)getRoot(); star** star_array = (star**)wp->sublvl; int star_count = wp->sublvl_count; for(int i_star = 0;i_star < star_count;i_star++) { star * p_star = star_array[i_star]; //expose star planet ** planet_array = (planet**)p_star->sublvl; int planet_count = p_star->sublvl_count; for(int i_planet = 0;i_planet < planet_count;i_planet++) { planet * p_planet = planet_array[i_planet]; //expose planet satellite ** satellite_array = (satellite**)p_planet->sublvl; int satellite_count = p_planet->sublvl_count; for(int i_sat = 0; i_sat < satellite_count;i_sat++) { satellite * p_sat = satellite_array[i_sat]; //expose satellite if(!p_sat->human_made){ count_n++; } } } } QString txt = QString("Natural: %1").arg(count_n); QMessageBox::about(this,"Satellites",txt); }
void MainWindow::on_actionSave_triggered() { if(getRoot() == NULL) { QErrorMessage error_mes; error_mes.showMessage("Node was not create"); error_mes.exec(); return; } QString file_name = QFileDialog::getSaveFileName(NULL, QString::fromUtf8("Chose file name for data"), QDir::currentPath(),"(*.*)"); char * f_name = (char*)qPrintable(file_name); FILE * f = fopen(f_name,"wb"); if(f == NULL) { QErrorMessage err; err.showMessage(file_name + "File open error"); err.exec(); return; } store((space*)getRoot(),f); }
void MainWindow::cropImages() { std::cout<<"Image Cropping"<<std::endl; if (!displayWidget->getImageStack().empty()) { CropImagesWidget* cropImages = new CropImagesWidget(); if (displayWidget->isImageStackLoaded) cropImages->setImageStack(displayWidget->getImageStack()); else cropImages->setImage(displayWidget->getImageViewer()->GetInput()); cropImages->setMainWindow(this); cropImages->show(); } else { QErrorMessage errorMessage; errorMessage.showMessage( "No images loaded, </ br> please load an images before crop images"); errorMessage.exec(); } }
// private slots void cSessionView::session_status(QString id, bool status, QString reason) { if (status) { m_pClient->channel_session().send_get_session_userlist(id); m_pClient->channel_session().send_get_pad_list(id); m_pClient->channel_session().send_get_chatroom_list(id); this->setEnabled(true); } else { this->setEnabled(false); QErrorMessage errorMessage; QString msg("No se ha podido conectar a la sesion: "); msg.append(id); msg.append(" Reason: "); msg.append(reason); errorMessage.showMessage(msg); errorMessage.exec(); } }
void MainWindow::addNew() { // TEMP SHORTCUT //_ui.tabPane->addTab("Resources\\spider\\spider.obj"); //_ui.tabPane->addTab("Resources\\jeep\\jeep1.ms3d"); //return; _file = QFileDialog::getOpenFileName( this, // Parent object tr("Open file"), // Caption QDir::homePath(), // Directory tr("All Files (*.*);;" // File filter "Wavefront (*.obj)") ).toStdString(); if(_file.length() == 0) return; // no file picked // Load the file into the viewer if(_ui.tabPane->addTab(_file) == -1) { // If we can't load the file, create an error popup QErrorMessage errorBox; errorBox.showMessage("Error: Invalid file tpye"); errorBox.exec(); return; } // Set window title to reflect new file string title = "3D Model Viewer - "; title.append(_file); setWindowTitle(title.c_str()); // Add a TabPane that contains our diferent viewports and widgets //_tabPane = new TabPane(this); //setCentralWidget(_tabPane); }
void SessionListWidget::commandFailed(QString const& error) { QErrorMessage msg; msg.showMessage(error); msg.exec(); }
//this slot takes the two points as input, for defining a new axis //for slicing, the new axis being the line joining these two points. //This axis is considered as z-axis, whose direction cosines are easily obtained //by using simple maths formula. Now, for for other two axis, idea is that they must //lie on the plane perpendicular to the axis. So by defining this plane, an arbitrary axis is //chosen from this plane as x-axis and direction cosines for y-axis is obtained by using //cross product rule. For arbitrarily chosing x-axis, concept used is that it must cut atleast //one of three coordinate planes. void Application::defineptr() { double x1=0,y1=0,z1=0,x2=0,y2=0,z2=0,tx,ty,tz; double lx,ly,lz,mx,my,mz,nx,ny,nz; bool ok=0; CoInputDialog *dialog = new CoInputDialog(&x1,&y1,&z1,&x2,&y2,&z2,&ok); //taking input of coordinates dialog->setStyle(QStyleFactory::create("Plastique")); dialog->exec(); if(!ok) { return; } if(x1 == x2 && y1 == y2 && z1 == z2) { QErrorMessage errmsg; errmsg.showMessage(tr("Invalid Input!!")); errmsg.setWindowIcon(QIcon(":/ICONS/Head.jpg")); errmsg.exec(); return; } lz = (x2-x1)/sqrt(pow(x2-x1,2)+pow(y2-y1,2)+pow(z2-z1,2)); //direction cosines of new z-axis mz = (y2-y1)/sqrt(pow(x2-x1,2)+pow(y2-y1,2)+pow(z2-z1,2)); nz = (z2-z1)/sqrt(pow(x2-x1,2)+pow(y2-y1,2)+pow(z2-z1,2)); if(lz!=0 ) //choosing a coordinate on perpendicular plane { tz = 0; ty = 1/sqrt(1+((mz*mz)/(lz*lz))); tx = sqrt(1-(ty*ty)); } else if (mz!=0) { tx = 0; tz = 1/sqrt(1+((nz*nz)/(mz*mz))); ty = sqrt(1-(tz*tz)); } else if (nz!=0) { ty = 0; tx = 1/sqrt(1+((lz*lz)/(nz*nz))); tz = sqrt(1-(tx*tx)); } lx = tx/sqrt((tx*tx)+(ty*ty)+(tz*tz)); //direction cosines of new x-axis, based on the point choosen mx = ty/sqrt((tx*tx)+(ty*ty)+(tz*tz)); nx = tz/sqrt((tx*tx)+(ty*ty)+(tz*tz)); ly = (mz*nx) - (mx*nz); //using cross product, direction cosines of new y-axis my = (lx*nz) - (lz*nx); ny = (lz*mx) - (lx*mz); double arbaxisElements[16] = { //matrix for reslicing lx, mx, nx, 0, ly, my, ny, 0, lz, mz, nz, 0, 0, 0, 0, 1 }; pathmat = vtkMatrix4x4::New(); pathmat->DeepCopy(arbaxisElements); pathmat->SetElement(0, 3, center[0]); pathmat->SetElement(1, 3, center[1]); pathmat->SetElement(2, 3, center[2]); vtkImageReslice *reslice = vtkImageReslice::New(); //setting the new axis reslice->SetInputConnection(reader->GetOutputPort()); reslice->SetOutputDimensionality(2); reslice->SetResliceAxes(pathmat); reslice->SetInterpolationModeToLinear(); vtkImageActor *actorx = vtkImageActor::New(); actorx->SetInput(reslice->GetOutput()); vtkRenderer *rendererx = vtkRenderer::New(); rendererx->AddActor(actorx); vtkRenderWindow *windx = vtkRenderWindow::New(); windx->AddRenderer(rendererx); vtkInteractorStyleImage *imageStyle = vtkInteractorStyleImage::New(); vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New(); interactor->SetInteractorStyle(imageStyle); //setting up interactor style to image style windx->SetInteractor(interactor); ArbAxisInterCall *Intercall = new ArbAxisInterCall(); Intercall->SetImageReslice(reslice); Intercall->SetInteractor(interactor); imageStyle->AddObserver(vtkCommand::MouseMoveEvent, Intercall); //Adding observer for renedring based on mouse activies imageStyle->AddObserver(vtkCommand::LeftButtonPressEvent, Intercall); imageStyle->AddObserver(vtkCommand::LeftButtonReleaseEvent, Intercall); defaxwid->SetRenderWindow(windx); defaxwid->GetRenderWindow()->Render(); //rendering }
void Visualizer::displayParseError(QString msg) { QErrorMessage errorMessage; errorMessage.showMessage(msg); errorMessage.exec(); }