Screen* ScreenMgr::getScreen(ResourceID id){ uint32_t row = GetRow(id); uint32_t col = GetCol(id); if ( row-1 >=0 && col-1 >=0 && row -1 < getRowCount() && col -1 < getColCount()){ return screens_[GetRow(id)-1][GetCol(id)-1]; }else return 0; }
void drawXFormPixelWithAlpha(const uint32_t i, const uint32_t j, const GRect &srcRect, const GIRect &dstRect, const GBitmap &src, const GBitmap &dst, const uint8_t alpha, const BlendFunc blend = blend_srcover) { GVec3f ctxPt(static_cast<float>(dstRect.fLeft + i) + 0.5f, static_cast<float>(dstRect.fTop + j) + 0.5f, 1.0f); ctxPt = m_CTMInv * ctxPt; if(ContainsPoint(srcRect, ctxPt[0], ctxPt[1])) { uint32_t x = static_cast<uint32_t>(ctxPt[0] - srcRect.fLeft); uint32_t y = static_cast<uint32_t>(ctxPt[1] - srcRect.fTop); GPixel *srcRow = GetRow(src, y); GPixel *dstRow = GetRow(dst, j+dstRect.fTop) + dstRect.fLeft; uint32_t srcA = fixed_multiply(GPixel_GetA(srcRow[x]), alpha); uint32_t srcR = fixed_multiply(GPixel_GetR(srcRow[x]), alpha); uint32_t srcG = fixed_multiply(GPixel_GetG(srcRow[x]), alpha); uint32_t srcB = fixed_multiply(GPixel_GetB(srcRow[x]), alpha); GPixel src = GPixel_PackARGB(srcA, srcR, srcG, srcB); dstRow[i] = blend(dstRow[i], src); } }
bool Board::DoesEnPassantCaptureCauseDiscoveredCheck(int square, int color) { assert(this->enPassantRights.HasEnPassant()); int attackerColor = OtherColor(color); int kingSquare = GetKingSquare(color); int kingRow = GetRow(kingSquare); int pieceRow = GetRow(square); int dr = pieceRow - kingRow; ulong defenderKing = 1ULL << kingSquare; if (dr == 0) { ulong myRankAttacks = MoveGenerator::rankAttacks[square][GetRankStatus(square)]; ulong theirRankAttacks = MoveGenerator::rankAttacks[enPassantRights.PawnSquare()][GetRankStatus(enPassantRights.PawnSquare())]; ulong defenderKing = 1ULL << kingSquare; if ((defenderKing & myRankAttacks) != 0 || (defenderKing & theirRankAttacks) != 0) { ulong attackers = GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Rook, attackerColor)) | GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Queen, attackerColor)); if ((myRankAttacks & attackers) != 0 || (theirRankAttacks & attackers) != 0) { return true; } } } return false; }
int RDMatrix::port(RDMatrix::Role role) const { switch(role) { case RDMatrix::Primary: return GetRow("PORT").toInt(); case RDMatrix::Backup: return GetRow("PORT_2").toInt(); } return -1; }
unsigned RDMatrix::stopCart(RDMatrix::Role role) const { switch(role) { case RDMatrix::Primary: return GetRow("STOP_CART").toUInt(); case RDMatrix::Backup: return GetRow("STOP_CART_2").toUInt(); } return 0; }
QString RDMatrix::password(RDMatrix::Role role) const { switch(role) { case RDMatrix::Primary: return GetRow("PASSWORD").toString(); case RDMatrix::Backup: return GetRow("PASSWORD_2").toString(); } return QString(); }
QString RDMatrix::username(RDMatrix::Role role) const { switch(role) { case RDMatrix::Primary: return GetRow("USERNAME").toString(); case RDMatrix::Backup: return GetRow("USERNAME_2").toString(); } return QString(); }
RDMatrix::PortType RDMatrix::portType(RDMatrix::Role role) const { switch(role) { case RDMatrix::Primary: return (RDMatrix::PortType)GetRow("PORT_TYPE").toInt(); case RDMatrix::Backup: return (RDMatrix::PortType)GetRow("PORT_TYPE_2").toInt(); } return RDMatrix::TtyPort; }
void Pacman::Debug() { std::cout << std::endl; std::cout << "<<< Pacmans' Data >>>" << std::endl; std::cout << "actual position: (" << GetPosition().x << ", " << GetPosition().y << ")" << std::endl; std::cout << "grid position: (" << GetRow() << "," << GetColumn() << ")" << std::endl; std::cout << "map tile: " << map->getTile(GetRow(), GetColumn()) << std::endl; std::cout << std::endl; std::cout << "<<< END Pacmans' Data >>>" << std::endl; std::cout << std::endl; }
ResourceID ScreenMgr::occupyScreenOut( ResourceID inputid){ Screen* screen = screens_[GetRow(inputid)-1][GetCol(inputid)-1]; for ( auto it = screen->outPort753_.begin(); it != screen->outPort753_.end(); ++it){ if ( it->second == 0){ ResourceID wnode = ToResourceID( GetInput(inputid), GetOutput(it->first), GetRow(inputid), GetCol(inputid)); it->second = wnode; return wnode; } } return 0; }
void Screen::connInOutRequest(ResourceID inputid, ResourceID wnode){ if ( qbox_){ QboxDataMap value; value["out"] = QString::number(GetOutput(wnode) ).toStdString(); if ( GetCol(inputid) == GetCol(wnode) && GetRow(inputid) == GetRow(wnode)){ value["in"] = QString::number(GetInput(inputid) ).toStdString(); }else{ value["in"] = QString::number(GetInput(wnode) ).toStdString(); } qbox_->addAsyncRequest( PSetSwitchInputReq::uri , std::bind( ignoreCallback, std::placeholders::_1, std::placeholders::_2), value); } }
bool Screen::connInOutRequestCB(ResourceID inputid, ResourceID wnode, QboxCallback callback, uint32_t , QboxDataMap& v){ if ( qbox_){ QboxDataMap value; value["out"] = QString::number(GetOutput(wnode) ).toStdString(); if ( GetCol(inputid) == GetCol(wnode) && GetRow(inputid) == GetRow(wnode)){ value["in"] = QString::number(GetInput(inputid) ).toStdString(); }else{ value["in"] = QString::number(GetInput(wnode) ).toStdString(); } qbox_->addAsyncRequest( PSetSwitchInputReq::uri , callback, value); return true; } return false; }
QHostAddress RDMatrix::ipAddress(RDMatrix::Role role) const { QHostAddress addr; switch(role) { case RDMatrix::Primary: addr.setAddress(GetRow("IP_ADDRESS").toString()); break; case RDMatrix::Backup: addr.setAddress(GetRow("IP_ADDRESS_2").toString()); break; } return addr; }
void Matrix3x3::Renormalization() { Vector3D Xorth, Yorth, Zorth, X = GetRow(0), Y = GetRow(1); double Error = X * Y; Xorth = X - Y * Error; Yorth = Y - X * Error; Zorth = Vector3D::Cross(Xorth, Yorth); // Normalize via Taylor expansion Xorth = Xorth * 0.5d * (3.0d - Xorth * Xorth); Yorth = Yorth * 0.5d * (3.0d - Yorth * Yorth); Zorth = Zorth * 0.5d * (3.0d - Zorth * Zorth); SetRow(0, Xorth); SetRow(1, Yorth); SetRow(2, Zorth); }
double FDSMesh::GetKnotValue(const double &x, const double &y) const { /// To Do: exception / warning when no knot is available for the pedestrian position int col=0; int row=0; /// Which knot is the nearest one to (x,y)? GetColumn(x, col); GetRow(row, y); //std::cout << _matrix[row][col].GetValue() << std::endl; double value; // Exception if a mesh can not provide an appropriately located value if(row < _matrix.size() && col < _matrix[0].size()) value = _matrix[row][col].GetValue(); else // needs to be fixed!!! value = 0.0;//std::numeric_limits<double>::quiet_NaN(); // if(_matrix[row][col].GetValue() == 0.) { // std::cout << "(" << row << " , " << col << ")" << std::endl; // } return value; }
void InfoBoxesConfigWidget::RefreshEditContentDescription() { DataFieldEnum &df = (DataFieldEnum &)GetDataField(CONTENT); WndFrame &description = (WndFrame &)GetRow(DESCRIPTION); description.SetText(df.GetHelp() != nullptr ? df.GetHelp() : _T("")); }
void MyListModel::DeleteItems( const wxDataViewItemArray &items ) { unsigned i; wxArrayInt rows; for (i = 0; i < items.GetCount(); i++) { unsigned int row = GetRow( items[i] ); if (row < m_textColValues.GetCount()) rows.Add( row ); } if (rows.GetCount() == 0) { // none of the selected items were in the range of the items // which we store... for simplicity, don't allow removing them wxLogError( "Cannot remove rows with an index greater than %d", m_textColValues.GetCount() ); return; } // Sort in descending order so that the last // row will be deleted first. Otherwise the // remaining indeces would all be wrong. rows.Sort( my_sort_reverse ); for (i = 0; i < rows.GetCount(); i++) m_textColValues.RemoveAt( rows[i] ); // This is just to test if wxDataViewCtrl can // cope with removing rows not sorted in // descending order rows.Sort( my_sort ); RowsDeleted( rows ); }
//============================================================================= double Epetra_MsrMatrix::NormOne() const { if (NormOne_>-1.0) return(NormOne_); if (!Filled()) EPETRA_CHK_ERR(-1); // Matrix must be filled. Epetra_Vector * x = new Epetra_Vector(RowMatrixRowMap()); // Need temp vector for column sums Epetra_Vector * xp = 0; Epetra_Vector * x_tmp = 0; // If we have a non-trivial importer, we must export elements that are permuted or belong to other processors if (RowMatrixImporter()!=0) { x_tmp = new Epetra_Vector(RowMatrixColMap()); // Create temporary import vector if needed xp = x_tmp; } int i, j; for (i=0; i < NumMyCols_; i++) (*xp)[i] = 0.0; for (i=0; i < NumMyRows_; i++) { int NumEntries = GetRow(i); for (j=0; j < NumEntries; j++) (*xp)[Indices_[j]] += fabs(Values_[j]); } if (RowMatrixImporter()!=0) x->Export(*x_tmp, *RowMatrixImporter(), Add); // Fill x with Values from temp vector x->MaxValue(&NormOne_); // Find max if (x_tmp!=0) delete x_tmp; delete x; UpdateFlops(NumGlobalNonzeros()); return(NormOne_); }
//============================================================================= int Epetra_MsrMatrix::InvRowSums(Epetra_Vector& x) const { // // Put inverse of the sum of absolute values of the ith row of A in x[i]. // if (!OperatorRangeMap().SameAs(x.Map())) EPETRA_CHK_ERR(-2); // x must have the same distribution as the range of A int ierr = 0; int i, j; for (i=0; i < NumMyRows_; i++) { int NumEntries = GetRow(i); // Copies ith row of matrix into Values_ and Indices_ double scale = 0.0; for (j=0; j < NumEntries; j++) scale += fabs(Values_[j]); if (scale<Epetra_MinDouble) { if (scale==0.0) ierr = 1; // Set error to 1 to signal that zero rowsum found (supercedes ierr = 2) else if (ierr!=1) ierr = 2; x[i] = Epetra_MaxDouble; } else x[i] = 1.0/scale; } UpdateFlops(NumGlobalNonzeros()); EPETRA_CHK_ERR(ierr); return(0); }
// Gets the dimensions of the colour cell given by (row,col) BOOL CColourPopup::GetCellRect(int nIndex, const LPRECT& rect) { if (nIndex == CUSTOM_BOX_VALUE) { ::SetRect(rect, m_CustomTextRect.left, m_CustomTextRect.top, m_CustomTextRect.right, m_CustomTextRect.bottom); return TRUE; } else if (nIndex == DEFAULT_BOX_VALUE) { ::SetRect(rect, m_DefaultTextRect.left, m_DefaultTextRect.top, m_DefaultTextRect.right, m_DefaultTextRect.bottom); return TRUE; } if (nIndex < 0 || nIndex >= m_nNumColours) return FALSE; rect->left = GetColumn(nIndex) * m_nBoxSize + m_nMargin; rect->top = GetRow(nIndex) * m_nBoxSize + m_nMargin; // Move everything down if we are displaying a default text area if (m_strDefaultText.GetLength()) rect->top += (m_nMargin + m_DefaultTextRect.Height()); rect->right = rect->left + m_nBoxSize; rect->bottom = rect->top + m_nBoxSize; return TRUE; }
static void block_cut() { EditLine *ed,*ed_next; int x_st, x_ed; char buf[MAXEDITLINE+1]; if (bkm.blkm==BLKM_y && bkm.y_st<GetLastNumber()) lists_delete(bkm.y_st, bkm.y_ed-1);else { ed=GetList(bkm.y_st); block_range(bkm.y_st, &bkm, &x_st, &x_ed); strcpy(buf, ed->buffer); buf[x_st]='\0'; ed_next=GetList(bkm.y_ed); block_range(bkm.y_ed, &bkm, &x_st, &x_ed); strcat(buf, ed_next->buffer+x_ed); Realloc(ed, buf); if (bkm.y_st+1<=bkm.y_ed) lists_delete(bkm.y_st+1, bkm.y_ed); } SetFileChangeFlag(); csr_lenew(); csr_setdy(GetRow()+bkm.y_st-GetLineOffset()); csr_setly(bkm.y_st); if (bkm.blkm==BLKM_x) csr_setlx(bkm.x_st); }
BOOL COptionTreeColorPopUp::GetCellRect(int nIndex, const LPRECT& rect) { // Get cell rect if (nIndex == OT_COLOR_CUSTOMBOXVALUE) { ::SetRect(rect, m_rcCustomTextRect.left, m_rcCustomTextRect.top, m_rcCustomTextRect.right, m_rcCustomTextRect.bottom); return TRUE; } else if (nIndex == OT_COLOR_DEFAULTBOXVALUE) { ::SetRect(rect, m_rcDefaultTextRect.left, m_rcDefaultTextRect.top, m_rcDefaultTextRect.right, m_rcDefaultTextRect.bottom); return TRUE; } if (nIndex < 0 || nIndex >= m_nNumColors) { return FALSE; } rect->left = GetColumn(nIndex) * m_nBoxSize + m_nMargin; rect->top = GetRow(nIndex) * m_nBoxSize + m_nMargin; // Move everything down if we are displaying a default text area if (m_strDefaultText.GetLength()) { rect->top += (m_nMargin + m_rcDefaultTextRect.Height()); } rect->right = rect->left + m_nBoxSize; rect->bottom = rect->top + m_nBoxSize; return TRUE; }
QModelIndex MergeModel::mapFromSource (const QModelIndex& sourceIndex) const { if (!sourceIndex.isValid ()) return {}; QList<QModelIndex> hier; auto parent = sourceIndex; while (parent.isValid ()) { hier.prepend (parent); parent = parent.parent (); } auto currentItem = Root_; for (const auto& idx : hier) { currentItem = currentItem->FindChild (idx); if (!currentItem) { qWarning () << Q_FUNC_INFO << "no next item for" << idx << hier; return {}; } } return createIndex (currentItem->GetRow (), sourceIndex.column (), currentItem.get ()); }
void CResolverUIModel::DeleteItem(const wxDataViewItem &item) { unsigned int row = GetRow(item); if (m_model.deleteEntry(row)) { RowDeleted(row); } }
void CTimeBarListModel::DeleteItems( const wxDataViewItemArray &items ) { wxArrayInt rows; for (unsigned i = 0; i < items.GetCount(); i++) { unsigned int row = GetRow( items[i] ); if (row < m_textColValues.GetCount()) rows.Add( row ); } if (rows.GetCount() > 0) { // Sort in descending order so that the last // row will be deleted first. Otherwise the // remaining indeces would all be wrong. rows.Sort([](int *v1, int *v2) { return *v2-*v1; }); for (unsigned i = 0; i < rows.GetCount(); i++) { m_textColValues.RemoveAt( rows[i] ); m_view.RemoveAt( rows[i] ); m_lock.RemoveAt( rows[i] ); } // This is just to test if wxDataViewCtrl can // cope with removing rows not sorted in // descending order rows.Sort([](int *v1, int *v2) { return *v1-*v2; }); RowsDeleted( rows ); } }
// 重新加载现场测道数据 void CSensorListCtrl::OnReloadSiteDataCMD() { // 现场数据对象初始化 OnSiteDataInit(); matrix_data::data_base_helper::device_info_map& map = data_base_helper_->get_devices_info(); matrix_data::data_base_helper::device_info_map::const_iterator itr; matrix_data::data_base_helper::device_info di; CBCGPGridRow* pRow = NULL; data_base_helper_->devices_info_lock(); for(itr = map.begin(); itr != map.end(); ++itr) { pRow = FindRowByData(itr->second.ip_, FALSE); // 填充本次数据 if(pRow != NULL) { SetRowData(pRow, itr->second); // 设置一行的数据 } else { pRow = CreateRow(GetColumnCount()); SetRowData(pRow, itr->second); AddRow(pRow, FALSE); } } // 删除没有用到的行 for(int i = (GetRowCount() - 1); i >= 0; i--) { pRow = GetRow(i); if(pRow != NULL) { // 找到行 di.ip_ = pRow->GetData(); if(data_base_helper_->find_device(di.ip_, di)) RemoveRow(i, FALSE); } } data_base_helper_->devices_info_unlock(); AdjustLayout (); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 创建条件 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// void SVConditionParam::createCondition() { int nRow = numRows(); m_pLabel = new WText(m_szLabel, elementAt(nRow, 0)); elementAt(nRow, 0)->setContentAlignment(AlignTop | AlignLeft); elementAt(nRow, 0)->setStyleClass("table_list_data_input_text"); GetRow(nRow)->setStyleClass("padding_top"); string szValue (""); if(!m_szDefaultValue.empty()) szValue = chLeftBracket + m_szDefaultValue + chRightBracket; m_pConditionArea = new WTextArea(szValue, elementAt(nRow, 1)); if(m_pConditionArea) m_pConditionArea->setStyleClass(m_szStyle); elementAt(nRow, 1)->setStyleClass("table_data_text"); createShowButton(nRow); createHelp(nRow); m_pOperate = new WTable(elementAt(nRow,1)); if(m_pOperate) { m_pOperate->setStyleClass("conditionset"); createHideButton(); createAddConidtion(); createButtonGroup(); m_pOperate->hide(); } }
void Character::Death(Cell*Room[20][20]) { cout << GetName() << " is dead." <<endl; m_isDead = true; Room[GetRow()][GetColumn()]->Reset(); SetPosition(NULL,NULL); }
std::string GetSquareSAN(const Square square) { std::string result; result += GetColumn(square) + 'a'; result += (RANK_1 - GetRow(square)) + '1'; return result; }
void CLoadBalanceBar::PopulateView() { int threads = m_Engine->GetThreadCount(); m_View->CreateRows(threads); // can take a while if CPU overloaded m_ThreadPlugin.SetSize(threads); int plugs = m_Engine->GetPluginCount(); int RowIdx = 0; for (int PlugIdx = 0; PlugIdx < plugs; PlugIdx++) { CPlugin& plug = m_Engine->GetPlugin(PlugIdx); int PlugThreads = plug.GetThreadCount(); for (int ThrIdx = 0; ThrIdx < PlugThreads; ThrIdx++) { m_ThreadPlugin[RowIdx] = PlugIdx; CString name(plug.GetName()); if (PlugThreads > 1) { CString s; s.Format(_T("[%d]"), ThrIdx); name += s; } CLoadBalanceRow *rp = GetRow(RowIdx); rp->SetPluginName(name + ':'); rp->EnableThreadCountEdit(!ThrIdx); if (!ThrIdx) // if plugin's first thread rp->SetThreadCount(PlugThreads); else rp->BlankThreadCount(); RowIdx++; } } }