CGridLocus::CGridLocus( COARlocus *pLocusEdit, wxWindow *parent, wxWindowID id, bool bReadOnly) : _CGridEdit(parent,id,bReadOnly), m_pLocusEdited(pLocusEdit) { wxSize sz; size_t nCount = m_pLocusEdited->AlleleCount(); size_t j; int nCol = nCount ? (int) nCount : 1; int nRow = nCount ? nLABELS : 1; int i; int k; CreateGrid(nRow,nCol); if(!nCount) { SetRowLabelValue(0,wxEmptyString); SetColLabelValue(0,wxEmptyString); SetReadOnly(0,0,true); SetReadOnly(0,1,true); SetReadOnly(1,0,true); SetReadOnly(1,1,true); } else { bool bAmel = m_pLocusEdited->IsAmel(); for(i = 0; i < nRow; i++) { s = _T(labels[i]); SetRowLabelValue(i,s); SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE); } for(j = 0; j < nCount; j++) { k = (int)j; _ImplementColumn(k,bAmel); } TransferDataToWindow(); nwxGrid::UpdateLabelSizes(this); } DisableDragRowSize(); DisableDragColSize(); SetColLabelSize(GetRowSize(0)); s.Empty(); }
wxSize MultiDimGridGrid::DoGetBestSize() const { // 100 is the default minimal size of a widget - taken from wx headers. int width = std::max(GetRowLabelSize() + GetColSize(0), 100); int height = std::max(GetColLabelSize() + GetRowSize(0), 100); // The following is from the wx header file for wxScrollWindow: // Round up to a multiple the scroll rate NOTE: this still doesn't get rid // of the scrollbars, is there any magic incantaion for that? int xpu, ypu; GetScrollPixelsPerUnit(&xpu, &ypu); if(xpu) { width += 1 + xpu - (width % xpu); } if(ypu) { height += 1 + ypu - (height % ypu); } return wxSize(width, height); }
void THDContentGrid::Refresh() { // Update the table to account for current index state. BeginBatch(); // Give wxGrid ownership over the pointer, so it's destroyed at the proper time. table = new THDContentTable(model); ClearColumns(); SetTable(table, true); SetRowLabelSize(0); SetColLabelSize(0); EnableEditing(false); EnableDragRowSize(false); EnableDragColSize(false); if (GetNumberRows() > 0) { // Scroll by entire rows int rowSize = GetRowSize(0); if (rowSize > 0) SetScrollLineY(rowSize); // Size all columns for (int col = 0; col < table->columns.size(); col++) { THDContentColumn &colObj = table->columns[col]; wxClientDC dc(GetParent()); int width = colObj.visualizer->GetWidth(dc); SetColMinimalWidth(col, width); SetColSize(col, width); } } EndBatch(); }
PVideoFrame __stdcall BuildMM::GetFrame(int n, ise_t* env) { int ft = field; if (mode == 1) { ft = (n & 1) ? 1 - order : order; n /= 2; } const int* tmmlut = tmmlutf[ft]; const int tstart = n + vals[ft].tstart, tstop = n + vals[ft].tstop, bstart = n + vals[ft].bstart, bstop = n + vals[ft].bstop, ocount = vals[ft].ocount, ccount = vals[ft].ccount; auto b = BMMBuffer(ocount, ccount, length, tstop - tstart + 1); int* opitch = b.intVals.data(); int* cpitch = opitch + ocount; int* plut0 = cpitch + ccount; int* plut1 = plut0 + 2 * length - 1; const uint8_t** srcp0 = b.ptrs.data(); const uint8_t** srcp1 = srcp0 + ocount; const uint8_t** srcp2 = srcp1 + ccount; int nf = vi.num_frames - 1; for (int i = tstop; i >= tstart; --i) { if (i < 0 || i >= nfSrc) { b.tops[i - tstart] = black; continue; } b.tops[i - tstart] = child->GetFrame(i, env); } for (int i = bstop; i >= bstart; --i) { if (i < 0 || i >= nfSrc) { b.btms[i - bstart] = black; continue; } b.btms[i - bstart] = btmf->GetFrame(i, env); } PVideoFrame* oclips = ft == 0 ? b.btms : b.tops; PVideoFrame* cclips = ft == 0 ? b.tops : b.btms; auto dst = env->NewVideoFrame(vi); const int offo = (length & 1) ? 0 : 1; const int offc = !offo; for (int p = 0; p < numPlanes; ++p) { const int plane = planes[p]; uint8_t* dstp = dst->GetWritePtr(plane); const int dpitch = dst->GetPitch(plane); const int width = dst->GetRowSize(plane); const int height = dst->GetHeight(plane); for (int i = !ft; i < height; i += 2) { memset(dstp + dpitch * i, 10, width); } dstp += dpitch * ft; for (int i = 0; i < ocount; ++i) { opitch[i] = oclips[i]->GetPitch(plane); srcp0[i] = oclips[i]->GetReadPtr(plane); srcp2[i] = srcp0[i] + opitch[i] * ft; } for (int i = 0; i < ccount; ++i) { srcp1[i] = cclips[i]->GetReadPtr(plane); cpitch[i] = cclips[i]->GetPitch(plane); } const int ct = ccount / 2; for (int y = ft; y < height; y += 2) { for (int x = 0; x < width; ++x) { if (srcp1[ct - 2][x] == 0 && srcp1[ct][x] == 0 && srcp1[ct + 1][x] == 0) { dstp[x] = 60; continue; } for (int i = 0; i < ccount; ++i) { plut0[i * 2 + offc] = plut1[i * 2 + offc] = srcp1[i][x]; } for (int i = 0; i < ocount; ++i) { plut0[i * 2 + offo] = srcp0[i][x]; plut1[i * 2 + offo] = srcp2[i][x]; } int val = 0; for (int i = 0; i < length; ++i) { for (int j = 0; j < length - 4; ++j) { if (plut0[i + j] == 0) goto j1; } val |= (gvlut[i] << 3); j1: for (int j = 0; j < length - 4; ++j) { if (plut1[i + j] == 0) goto j2; } val |= gvlut[i]; j2: if (vlut[val] == 2) break; } dstp[x] = tmmlut[val]; } dstp += dpitch * 2; for (int i = 0; i < ccount; ++i) { srcp1[i] += cpitch[i]; } int y0 = y == 0 ? 0 : 1; int y1 = y == height - 3 ? 0 : 1; for (int i = 0; i < ocount; ++i) { srcp0[i] += opitch[i] * y0; srcp2[i] += opitch[i] * y1; } } } return dst; }
std::shared_ptr<VideoFrame> AvisynthVideoProvider::GetFrame(int n) { std::lock_guard<std::mutex> lock(avs.GetMutex()); auto frame = RGB32Video->GetFrame(n, avs.GetEnv()); return std::make_shared<VideoFrame>(frame->GetReadPtr(), frame->GetRowSize() / 4, frame->GetHeight(), frame->GetPitch(), true); }
bool CGridAnalysis::TransferDataToGrid( COARfile *pFile, COARsampleSort *pSort, int nLabelType, int nLabelTypeName, wxDC *pdc) { int nAMEL = -1; bool bError = false; // set up row/col count size_t nRowCount = pSort->GetCount(); size_t nAlleleColCount = pFile->GetLocusCount(); size_t nColCount = nAlleleColCount + CFrameAnalysis::FIRST_LOCUS_COLUMN + 1; DCholder xxx(this,pdc); m_nLabelSize = 0; m_setColChannelChange.clear(); nwxGridBatch xBatch(this); bError = (!nRowCount) || (!nAlleleColCount) || (!_SetGridSize((int) nRowCount,(int)nColCount)); if(!bError) { // set up column headers wxString sLabel; wxString sLocus; wxString sChannel; SetColLabelValue(CFrameAnalysis::STATUS_COLUMN,_T("")); SetColLabelValue(CFrameAnalysis::ILS_COLUMN,_T("ILS")); SetColLabelValue(CFrameAnalysis::CHANNEL_ALERT_COLUMN,_T("Channels")); int nPrevChannel = 0; int nChannel; int nCol; size_t i; const COARdirectoryAlerts *pDirAlerts = pFile->GetDirectoryAlerts(); // set up column labels for(i = 0, nCol = CFrameAnalysis::FIRST_LOCUS_COLUMN; i < nAlleleColCount; ++i,++nCol) { sLocus = pFile->GetLocusName(i); nChannel = pFile->GetChannelNr(i); sLabel = wxString::Format("%s-%d",sLocus.c_str(),nChannel); if(pDirAlerts->GetBaseLocusAlertsByLocus(sLocus) != NULL) { sLabel.Append(_T(" *")); } if(nChannel != nPrevChannel) { m_setColChannelChange.insert(nCol - 1); nPrevChannel = nChannel; } SetColLabelValue(nCol,sLabel); if(!strncmp(sLabel.MakeUpper().c_str(),"AMEL",4)) { nAMEL = nCol; } } nCol = (int)nColCount - 1; SetColLabelValue(nCol,"+Ctrl"); m_setColChannelChange.insert(nCol - 1); m_setColChannelChange.insert(nCol); UpdateGrid(pFile,pSort,nLabelType,nLabelTypeName); UpdateLabelSize(); SetGridCursor(0,CFrameAnalysis::ILS_COLUMN); SetColLabelSize(GetRowSize(0) + 2); } return !bError; }
CGridAlerts::CGridAlerts( COARmessages *pMsgEdit, wxWindow *parent, wxWindowID id, int nType, bool bReadOnly) : _CGridEdit(parent,id,bReadOnly), m_pMsgEdit(pMsgEdit), m_nChannelColumn(-1), m_nLocusColumn(-1), m_nInCellChangeEvent(0) { int bChannel = !!(nType & TYPE_CHANNEL); int bLocus = !!(nType & TYPE_LOCUS); size_t nCount = m_pMsgEdit->GetMessageCount(); if(nCount) { const wxString sDisable(_T("Enabled")); int nColCount = 2 + bChannel + bLocus; int nCol = nColCount; CreateGrid((int)nCount,nColCount); SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE); SetColLabelValue(--nCol,_T("Alert")); SetColLabelValue(--nCol,sDisable); if(bChannel) { SetColLabelValue(--nCol,LABEL_CHANNEL); m_nChannelColumn = nCol; } if(bLocus) { SetColLabelValue(--nCol,LABEL_LOCUS); m_nLocusColumn = nCol; } SetRowLabelSize(2); for(size_t j = 0; j < nCount; j++) { nCol = nColCount; SetCellAlignment((int)j,--nCol,wxALIGN_LEFT,wxALIGN_CENTRE); SetBoolCell((int)j,--nCol); SetCellAlignment((int)j,nCol,wxALIGN_CENTRE,wxALIGN_CENTRE); if(bChannel) { SetCellAlignment((int)j,m_nChannelColumn,wxALIGN_CENTRE,wxALIGN_CENTRE); SetReadOnly((int)j,m_nChannelColumn,true); } if(bLocus) { SetCellAlignment((int)j,m_nLocusColumn,wxALIGN_LEFT,wxALIGN_CENTRE); SetReadOnly((int)j,m_nLocusColumn,true); } SetRowLabelValue((int)j,wxEmptyString); } TransferDataToWindow(); SetColLabelSize(GetRowSize(0)); } else { CreateGrid(1,1); nwxGrid::SetMessageGrid(this,_T("There are no " COAR_NOTICE_DISPLAY)); } AutoSizeColumns(); DisableDragRowSize(); if(bReadOnly) { DisableDragColSize(); } }
void GLIDebugVariableGrid::SetItemValue(int rowIndex, GLenum glType, unsigned int floatCount, const float *floatData) { wxString setText; //Determine if the color block is rendered bool renderColor = false; if(floatCount == 3 || floatCount == 4) { renderColor = true; } //Determine if it is a matrix type bool isMatrix = false; uint numMatrixElemPerRow = 1; if(glType == GL_FLOAT_MAT2 || glType == GL_FLOAT_MAT3 || glType == GL_FLOAT_MAT4 || glType == GL_FLOAT_MAT2x3 || glType == GL_FLOAT_MAT2x4 || glType == GL_FLOAT_MAT3x2 || glType == GL_FLOAT_MAT3x4 || glType == GL_FLOAT_MAT4x2 || glType == GL_FLOAT_MAT4x3) { isMatrix = true; renderColor = false; //Get the number of matrix rows switch(glType) { case(GL_FLOAT_MAT2): case(GL_FLOAT_MAT2x3): case(GL_FLOAT_MAT2x4): numMatrixElemPerRow = 2; break; case(GL_FLOAT_MAT3): case(GL_FLOAT_MAT3x2): case(GL_FLOAT_MAT3x4): numMatrixElemPerRow = 3; break; case(GL_FLOAT_MAT4): case(GL_FLOAT_MAT4x2): case(GL_FLOAT_MAT4x3): numMatrixElemPerRow = 4; break; }; switch(glType) { case(GL_FLOAT_MAT2): case(GL_FLOAT_MAT3x2): case(GL_FLOAT_MAT4x2): SetRowSize(rowIndex, GetRowSize(rowIndex) * 2); break; case(GL_FLOAT_MAT3): case(GL_FLOAT_MAT2x3): case(GL_FLOAT_MAT4x3): SetRowSize(rowIndex, GetRowSize(rowIndex) * 3); break; case(GL_FLOAT_MAT4): case(GL_FLOAT_MAT2x4): case(GL_FLOAT_MAT3x4): SetRowSize(rowIndex, GetRowSize(rowIndex) * 4); break; }; } //Add an opening brace if(floatCount > 1) { setText += "("; } //Copy the data for(unsigned int i=0; i<floatCount; i++) { wxString newStr; newStr.Printf(wxT("%g"), floatData[i]); // TODO: Transpose //Ensure there is a trailing .0 if(newStr.Find('.') < 0 && newStr.Find('e') < 0) { newStr += ".0"; } //Append to the string setText += newStr; //Add a comma if necessary if(i != floatCount-1) { setText += ", "; } //If this is the end of a matrix row, add a newline if(isMatrix && (i != floatCount-1) && ((i+1) % numMatrixElemPerRow == 0)) { setText += "\n "; } } //Add a closing brace if(floatCount > 1) { setText += ")"; } //If rendering a color if(renderColor) { //Assign a color box render to the value wxColor assignColour = wxColor(FloatClamp(floatData[0]), FloatClamp(floatData[1]), FloatClamp(floatData[2])); SetCellRenderer(rowIndex, VALUE_COLUMN_INDEX, new ColourGridCellRenderer(assignColour)); } //Assign the data to the row SetCellValue(rowIndex, VALUE_COLUMN_INDEX, setText); }