bool singleRPAJastrowBuilder::put(xmlNodePtr cur, int addOrbital) { MyName="Jep"; string rpafunc="RPA"; OhmmsAttributeSet a; a.add(MyName,"name"); a.add(rpafunc,"function"); a.put(cur); ParameterSet params; RealType Rs(-1.0); RealType Kc(-1.0); params.add(Rs,"rs","double"); params.add(Kc,"kc","double"); params.put(cur); if(Rs<0) { Rs=tlen; } if(Kc<0){ Kc = 1e-6 ; }; if (rpafunc=="RPA"){ myHandler= new LRRPAHandlerTemp<EPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc); app_log()<<" using e-p RPA"<<endl; } else if (rpafunc=="dRPA") { myHandler= new LRRPAHandlerTemp<derivEPRPABreakup<RealType>,LPQHIBasis>(targetPtcl,Kc); app_log()<<" using e-p derivRPA"<<endl; } myHandler->Breakup(targetPtcl,Rs); // app_log() << " Maximum K shell " << myHandler->MaxKshell << endl; // app_log() << " Number of k vectors " << myHandler->Fk.size() << endl; //Add short range part Rcut = myHandler->get_rc()-0.1; GridType* myGrid = new GridType; int npts=static_cast<int>(Rcut/0.01)+1; myGrid->set(0,Rcut,npts); //create the numerical functor nfunc = new FuncType; SRA = new ShortRangePartAdapter<RealType>(myHandler); SRA->setRmax(Rcut); nfunc->initialize(SRA, myGrid); J1s = new JneType (*sourcePtcl,targetPtcl); for(int ig=0; ig<ng; ig++) { J1s->addFunc(ig,nfunc); } app_log()<<" Only Short range part of E-I RPA is implemented"<<endl; if (addOrbital) targetPsi.addOrbital(J1s,MyName); return true; }
BOOL CUpdateDBThread::TableExists(LPCTSTR lpszTableName) { BOOL bRet = FALSE; CADORecordset Rs(m_pDbConnInfo->GetConn()); //CString strSQL; //strSQL.Format(_T("select TABLE_NAME from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_NAME`='%s'"), lpszTableName); if (Rs.Open(_T("SHOW TABLES FROM NETBAR"))) { while (!Rs.IsEOF()) { CString strTmp; if (Rs.GetFieldValue(0, strTmp)) { if (0 == strTmp.CompareNoCase(lpszTableName)) { bRet = TRUE; break; } } Rs.MoveNext(); } Rs.Close(); } return bRet; }
void Hl(int y, char *txt) { Ls(y); strncat(hstr, colour_str(WHITE, BLUE), 80); strncat(hstr, padleft(txt, 58, ' '), 80); Rs(); PUTSTR(chartran(hstr)); }
BOOL CDlgAllCheckOut::SaveToDB(CCheckOutInfoArray& CheckOutArray) { if (CheckOutArray.GetCount() <= 0) { return TRUE; } //2011-4-7-gxx CString strSQL; strSQL = _T("select * from checkoutinfo where 1=0"); IBA_TRACE(strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) { return FALSE; } CADORecordset Rs(pDb->GetConn()); if (!Rs.Open(strSQL)) { pDb->Release(); return FALSE; } for (int i = 0 ; i < CheckOutArray.GetCount() ; i++ ) { CCheckOutinfo& CheckOutinfo = CheckOutArray.GetAt(i); Rs.AddNew(); Rs.SetFieldValue(_T("terminalId"),CheckOutinfo.GetTerminalId()); Rs.SetFieldValue(_T("checkOutTime"),CheckOutinfo.GetCheckOutTime()); Rs.SetFieldValue(_T("serialNum"), CheckOutinfo.GetSerialNum()); Rs.SetFieldValue(_T("className"), CheckOutinfo.GetClassName()); Rs.SetFieldValue(_T("memberId"), CheckOutinfo.GetMemberId()); Rs.SetFieldValue(_T("classState"), CheckOutinfo.GetClassState()); Rs.SetFieldValue(_T("guarantyMoney"), CheckOutinfo.GetGuarantyMoney()); Rs.SetFieldValue(_T("balanceMoney"), CheckOutinfo.GetBalanceMoney()); Rs.SetFieldValue(_T("userName"), CheckOutinfo.GetUserName()); Rs.SetFieldValue(_T("personalId"), CheckOutinfo.GetPersonalId()); Rs.SetFieldValue(_T("returnState"), CheckOutinfo.GetReturnState()); Rs.Update(); } Rs.Close(); pDb->Release(); return TRUE; // }
void Ws(int y) { int i; Ls(y); for (i = 0; i < 58; i++) strncat(hstr, (char *)" ", 80); Rs(); }
bool isRegistable(MapPoint* mp, FeaturePoint* new_fp, double pixelVar) { if (mp->featPts.size() == 0) return false; size_t nview = mp->featPts.size(); Mat_d Ks(nview + 1, 9), Rs(nview + 1, 9), ts(nview + 1, 3), ms(nview + 1, 2), nms(nview + 1, 2); double iK[9]; for (size_t c = 0; c < nview; c++) { const FeaturePoint* fp = mp->featPts[c]; assert(fp->K && fp->cam); const double* K = fp->K; const double* R = fp->cam->R; const double* t = fp->cam->t; const double* m = fp->m; doubleArrCopy(Ks, c, K, 9); doubleArrCopy(Rs, c, R, 9); doubleArrCopy(ts, c, t, 3); doubleArrCopy(ms, c, m, 2); getInvK(K, iK); normPoint(iK, m, nms + 2 * c); } doubleArrCopy(Ks, nview, new_fp->K, 9); doubleArrCopy(Rs, nview, new_fp->cam->R, 9); doubleArrCopy(ts, nview, new_fp->cam->t, 3); doubleArrCopy(ms, nview, new_fp->m, 2); normPoint(iK, new_fp->m, nms + 2 * nview); double M[3], m[2]; triangulateMultiView((int) (nview + 1), Rs, ts, nms, M); //check the re-projection error for (size_t c = 0; c < nview; c++) { const FeaturePoint* fp = mp->featPts[c]; assert(fp->K && fp->cam); project(fp->K, fp->cam->R, fp->cam->t, M, m); if (dist2(m, fp->m) > pixelVar) return false; } project(new_fp->K, new_fp->cam->R, new_fp->cam->t, M, m); if (dist2(m, new_fp->m) > pixelVar) return false; return true; }
BOOL CUpdateDBThread::FieldExists(LPCTSTR lpszTableName, LPCTSTR lpszFieldName) { BOOL bRet = FALSE; CADORecordset Rs(m_pDbConnInfo->GetConn()); CString strSQL; strSQL.Format(_T("Describe %s %s"), lpszTableName, lpszFieldName); if (Rs.Open(strSQL)) { bRet = (Rs.GetRecordCount() > 0); Rs.Close(); } return bRet; }
void Full_Help(void) { strcpy(hstr, colour_str(LIGHTGREEN, BLUE)); /* Top row */ strncat(hstr, locate_str(1, 10), 80); strncat(hstr, (char *)"\xDA", 80); strncat(hstr, hLine_str(58), 80); strncat(hstr, (char *)"\xBF", 80); PUTSTR(chartran(hstr)); Ws(2); PUTSTR(chartran(hstr)); Ls(3); strncat(hstr, colour_str(YELLOW, BLUE), 80); strncat(hstr, padleft((char *)" Editor Help", 58, ' '), 80); Rs(); PUTSTR(chartran(hstr)); Ws(4); PUTSTR(chartran(hstr)); Hl( 5, (char *)"Ctrl-S or LeftArrow - Cursor left"); Hl( 6, (char *)"Ctrl-D or RightArrow - Cursor right"); Hl( 7, (char *)"Ctrl-E or UpArrow - Cursor up"); Hl( 8, (char *)"Ctrl-X or DownArrow - Cursor down"); Hl( 9, (char *)"Ctrl-V or Insert - Insert or Overwrite"); Hl(10, (char *)"Ctrl-N - Insert line"); Hl(11, (char *)"Ctrl-Y - Delete line"); Ws(12); PUTSTR(chartran(hstr)); Hl(13, (char *)"Ctrl-L - Refresh screen"); Hl(14, (char *)"Ctrl-R - Read from file"); Ws(15); PUTSTR(chartran(hstr)); strcpy(hstr, locate_str(16,10)); strncat(hstr, (char *)"\xC0", 80); strncat(hstr, hLine_str(58), 80); strncat(hstr, (char *)"\xD9", 80); PUTSTR(chartran(hstr)); }
// 查询记录 BOOL CCardopenConsumeView::QueryHistotyConsume(CString strMemberId, CString strCardOpenTime) { BOOL bRet = FALSE; CString strSQL; strSQL.Append(_T("SELECT consume.checkinTime, consume.memberId ")); strSQL.Append(_T("FROM consume ")); strSQL.AppendFormat(_T("where consume.memberId = %s "), strMemberId); //登入时间必须在开户时间之后,防止出现strMemberId重复的情况 strSQL.AppendFormat(_T("AND consume.checkinTime BETWEEN '%s' AND '%s'") , strCardOpenTime, m_EndTime.ToString()); strSQL.Append(_T(" ORDER BY consume.checkinTime DESC")); CIBALog::GetInstance()->WriteFormat(CIBALog::ELT_SQL, _T("QueryConsume:%s"), strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) bRet = FALSE; CADORecordset Rs(pDb->GetConn()); if (Rs.Open(strSQL)) { if (Rs.GetRecordCount() > 0) { bRet = TRUE; } Rs.Close(); } pDb->Release(); return bRet; }
void updatePointUncertainty(MapPoint* mp, FeaturePoint* new_fp, double pixelVar) { if (mp->featPts.size() == 0) return; size_t nview = mp->featPts.size(); Mat_d Ks(nview + 1, 9), Rs(nview + 1, 9), ts(nview + 1, 3), ms(nview + 1, 2), nms(nview + 1, 2); double iK[9]; for (size_t c = 0; c < nview; c++) { const FeaturePoint* fp = mp->featPts[c]; assert(fp->K && fp->cam); const double* K = fp->K; const double* R = fp->cam->R; const double* t = fp->cam->t; const double* m = fp->m; doubleArrCopy(Ks, c, K, 9); doubleArrCopy(Rs, c, R, 9); doubleArrCopy(ts, c, t, 3); doubleArrCopy(ms, c, m, 2); getInvK(K, iK); normPoint(iK, m, nms + 2 * c); } doubleArrCopy(Ks, nview, new_fp->K, 9); doubleArrCopy(Rs, nview, new_fp->cam->R, 9); doubleArrCopy(ts, nview, new_fp->cam->t, 3); doubleArrCopy(ms, nview, new_fp->m, 2); normPoint(iK, new_fp->m, nms + 2 * nview); getTriangulateCovMat((int) (nview + 1), Ks, Rs, ts, mp->M, mp->cov, pixelVar); }
// 查询当前上机记录 BOOL CCardopenConsumeView::QueryActiveConsume(CString strMemberId) { BOOL bRet = FALSE; CString strSQL; strSQL.Append(_T("SELECT activemember.classId, activemember.updateTime, activemember.memberId ")); strSQL.Append(_T("FROM activemember ")); strSQL.AppendFormat(_T("where activemember.memberId = %s and refNo > 0"), strMemberId); strSQL.Append(_T(" ORDER BY activemember.updateTime DESC")); CIBALog::GetInstance()->WriteFormat(CIBALog::ELT_SQL, _T("Queryactivemember:%s"), strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) bRet = FALSE; CADORecordset Rs(pDb->GetConn()); if (Rs.Open(strSQL)) { if (Rs.GetRecordCount() > 0) { bRet = TRUE; } Rs.Close(); } pDb->Release(); return bRet; }
// 返回-1表示无效 int CDlgAllCheckOut::GetActiveMembers(CArray<CActiveMember>& ActiveMembers) { BOOL bRet = FALSE; CString strSQL; strSQL = _T("select activemember.*, member.classId as userClassId from activemember"); strSQL.Append(_T(" left outer join member on activemember.memberId = member.memberId where activemember.memberId <> 0")); IBA_TRACE(strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) return FALSE; CADORecordset Rs(pDb->GetConn()); if (Rs.Open(strSQL)) { bRet = TRUE; } else { pDb->Release(); return FALSE; } for (UINT i = 0; i < Rs.GetRecordCount(); i++) { CActiveMember ActiveMember; CString strTmp; INT nTmp = 0; if (Rs.GetFieldValue(_T("memberId"), nTmp)) { ActiveMember.SetMemberID(nTmp); } if (Rs.GetFieldValue(_T("netId"), strTmp)) { ActiveMember.SetNetId(strTmp); } if (Rs.GetFieldValue(_T("userClassId"), nTmp)) { ActiveMember.SetClassId(nTmp); } if (Rs.GetFieldValue(_T("name"), strTmp)) { ActiveMember.SetUserName(strTmp); } if (Rs.GetFieldValue(_T("sex"), nTmp)) { ActiveMember.SetSex(nTmp); } if (Rs.GetFieldValue(_T("idNumber"), strTmp)) { ActiveMember.SetPersonalID(strTmp); } if (Rs.GetFieldValue(_T("idType"), nTmp)) { ActiveMember.SetIdType(nTmp); } if (Rs.GetFieldValue(_T("lastRemainAmount"), nTmp)) { ActiveMember.SetAvailavleBalance(nTmp); } if (Rs.GetFieldValue(_T("amount"), nTmp)) { ActiveMember.SetAmount(nTmp); } if (Rs.GetFieldValue(_T("refNo"), nTmp)) { ActiveMember.SetIsOnLine( nTmp > 0 ); ActiveMember.SetRefNo(nTmp); } if (Rs.GetFieldValue(_T("status"), nTmp)) { ActiveMember.SetStatus(nTmp); } Rs.GetFieldValue(_T("activationTime"), ActiveMember.SET(ActivationTime)); Rs.GetFieldValue(_T("updateTime"), ActiveMember.SET(UpdateDataTime)); Rs.GetFieldValue(_T("checkinTime"), ActiveMember.SET(CheckInTime)); if (Rs.GetFieldValue(_T("termId"), strTmp)) { ActiveMember.SetTerminalID(strTmp); } if (Rs.GetFieldValue(_T("pcClass"), nTmp)) { ActiveMember.SetPCClassID(nTmp); } if (Rs.GetFieldValue(_T("isActive"), nTmp)) { ActiveMember.SetActive(nTmp); } if (Rs.GetFieldValue(_T("payType"), nTmp)) { ActiveMember.SetPayType(nTmp); } if (Rs.GetFieldValue(_T("advancePayment"), nTmp)) { ActiveMember.SetAdvancePayment(nTmp); } if (Rs.GetFieldValue(_T("creditProcess"), strTmp)) { ActiveMember.SetCreditProcess(strTmp); } // 2011-3-29-gxx-添加收银台ID的读取 if (Rs.GetFieldValue(_T("lastNetBarId"), nTmp)) { ActiveMember.SetCasherID(nTmp); } // 2011/05/13-gxx: 添加备注 if (Rs.GetFieldValue(_T("Remark"), strTmp)) { ActiveMember.SetRemark(strTmp); } // 2011/05/19-gxx: 开户是否为包时 if (Rs.GetFieldValue(_T("registerBT"), nTmp)) { ActiveMember.SetIsRegisterBT(nTmp); } // 2011/07/21-8201-gxx: { // 累计封顶额 if (Rs.GetFieldValue(_T("dynamicMaxAmount"), nTmp)) { ActiveMember.SetDynamicMaxAmount(nTmp); } // 是否本地用户 if (Rs.GetFieldValue(_T("isLocal"), nTmp)) { ActiveMember.SetIsLocalUser(nTmp); } // 上机密码, MD5值 if (Rs.GetFieldValue(_T("password"), strTmp)) { ActiveMember.SetPassword(strTmp); } // 扣率 if (Rs.GetFieldValue(_T("PolicyInfo"), strTmp)) { ActiveMember.SetPolicyInfo(strTmp); } //} ActiveMembers.Add(ActiveMember); Rs.MoveNext(); } IBA_TRACE("用户总数为:%d",Rs.GetRecordCount()); Rs.Close(); pDb->Release(); //CLocalServer::GetInstance()->ActiveMemberList.Copy(ActiveMembers); return ActiveMembers.GetCount(); }
void MainWindow::on_actionBrightness_quantization_triggered() { QPixmap pixmap = pixmapItem->pixmap().copy(); QImage image = pixmap.toImage(); int width = image.width(); int height = image.height(); if (width == 0 || height == 0) { ui->statusBar->showMessage( tr("Error. Image bad size"), 3000 ); return; } std::vector<int> grays(width * height); for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { QRgb oldColor = image.pixel(x, y); int gray = qPow( 0.2126 * qPow(qRed(oldColor), 2.2) + 0.7152 * qPow(qGreen(oldColor), 2.2) + 0.0722 * qPow(qBlue(oldColor), 2.2), 1/2.2 ); grays[x + y * width] = gray; } std::vector<unsigned int> Rs(256, 0); std::vector<unsigned int> Gs(256, 0); std::vector<unsigned int> Bs(256, 0); std::vector<int> hist(256, 0); for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { int num = grays[x + y * width]; Rs[num] += qRed( image.pixel(x, y) ); Gs[num] += qGreen( image.pixel(x, y) ); Bs[num] += qBlue( image.pixel(x, y) ); ++hist[num]; } int quantsCountMaximum = 0; std::map<int, QRgb> colors; for (int i = 0; i < 256; ++i) { if (hist[i] == 0) continue; Rs[i] /= hist[i]; Gs[i] /= hist[i]; Bs[i] /= hist[i]; colors[i] = qRgb(Rs[i], Gs[i], Bs[i]); ++quantsCountMaximum; } DialogQuantization dialog; dialog.setQuantCountMaximum(quantsCountMaximum); if (dialog.exec() == QDialog::Rejected) return; int quantsCount = dialog.quantsCount(); double shift = 256 / quantsCount; double cur = 0.0; double next = 0.0; for (int i = 0; i < quantsCount; ++i) { next += shift; int c = qFloor(cur); int n = qFloor(next); int minC = 256; for (std::map<int, QRgb>::iterator it = colors.begin(); it != colors.end(); ++it) if (c <= (it->first) && (it->first) < n) if (it->first < minC) minC = it->first; QRgb newColor = colors[minC]; for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { int num = grays[x + y * width]; if (c <= num && num < n) image.setPixel(x, y, newColor); else continue; } cur = next; } pixmap.convertFromImage(image); pixmapItem_2->setPixmap(pixmap); scene_2->setSceneRect(QRectF(pixmap.rect())); //ui->graphicsView_2->fitInView(scene_2->itemsBoundingRect(), Qt::KeepAspectRatio); calcHist(pixmap, hist_2, maxLevel_2); drawHist(pixmapItem_4, hist_2, maxLevel_2); }
// 用户开户查询 void CCardopenConsumeView::QueryRegister(void) { CArray<NS_DAL::CCardOpenInfo, NS_DAL::CCardOpenInfo &> CardOpenDBArray; CString strSQL; strSQL.Append(_T("SELECT cardopen.*, member.classId, member.memberId, member.name, member.serialNum, member.idNumber ")); strSQL.Append(_T("FROM cardopen, member ")); strSQL.Append(_T("WHERE cardopen.memberId = member.memberId ")); strSQL.Append(_T("AND cardopen.classId = member.classId ")); strSQL.AppendFormat(_T("AND member.classId in %s "), GetCommonClassIdAsString()); strSQL.AppendFormat(_T("AND cardopen.operationDateTime BETWEEN '%s' AND '%s'") , m_StartTime.ToString(), m_EndTime.ToString()); strSQL.Append(_T(" ORDER BY cardopen.operationDateTime DESC")); CIBALog::GetInstance()->WriteFormat(CIBALog::ELT_SQL, _T("QueryRegister:%s"), strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) return; CADORecordset Rs(pDb->GetConn()); if (Rs.Open(strSQL)) { INT i = 0; while (!Rs.IsEof()) { INT nTmp = 0; CString strTmp; CCardOpenInfo CardOpenInfo; Rs.GetFieldValue(_T("serialNum"), strTmp); CardOpenInfo.SetSerialNum(strTmp); Rs.GetFieldValue(_T("name"), strTmp); CardOpenInfo.SetUserName(strTmp); Rs.GetFieldValue(_T("idNumber"), strTmp); CardOpenInfo.SetIdNumber(strTmp); Rs.GetFieldValue(_T("memberId"), nTmp); CardOpenInfo.SetMemberId(nTmp); Rs.GetFieldValue(_T("operationDateTime"), strTmp); CardOpenInfo.SetOperationDateTime(strTmp); Rs.GetFieldValue(_T("operator"), strTmp); CardOpenInfo.SetOperator(strTmp); i++; CardOpenDBArray.Add(CardOpenInfo); Rs.MoveNext(); } Rs.Close(); } pDb->Release(); for (INT ii = 0; ii < CardOpenDBArray.GetCount(); ii++) { #ifdef _DEBUG if (CardOpenDBArray.GetAt(ii).GetMemberId() == 178547) { int kkk = 0; } #endif CString strSQL; strSQL.Append(_T("SELECT returned.* ")); strSQL.Append(_T("FROM returned ")); strSQL.AppendFormat(_T("WHERE returned.memberId = '%d' AND returned.classId in %s ") , CardOpenDBArray.GetAt(ii).GetMemberId(), GetCommonClassIdAsString()); strSQL.AppendFormat(_T("AND returned.returnDate >= '%s'") , CardOpenDBArray.GetAt(ii).GetOperationDateTime()); strSQL.Append(_T(" ORDER BY returned.returnDate DESC")); CIBALog::GetInstance()->WriteFormat(CIBALog::ELT_SQL, _T("QueryReturned:%s"), strSQL); CADODBConnInfo* pDb = NULL; if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) return; CADORecordset Rs(pDb->GetConn()); if (Rs.Open(strSQL)) { if (!Rs.IsEof()) { CardOpenDBArray.RemoveAt(ii); ii--; } Rs.Close(); } pDb->Release(); } for (INT jj = 0; jj < CardOpenDBArray.GetCount(); jj++) { INT nTmp = 0; CString strTmp; m_InfoList.InsertItem(jj, CardOpenDBArray.GetAt(jj).GetSerialNum()); m_InfoList.SetItemText(jj, 1, CardOpenDBArray.GetAt(jj).GetUserName()); m_InfoList.SetItemText(jj, 3, CardOpenDBArray.GetAt(jj).GetIdNumber()); strTmp.Format(_T("%d"), CardOpenDBArray.GetAt(jj).GetMemberId()); m_InfoList.SetItemText(jj, 4, strTmp); m_InfoList.SetItemText(jj, 5, CardOpenDBArray.GetAt(jj).GetOperationDateTime()); } CardOpenDBArray.RemoveAll(); }