@@ -137,7 +137,7 @@ MainWindow::MainWindow(QWidget *parent) :
137
137
setAcceptDrops ( true );
138
138
139
139
// show the 3D view widget
140
- ui->frmContent ->layout ()->addWidget ( new View3DWidget () );
140
+ ui->frmContent ->layout ()->addWidget ( new View3DWidget ( this ) );
141
141
}
142
142
143
143
MainWindow::~MainWindow ()
@@ -449,6 +449,9 @@ void MainWindow::onProjectContextMenu(const QPoint &mouse_location)
449
449
_projectContextMenu->addMenu ( m_subMenuClassifyWith );
450
450
_projectContextMenu->addAction (" Soft indicator calibration..." , this , SLOT (onSoftIndicatorCalib ()) );
451
451
}
452
+ if ( parent_file->getFileType () == " CARTESIANGRID" ){
453
+ _projectContextMenu->addAction (" FFT" , this , SLOT (onFFT ()));
454
+ }
452
455
}
453
456
// two items were selected. The context menu depends on the combination of items.
454
457
} else if ( selected_indexes.size () == 2 ) {
@@ -1293,6 +1296,53 @@ void MainWindow::onFreeLoadedData()
1293
1296
Application::instance ()->getProject ()->freeLoadedData ();
1294
1297
}
1295
1298
1299
+ void MainWindow::onFFT ()
1300
+ {
1301
+ // propose a name for the new grid to contain the FFT image
1302
+ QString proposed_name = _right_clicked_attribute->getName () + " _FFT.dat" ;
1303
+
1304
+ // user enters the name for the new grid with FFT image
1305
+ QString new_cg_name = QInputDialog::getText (this , " Name the new grid" ,
1306
+ " Name for the grid with FFT image:" , QLineEdit::Normal,
1307
+ proposed_name );
1308
+
1309
+ // if the user canceled the input box
1310
+ if ( new_cg_name.isEmpty () ){
1311
+ // abort
1312
+ return ;
1313
+ }
1314
+
1315
+ // the parent file is surely a CartesianGrid.
1316
+ CartesianGrid *cg = (CartesianGrid*)_right_clicked_attribute->getContainingFile ();
1317
+
1318
+ // get the array containing the data
1319
+ std::vector< std::complex<double > > array = cg->getArray ( _right_clicked_attribute->getAttributeGEOEASgivenIndex ()-1 );
1320
+
1321
+ // run FFT
1322
+ Util::fft3D ( cg->getNX (),
1323
+ cg->getNY (),
1324
+ cg->getNZ (),
1325
+ array,
1326
+ FFTComputationMode::DIRECT);
1327
+
1328
+ // make a tmp file path
1329
+ QString tmp_file_path = Application::instance ()->getProject ()->generateUniqueTmpFilePath (" dat" );
1330
+
1331
+ // crate a new cartesian grid pointing to the tmp path
1332
+ CartesianGrid * new_cg = new CartesianGrid ( tmp_file_path );
1333
+
1334
+ // set the geometry info based on the original grid
1335
+ new_cg->setInfoFromOtherCG ( cg, false );
1336
+
1337
+ // save the results in the project's tmp directory
1338
+ Util::createGEOEASGrid ( " Real part" , " Imaginary part" , array, tmp_file_path);
1339
+
1340
+ // import the saved file to the project
1341
+ Application::instance ()->getProject ()->importCartesianGrid ( new_cg, new_cg_name );
1342
+
1343
+ Application::instance ()->logInfo (" FFT 2D completed." );
1344
+ }
1345
+
1296
1346
void MainWindow::onCreateCategoryDefinition ()
1297
1347
{
1298
1348
CategoryDefinition *cd = new CategoryDefinition (" " );
0 commit comments