void CGridDocs::SelectItem(int iRow, BOOL bSetFocus) { if(iSelRow != iRow) { CCellID cell; cell.col = 0; cell.row = iRow; if (!IsCellVisible(cell)) { CCellID idTopLeft = GetTopleftNonFixedCell(); int iPos; iPos = 0; for(int i = 1;i<iRow;i++) { iPos = iPos + GetRowHeight(i); } SetScrollPos(SB_VERT, iPos, TRUE); GetTopleftNonFixedCell(TRUE); Invalidate(); } iSelRow = iRow; SetSelectedRange(iRow,GetFixedColumnCount(),iRow,GetColumnCount()-1,TRUE,TRUE); SendMessageToParent(iRow,GetFixedColumnCount(), GVN_SELCHANGED); if(bSetFocus) SetFocus(); } }
void CGridDocs::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { int iSelectRow; iSelectRow = iSelRow; if((nChar >= VK_NUMPAD0)&&(nChar <= VK_NUMPAD9)) { nChar = nChar - VK_NUMPAD0; nChar = nChar +'0'; } if((nChar >='0')&&(nChar <= '9')) { CRect rect; if (!GetCellRect(0, 1, rect)) return; tr = new CFilterEdit(WS_VISIBLE|WS_BORDER, rect,(CWnd*)this, Mess_Filter_Edit); CString a; a.Format(_T("%c"),nChar); tr->SetWindowTextW(a); tr->SetSel(2,1); return; } if (nChar == VK_DOWN) { iSelectRow++; } else if (nChar == VK_UP) { iSelectRow--; } if(iSelectRow < GetFixedRowCount()) iSelectRow = GetFixedRowCount(); if(iSelectRow > GetRowCount()-1) iSelectRow = GetRowCount() -1; if(iSelectRow < GetFixedRowCount()) return; CCellID cell; cell.col = 0; cell.row = iSelectRow; if (!IsCellVisible(cell)) { switch (nChar) { case VK_DOWN: SendMessage(WM_VSCROLL, SB_LINEDOWN, 0); break; case VK_UP: SendMessage(WM_VSCROLL, SB_LINEUP, 0); break; } } SelectItem(iSelectRow); }
/** * Save an MD workspace to a vts/vtu file. * @param workspace: the workspace which is to be saved. * @param filename: the name of the file to which the workspace is to be saved. * @param normalization: the visual normalization option * @param recursionDepth: the recursion depth for MDEvent Workspaces determines * @param compressorType: the compression type used by VTK * from which level data should be displayed */ void SaveMDWorkspaceToVTKImpl::saveMDWorkspace( const Mantid::API::IMDWorkspace_sptr &workspace, const std::string &filename, VisualNormalization normalization, int recursionDepth, const std::string &compressorType) { auto isHistoWorkspace = boost::dynamic_pointer_cast<Mantid::API::IMDHistoWorkspace>(workspace) != nullptr; auto fullFilename = getFullFilename(filename, isHistoWorkspace); const vtkXMLWriter::CompressorType compressor = [&compressorType] { if (compressorType == "NONE") { return vtkXMLWriter::NONE; } else if (compressorType == "ZLIB") { return vtkXMLWriter::ZLIB; } else { // This should never happen. Mantid::Kernel::Logger g_log("SaveMDWorkspaceToVTK"); g_log.warning("Incorrect CompressorType: " + compressorType + ". Using CompressorType=NONE."); return vtkXMLWriter::NONE; } }(); // Define a time slice. auto time = selectTimeSliceValue(*workspace); // Get presenter and data set factory set up auto factoryChain = getDataSetFactoryChain(isHistoWorkspace, normalization, time); auto presenter = getPresenter(isHistoWorkspace, workspace, recursionDepth); // Create the vtk data NullProgressAction nullProgressA; NullProgressAction nullProgressB; auto dataSet = presenter->execute(factoryChain.get(), nullProgressA, nullProgressB); // Do an orthogonal correction dataSet = getDataSetWithOrthogonalCorrection(dataSet, presenter.get(), workspace, isHistoWorkspace); // ParaView 5.1 checks the range of the entire signal array, including blank // cells. if (isHistoWorkspace) { auto structuredGrid = vtkStructuredGrid::SafeDownCast(dataSet); vtkIdType imageSize = structuredGrid->GetNumberOfCells(); vtkNew<vtkFloatArray> signal; signal->SetNumberOfComponents(1); signal->SetNumberOfTuples(imageSize); auto oldSignal = structuredGrid->GetCellData()->GetScalars(); for (vtkIdType index = 0; index < imageSize; ++index) { if (structuredGrid->IsCellVisible(index)) { signal->SetComponent(index, 0, oldSignal->GetTuple1(index)); } else { signal->SetComponent(index, 0, std::numeric_limits<float>::quiet_NaN()); } } structuredGrid->GetCellData()->SetScalars(signal.GetPointer()); } // Write the data to the file vtkSmartPointer<vtkXMLWriter> writer = getXMLWriter(isHistoWorkspace); auto writeSuccessFlag = writeDataSetToVTKFile(writer, dataSet, fullFilename, compressor); if (!writeSuccessFlag) { throw std::runtime_error("SaveMDWorkspaceToVTK: VTK could not write " "your data set to a file."); } }