Exemplo n.º 1
0
void GPUMemMan::Changed2DTrans(LuaClassInstance luaAbstrRen,
                               LuaClassInstance tf2d) {
  MESSAGE("Sending change notification for 2D transfer function");

  shared_ptr<LuaScripting> ss = m_MasterController->LuaScript();

  // Convert LuaClassInstance -> LuaTransferFun2DProxy -> TransferFunction2D
  LuaTransferFun2DProxy* tfProxy = 
      tf2d.getRawPointer<LuaTransferFun2DProxy>(ss);
  TransferFunction2D* pTransferFunction2D = tfProxy->get2DTransferFunction();

  pTransferFunction2D->InvalidateCache();
  pTransferFunction2D->ComputeNonZeroLimits();

  // Retrieve raw pointer for the Abstract renderer.
  AbstrRenderer* requester = NULL;
  if (luaAbstrRen.isValid(ss)) {
    requester = luaAbstrRen.getRawPointer<AbstrRenderer>(ss);
  }

  for (Trans2DListIter i = m_vpTrans2DList.begin();
       i < m_vpTrans2DList.end(); ++i) {
    if (i->pTransferFunction2D == pTransferFunction2D) {
      for (AbstrRendererListIter j = i->qpUser.begin();j<i->qpUser.end();j++) {
        if (*j != requester) (*j)->Changed2DTrans();
      }
    }
  }

}
bool MainWindow::ExportGeometry(size_t i, std::string strFilename) {
  if (!m_pActiveRenderWin) return false;
  LuaClassInstance ds = m_pActiveRenderWin->GetRendererDataset();
  shared_ptr<LuaScripting> ss(m_MasterController.LuaScript());
  if (!ds.isValid(ss) || 
      (ss->cexecRet<LuaDatasetProxy::DatasetType>(ds.fqName() + ".getDSType") !=
       LuaDatasetProxy::UVF) )
    return false;

  PleaseWaitDialog pleaseWait(this);
  pleaseWait.SetText("Exporting Mesh...");
  pleaseWait.AttachLabel(&m_MasterController);

  std::vector<shared_ptr<Mesh>> meshes =
      ss->cexecRet<std::vector<shared_ptr<Mesh>>>(ds.fqName() + "getMeshes");
  return ss->cexecRet<bool>("tuvok.io.exportMesh", meshes[i], strFilename);
}
void MainWindow::RemoveGeometry() {
  if (!m_pActiveRenderWin) return;
  LuaClassInstance ds = m_pActiveRenderWin->GetRendererDataset();
  shared_ptr<LuaScripting> ss(m_MasterController.LuaScript());
  if (!ds.isValid(ss) || 
      (ss->cexecRet<LuaDatasetProxy::DatasetType>(ds.fqName() + ".getDSType") !=
       LuaDatasetProxy::UVF) )
    return;

  PleaseWaitDialog pleaseWait(this);
  pleaseWait.SetText("Removing Mesh from UVF file...");
  pleaseWait.AttachLabel(&m_MasterController);

  int iCurrent = listWidget_DatasetComponents->currentRow();

  if (iCurrent < 1 || iCurrent >= listWidget_DatasetComponents->count()) {
    T_ERROR("No Mesh selected.");
    return;
  }

  m_pActiveRenderWin->SetDatasetIsInvalid(true);

  if (!ss->cexecRet<bool>(ds.fqName() + ".removeMesh", size_t(iCurrent-1))) {
    pleaseWait.close();
    ShowCriticalDialog("Mesh Removal Failed.",
             "Could not remove mesh from the UVF file, "
             "maybe the file is write protected? For details please "
             "check the debug log ('Help | Debug Window').");
  } else {
    m_pActiveRenderWin->RemoveMeshData(size_t(iCurrent-1));
    UpdateExplorerView(true);
    pleaseWait.close();
  }

  m_pActiveRenderWin->SetDatasetIsInvalid(false);
}