void MainWindow::CropData() {
  if (m_pActiveRenderWin) {

    // todo fix this by copying the meshes from the old dataset to the new one
    if (!m_pActiveRenderWin->GetRendererMeshes().empty()) {
      QMessageBox::warning(this, "File Error", "Cropping datasets that contain meshes is not supported at the moment.", QMessageBox::Ok);
      return;
    }

    bool bKeepOldData = (QMessageBox::Yes == 
      QMessageBox::question(NULL, "Create Backup?", "Do you want to create a backup of the current dataset before cropping?", QMessageBox::Yes, QMessageBox::No));


    m_pActiveRenderWin->SetDatasetIsInvalid(true);

    PleaseWaitDialog pleaseWait(this);
    pleaseWait.SetText("Cropping dataset");
    pleaseWait.AttachLabel(&m_MasterController);

    LuaClassInstance first3DRegion = m_pActiveRenderWin->GetFirst3DRegion();
    ExtendedPlane p = m_pActiveRenderWin->GetRendererClipPlane();
    FLOATMATRIX4 trans = m_pActiveRenderWin->GetRotation(first3DRegion) *
                         m_pActiveRenderWin->GetTranslation(first3DRegion);

    // get rid of the viewing transformation in the plane
    p.Transform(trans.inverse(),false);

    if (!m_pActiveRenderWin->RendererCropDataset(m_strTempDir,bKeepOldData)) {
      if (!m_bScriptMode) {
        QMessageBox::warning(this, "File Error", "Unable to crop dataset, is the file write protected?", QMessageBox::Ok);
      }
    } else {
      ToggleClipPlane(false);

    }
    m_pActiveRenderWin->SetDatasetIsInvalid(false);

    RenderWindow* current = m_pActiveRenderWin;
    m_pActiveRenderWin = NULL; // set m_pActiveRenderWin to NULL so RenderWindowActive thinks it has changed
    RenderWindowActive(current);

    pleaseWait.close();
  }
}
Esempio n. 2
0
void ScaleAndBiasDlg::InvertMatrix() {
  FLOATMATRIX4 m = GetExpertTransform();
  SetExpertTransform(m.inverse());
}