第一篇:QSetting類的使用小結(jié)
是QT中專門用于讀寫程序數(shù)據(jù)的對象。
*********************************************************** 簡單示例:頭文件#include
寫入操作:
生成文件結(jié)果為:
說明:如果sys.ini文件不存在,則會自動生成,用beginGroup來產(chǎn)生一個組,組名為sys,在beginGroup與endGroup之間的setValue(key, value)都屬于同一個組,第一個參數(shù)為關(guān)鍵值,第二個參數(shù)為值(QVariant類型)
****************************************************************************** 讀取操作:
輸出結(jié)果:
說明:讀取文件中的值,必須指定key所在的是哪個組,“sys/age“:sys為組名,age為sys組下的key;
“sys/sys/age”:第一個sys為組名,sys/age為key,文件保存中,key中的'/'會自動轉(zhuǎn)變?yōu)?'
第二個參數(shù)20,表示如果在配置文件中沒有找到我們所指定的key,20就作為默認(rèn)返回值
用value得到的值類型為Variant,所以必須要進(jìn)行類型轉(zhuǎn)換(根據(jù)實(shí)際需要獲取的數(shù)據(jù)類型,選擇相應(yīng)的轉(zhuǎn)換格式)
******************************************************************************
QSettings::Format有兩種:
QSettings::NativeFormat在windows平臺可以讀寫windows注冊表.QSettings::IniFormat可以讀寫ini格式的配置文件
在Unix/X11平臺下這兩個Format效果是一樣的
*****************************************************************************
刪除操作:
刪除對應(yīng)的key的格式:remove(const QString & key);
刪除后的文件內(nèi)容:
如果在beginGroup時不指定哪個組,則可以在setValue中指定所屬分組
第二篇:sqlldr使用小結(jié)
sqlldr使用小結(jié)
sqlldr userid=lgone/tiger control=a.ctl
LOAD DATA
INFILE ’t.dat’ // 要導(dǎo)入的文件
// INFILE ’tt.date’ // 導(dǎo)入多個文件
// INFILE * // 要導(dǎo)入的內(nèi)容就在control文件里 下面的BEGINDATA后面就是導(dǎo)入的內(nèi)容
INTO TABLE table_name // 指定裝入的表
BADFILE ’c:\bad.txt’ // 指定壞文件地址
************* 以下是4種裝入表的方式
APPEND // 原先的表有數(shù)據(jù) 就加在后面
// INSERT // 裝載空表 如果原先的表有數(shù)據(jù) sqlloader會停止 默認(rèn)值
// REPLACE // 原先的表有數(shù)據(jù) 原先的數(shù)據(jù)會全部刪除
// TRUNCATE // 指定的內(nèi)容和replace的相同 會用truncate語句刪除現(xiàn)存數(shù)據(jù)
************* 指定的TERMINATED可以在表的開頭 也可在表的內(nèi)部字段部分
FIELDS TERMINATED BY ’,’ OPTIONALLY ENCLOSED BY ’“’
// 裝載這種數(shù)據(jù): 10,lg,”“"lg”“",”lg,lg“
// 在表中結(jié)果: 10 lg ”lg“ lg,lg
// TERMINATED BY X ’0Array’ // 以十六進(jìn)制格式 ’0Array’ 表示的// TERMINATED BY WRITESPACE // 裝載這種數(shù)據(jù): 10 lg lg
TRAILING NULLCOLS ************* 表的字段沒有對應(yīng)的值時允許為空
************* 下面是表的字段
(col_1 , col_2 ,col_filler FILLER // FILLER 關(guān)鍵字 此列的數(shù)值不會被裝載
// 如: lg,lg,not 結(jié)果 lg lg)
// 當(dāng)沒聲明FIELDS TERMINATED BY ’,’ 時
//(// col_1 [interger external] TERMINATED BY ’,’ ,// col_2 [date ”dd-mon-yyy“] TERMINATED BY ’,’ , // col_3 [char] TERMINATED BY ’,’ OPTIONALLY ENCLOSED BY ’lg’
//)
// 當(dāng)沒聲明FIELDS TERMINATED BY ’,’用位置告訴字段裝載數(shù)據(jù)
//(// col_1 position(1:2),// col_2 position(3:10),// col_3 position(*:16), // 這個字段的開始位置在前一字段的結(jié)束位置
// col_4 position(1:16),// col_5 position(3:10)char(8)// 指定字段的類型
//)
BEGINDATA // 對應(yīng)開始的 INFILE * 要導(dǎo)入的內(nèi)容就在control文件里
10,Sql,what
20,lg,show
=======================================
//////////// 注意begindata后的數(shù)值前面不能有空格***** 普通裝載
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’ OPTIONALLY ENCLOSED BY ’”’
(DEPTNO,DNAME,LOC)
BEGINDATA
10,Sales,“"”USA“"”
20,Accounting,“Virginia,USA”
30,Consulting,Virginia
40,Finance,Virginia
50,“Finance”,“",Virginia // loc 列將為空
60,”Finance“,Virginia // loc 列將為空***** FIELDS TERMINATED BY WHITESPACE 和 FIELDS TERMINATED BY x’0Array’ 的情況
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY WHITESPACE
--FIELDS TERMINATED BY x’0Array’
(DEPTNO,DNAME,LOC)
BEGINDATA Sales Virginia ***** 指定不裝載那一列
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’ OPTIONALLY ENCLOSED BY ’”’
(DEPTNO,F(xiàn)ILLER_1 FILLER, // 下面的 “Something Not To Be Loaded” 將不會被裝載
DNAME,LOC)
BEGINDATA
20,Something Not To Be Loaded,Accounting,“Virginia,USA” ***** position的列子
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
(DEPTNO position(1:2),DNAME position(*:16), // 這個字段的開始位置在前一字段的結(jié)束位置
LOC position(*:2Array),ENTIRE_LINE position(1:2Array))
BEGINDATA
10Accounting Virginia,USA
***** 使用函數(shù) 日期的一種表達(dá) TRAILING NULLCOLS的使用
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS // 其實(shí)下面的ENTIRE_LINE在BEGINDATA后面的數(shù)據(jù)中是沒有直接對應(yīng)
// 的列的值的 如果第一行改為
10,Sales,Virginia,1/5/2000, 就不用TRAILING NULLCOLS了
(DEPTNO,DNAME “upper(:dname)”, // 使用函數(shù)
LOC “upper(:loc)”,LAST_UPDATED date ’dd/mm/yyyy’, // 日期的一種表達(dá)方式 還有’dd-mon-yyyy’ 等
ENTIRE_LINE “:deptno||:dname||:loc||:last_updated”)
BEGINDATA
10,Sales,Virginia,1/5/2000
20,Accounting,Virginia,21/6/1ArrayArrayArray 30,Consulting,Virginia,5/1/2000
40,Finance,Virginia,15/3/2001 ***** 使用自定義的函數(shù) // 解決的時間問題
create or replace
function my_to_date(p_string in varchar2)return date
as
type fmtArray is table of varchar2(25);
l_fmts fmtArray := fmtArray(’dd-mon-yyyy’, ’dd-month-yyyy’,’dd/mm/yyyy’,’dd/mm/yyyy hh24:mi:ss’);
l_return date;
begin
for i in 1..l_fmts.count
loop
begin
l_return := to_date(p_string, l_fmts(i));
exception
when others then null;
end;EXIT when l_return is not null;
end loop;
if(l_return is null)
then
l_return :=
new_time(to_date(’01011Array70’,’ddmmyyyy’)+ 1/24/60/60 *
p_string, ’GMT’, ’EST’);
end if;
return l_return;
end;
/
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS
(DEPTNO, DNAME “upper(:dname)”,LOC “upper(:loc)”,LAST_UPDATED “my_to_date(:last_updated)” // 使用自定義的函數(shù))
BEGINDATA
10,Sales,Virginia,01-april-2001
20,Accounting,Virginia,13/04/2001
30,Consulting,Virginia,14/04/2001 12:02:02
40,Finance,Virginia,Array872682Array7
50,Finance,Virginia,02-apr-2001
60,Finance,Virginia,Not a date ***** 合并多行記錄為一行記錄
LOAD DATA
INFILE *
concatenate 3 // 通過關(guān)鍵字concatenate 把幾行的記錄看成一行記錄
INTO TABLE DEPT
replace
FIELDS TERMINATED BY ’,’
(DEPTNO, DNAME “upper(:dname)”,LOC “upper(:loc)”,LAST_UPDATED date ’dd/mm/yyyy’)
BEGINDATA
10,Sales, // 其實(shí)這3行看成一行 10,Sales,Virginia,1/5/2000
Virginia,1/5/2000
// 這列子用 continueif list=“,” 也可以
告訴sqlldr在每行的末尾找逗號 找到逗號就把下一行附加到上一行
LOAD DATA
INFILE *
continueif this(1:1)= ’-’ // 找每行的開始是否有連接字符-有就把下一行連接為一行
// 如-10,Sales,Virginia,// 1/5/2000 就是一行 10,Sales,Virginia,1/5/2000
// 其中1:1 表示從第一行開始 并在第一行結(jié)束 還有continueif next 但continueif list最理想
INTO TABLE DEPT replace
FIELDS TERMINATED BY ’,’
(DEPTNO,DNAME “upper(:dname)”,LOC “upper(:loc)”,LAST_UPDATED date ’dd/mm/yyyy’)
BEGINDATA // 但是好象不能象右面的那樣使用
-10,Sales,Virginia,-10,Sales,Virginia,1/5/2000 1/5/2000
-40, 40,Finance,Virginia,13/04/2001
Finance,Virginia,13/04/2001 ***** 載入每行的行號
load data
infile *
into table t
replace
(seqno RECNUM //載入每行的行號
text Position(1:1024))
BEGINDATA fsdfasj //自動分配一行號給載入 表t 的seqno字段 此行為 1
fasdjfasdfl // 此行為 2...Array ***** 載入有換行符的數(shù)據(jù)
注意: unix 和 windows 不同 \\n & /n
< 1 > 使用一個非換行符的字符
LOAD DATA
INFILE *
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS
(DEPTNO,DNAME “upper(:dname)”,LOC “upper(:loc)”,LAST_UPDATED “my_to_date(:last_updated)”,COMMENTS “replace(:comments,’\n’,chr(10))” // replace 的使用幫助轉(zhuǎn)換換行符)
BEGINDATA
10,Sales,Virginia,01-april-2001,This is the Sales\nOffice in Virginia
20,Accounting,Virginia,13/04/2001,This is the Accounting\nOffice in Virginia
30,Consulting,Virginia,14/04/2001 12:02:02,This is the Consulting\nOffice in Virginia
40,Finance,Virginia,Array872682Array7,This is the Finance\nOffice in Virginia
< 2 > 使用fix屬性
LOAD DATA
INFILE demo17.dat “fix 101”
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS
(DEPTNO,DNAME “upper(:dname)”,LOC “upper(:loc)”,LAST_UPDATED “my_to_date(:last_updated)”,COMMENTS)
demo17.dat 10,Sales,Virginia,01-april-2001,This is the Sales
Office in Virginia
20,Accounting,Virginia,13/04/2001,This is the Accounting
Office in Virginia
30,Consulting,Virginia,14/04/2001 12:02:02,This is the Consulting
Office in Virginia
40,Finance,Virginia,Array872682Array7,This is the Finance
Office in Virginia
// 這樣裝載會把換行符裝入數(shù)據(jù)庫 下面的方法就不會 但要求數(shù)據(jù)的格式不同
LOAD DATA
INFILE demo18.dat “fix 101”
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’ OPTIONALLY ENCLOSED BY ’“’
TRAILING NULLCOLS
(DEPTNO, DNAME ”upper(:dname)“,LOC ”upper(:loc)“,LAST_UPDATED ”my_to_date(:last_updated)“,COMMENTS)
demo18.dat
10,Sales,Virginia,01-april-2001,”This is the Sales
Office in Virginia“
20,Accounting,Virginia,13/04/2001,”This is the Accounting
Office in Virginia“
30,Consulting,Virginia,14/04/2001 12:02:02,”This is the Consulting
Office in Virginia“
40,Finance,Virginia,Array872682Array7,”This is the Finance
Office in Virginia“
< 3 > 使用var屬性
LOAD DATA
INFILE demo1Array.dat ”var 3“
// 3 告訴每個記錄的前3個字節(jié)表示記錄的長度 如第一個記錄的 071 表示此記錄有 71 個字節(jié)
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS
(DEPTNO,DNAME ”upper(:dname)“,LOC ”upper(:loc)“,LAST_UPDATED ”my_to_date(:last_updated)“,COMMENTS)
demo1Array.dat
07110,Sales,Virginia,01-april-2001,This is the Sales
Office in Virginia
07820,Accounting,Virginia,13/04/2001,This is the Accounting
Office in Virginia
08730,Consulting,Virginia,14/04/2001 12:02:02,This is the Consulting
Office in Virginia
07140,Finance,Virginia,Array872682Array7,This is the Finance
Office in Virginia
< 4 > 使用str屬性
// 最靈活的一中 可定義一個新的行結(jié)尾符 win 回車換行 : chr(13)||chr(10)
此列中記錄是以 a|\r\n 結(jié)束的select utl_raw.cast_to_raw(’|’||chr(13)||chr(10))from dual;
結(jié)果 7C0D0A
LOAD DATA
INFILE demo20.dat ”str X’7C0D0A’“
INTO TABLE DEPT
REPLACE
FIELDS TERMINATED BY ’,’
TRAILING NULLCOLS
(DEPTNO,DNAME ”upper(:dname)“,LOC ”upper(:loc)“,LAST_UPDATED ”my_to_date(:last_updated)",COMMENTS)
demo20.dat 10,Sales,Virginia,01-april-2001,This is the Sales
Office in Virginia|
20,Accounting,Virginia,13/04/2001,This is the Accounting
Office in Virginia|
30,Consulting,Virginia,14/04/2001 12:02:02,This is the Consulting
Office in Virginia|
40,Finance,Virginia,Array872682Array7,This is the Finance
Office in Virginia|
================================
象這樣的數(shù)據(jù) 用 nullif 子句
10-jan-200002350Flipper seemed unusually hungry today.10510-jan-20000ArrayArray45Spread over three meals.id position(1:3)nullif id=blanks // 這里可以是blanks 或者別的表達(dá)式
// 下面是另一個列子 第一行的 1 在數(shù)據(jù)庫中將成為 null
LOAD DATA INFILE *
INTO TABLE T
REPLACE
(n position(1:2)integer external nullif n=’1’,v position(3:8))
BEGINDATA 10
20lg
-----------------------------
第三篇:GridCtrl使用小結(jié)
http://004km.cn/
GridCtrl使用詳解
CGridCtrl類主要是通過grid樣式顯示數(shù)據(jù) 在單文檔中的使用方法
步驟一 初始化 在CView類的.h頭文件中包含文件:
#include “Gridctrl.h” 并且手寫加入如下的成員函數(shù):
CGridCtrl * m_pGridCtrl;步驟二 構(gòu)造與析構(gòu) 構(gòu)造函數(shù)中:
m_pGridCtrl = NULL;析構(gòu)函數(shù)中:
if(m_pGridCtrl)
delete m_pGridCtrl;步驟三 如果需要打印功能的話添加同名打印函數(shù)代碼 在CView類的OnBeginPrinting()函數(shù)中添加如下代碼: if(m_pGridCtrl)
m_pGridCtrl->OnBeginPrinting(pDC,pInfo);//簡單吧,這就是類的好處其它兩個打印函數(shù)也一樣的做法.步驟四 在OnInitaUpdate()函數(shù)中或者你自己添加的要顯示Grid的消息函數(shù)中如下初始化: //創(chuàng)建非模式對話框 CDlg *dlg;dlg=new CDlg();dlg->Create(IDD_Dlg,this);
//初始化GridCtrl控件 if(m_pGridCtrl!=NULL){ deletem_pGridCtrl;m_pGridCtrl=NULL;} if(m_pGridCtrl == NULL){ // Create the Gridctrl object m_pGridCtrl = new CGridCtrl;if(!m_pGridCtrl)return 0;// Create the Gridctrl window CRectrect;GetClientRect(rect);m_pGridCtrl->Create(rect, this, 100);// fill it up with stuff m_pGridCtrl->SetEditable(false);m_pGridCtrl->SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));//黃色背景 m_pGridCtrl->EnableDragAndDrop(false);try { m_pGridCtrl->SetRowCount(k);//設(shè)置行數(shù)為k行 m_pGridCtrl->SetColumnCount(4);//k列
m_pGridCtrl->SetFixedRowCount(1);//標(biāo)題行為一行
http://004km.cn/
m_pGridCtrl->SetFixedColumnCount(1);//同上 } catch(CMemoryException* e){ e->ReportError();e->Delete();return 0;} //填充列標(biāo)題 int row=0;for(int col=0;col<4;col++){ GV_ITEM Item;Item.mask = GVIF_TEXT|GVIF_FORMAT;Item.row = row;Item.col = col;if(col==0){ Item.nFormat = DT_CENTER|DT_WORDBREAK;Item.strText.Format(_T(“【類別】”),col);} else if(col==1){ Item.nFormat = DT_LEFT|DT_WORDBREAK;Item.strText.Format(_T(“第一列”),col);} else if(col==2){ Item.nFormat = DT_LEFT|DT_WORDBREAK;Item.strText.Format(_T(“第二列”),col);} m_pGridCtrl->SetItem(&Item);} // fill rows/cols with text for(row = 1;row < k;row++)for(col = 0;col < h;col++){ GV_ITEM Item;Item.mask = GVIF_TEXT|GVIF_FORMAT;Item.row = row;Item.col = col;if(col < 1){ //行標(biāo)題頭
Item.nFormat = DT_CENTER|DT_VCENTER |DT_SINGLELINE|DT_END_ELLIPSIS |DT_NOPREFIX;Item.strText.Format(_T(“%d”),row);
http://004km.cn/
} else if(col==1){ //第一列的值 Item.nFormat = DT_CENTER|DT_VCENTER |DT_SINGLELINE|DT_END_ELLIPSIS |DT_NOPREFIX;str=“aa”;Item.strText.Format(_T(“%s”),str);}else if(col==2){ //第二列第值 Item.nFormat = DT_CENTER|DT_VCENTER |DT_SINGLELINE|DT_END_ELLIPSIS |DT_NOPREFIX;CStringstr;str=“bb”;Item.strText.Format(_T(“%s”),str);} m_pGridCtrl->SetItem(&Item);} m_pGridCtrl->AutoSize();
//--------------設(shè)置行列距------------------for(int a=1;a
步驟五: 添加WM_SIZE消息,調(diào)整控件的界面占屏幕大小
if(m_pGridCtrl->GetSafeHWnd())
{
CRectrect;
GetClientRect(rect);
m_pGridCtrl->MoveWindow(rect);
}
在對話框中的使用方法 步驟一 創(chuàng)建數(shù)據(jù)顯示表格對話框
在資源管理器中新創(chuàng)建一個對話框,假設(shè)為CDlgTestReportBox。從工具箱中加入Custom Control,就是人頭像的那個,將其區(qū)域拉伸至要顯示數(shù)據(jù)表格的大小,充滿整個對話框。
在CDlgTestReportBox類的頭文件中: #include “GridCtrl.h”
http://004km.cn/
再定義成員變量: CGridCtrl* m_pGrid;添加OnShowWindow()消息處理函數(shù)如下:
voidCDlgTestReportBox::OnShowWindow(BOOL bShow, UINT nStatus){ CDialog::OnShowWindow(bShow, nStatus);// TODO: Add your message handler code here if(m_pGrid!=NULL){ deletem_pGrid;m_pGrid=NULL;} if(m_pGrid==NULL){ m_pGrid=new CGridCtrl;CRectrect;GetDlgItem(IDC_ReportAera)->GetWindowRect(rect);//得到顯示區(qū)域 ScreenToClient(&rect);m_pGrid->Create(rect,this,100);m_pGrid->SetEditable(false);m_pGrid->SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));//黃色背景 try { m_pGrid->SetRowCount(10);//初始為10行
m_pGrid->SetColumnCount(11);//初始化為11列 m_pGrid->SetFixedRowCount(1);//表頭為一行 m_pGrid->SetFixedColumnCount(1);//表頭為一列 } catch(CMemoryException* e){ e->ReportError();e->Delete();// return FALSE;} for(int row = 0;row
http://004km.cn/
{ Item.nFormat = DT_CENTER|DT_WORDBREAK;Item.szText.Format(_T(“報表顯示”),col);} else if(row < 1)//設(shè)置0行表頭顯示 { Item.nFormat = DT_CENTER|DT_WORDBREAK;Item.szText.Format(_T(“ 項(xiàng)目%d”),col);} else if(col < 1)//設(shè)置0列表頭顯示 { if(row
步驟二 嵌入上面的對話框 顯示數(shù)據(jù)
在你需要顯示數(shù)據(jù)的對話框上的頭文件中,假設(shè)為CDlgTest,加入 #include ”GridCtrl.h“ CDlgTestReportBox* m_pTestReportBox;將數(shù)據(jù)顯示對話框放入你的對話框相應(yīng)位置上,在CDlgTest::OnInitDialog()中:
if(!m_pTestReportBox){
m_pTestReportBox=new CDlgTestReportBox(this);} m_pTestReportBox->Create(IDD_DlgTestReportBox,this);
http://004km.cn/
//定義區(qū)域變量 CRectrectDraw;GetDlgItem(IDC_AeraReport)->GetWindowRect(rectDraw);ScreenToClient(&rectDraw);//動態(tài)測試數(shù)據(jù)顯示區(qū)域rectDraw //將對應(yīng)的對話框放到指定區(qū)域 m_pTestReportBox->MoveWindow(rectDraw);m_pTestReportBox->ShowWindow(SW_SHOW);自定義填充數(shù)據(jù)的函數(shù):CDlgTest::FillGrid()如下: CGridCtrl* pGrid=m_pTestReportBox->m_pGrid;for(int row = pGrid->GetRowCount()-1;row >= pGrid->GetRowCount()-3;row--){ for(int col = 1;col <= pGrid->GetColumnCount();col++){ GV_ITEM Item;Item.mask = GVIF_TEXT|GVIF_FORMAT;Item.row = row;Item.col = col;if(row==pGrid->GetRowCount()-3&&col>0)//平均值 { if(col==10){ Item.nFormat = DT_CENTER|DT_WORDBREAK;Item.szText.Format(_T(” %6.2f “),avjch);} else{ Item.nFormat = DT_CENTER|DT_WORDBREAK;Item.szText.Format(_T(” %6.2f “),av[col-1]);} } pGrid->SetItem(&Item);//提交數(shù)據(jù) if(row==0||col==0){ COLORREF clr = RGB(0, 0, 0);pGrid->SetItemBkColour(row, col, clr);pGrid->SetItemFgColour(row, col, RGB(255,0,0));} }//循環(huán)結(jié)束
pGrid->Invalidate();} CGRIFCTRL原理:
DBGRID和一般的GRID的不同之處在于,一般的GRID并不適合顯示大的數(shù)據(jù)量,如果一個表中有上萬條記錄都要插入到GRID中,這將是一個很慢的過程,并且在GRID中移動滾動條時,它的記錄的滾動也是很慢。而DBGRID并不會真正把這些記錄的數(shù)據(jù)全部插入到控件中,當(dāng)DBGRID的滾動條滾動時,它會根據(jù)DBGRID的顯示面積的大小和查詢得到的總記錄數(shù)計算出當(dāng)前應(yīng)該顯示哪些行,然后插入
http://004km.cn/
到表格中,這樣一來,速度肯定快,而且沒有數(shù)據(jù)量多少的限制。幸運(yùn)的是,CGridCtrl類已經(jīng)為我們提供了這種機(jī)制,它是采用虛模式實(shí)現(xiàn)的。使用這種方式,即使你向這個該控件插入一百萬條數(shù)據(jù),它并不會真的生成一百萬行,而是隨著你的滾動條的滾動,計算出在屏幕上要顯示的行和列,然后會向你提供一個接口,通過這個接口,你可以在這兒設(shè)置你要顯示的數(shù)據(jù)。下面給出使用CGridCtrl控件的虛模式的步驟: 步驟一 初始化
在視圖的初始化函數(shù)里添加如下代碼:
void SetVirtualMode(TRUE)
設(shè)為虛模式
BOOL SetRowCount(intnRows)
設(shè)置總的行數(shù)。
BOOL SetFixedRowCount(intnFixedRows = 1)
設(shè)置固定的行數(shù)據(jù) BOOL SetColumnCount(intnCols)
設(shè)置列數(shù) BOOL SetFixedColumnCount(intnFixedCols = 1)設(shè)置固定的列數(shù) 步驟二 響應(yīng)消息 顯示數(shù)據(jù)
我們假設(shè)CGridCtrl是放在單文檔視圖中,而且它關(guān)聯(lián)的變量是m_GridCtrl,利用ClassWizard添加視圖的OnNotify響應(yīng)函數(shù)。這個響應(yīng)函數(shù)的寫法是固定的,類似下面的代碼:
BOOL CGridCtrlTestView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult){ if(wParam ==(WPARAM)m_Grid.GetDlgCtrlID()){ *pResult = 1;GV_DISPINFO *pDispInfo =(GV_DISPINFO*)lParam;if(GVN_GETDISPINFO == pDispInfo->hdr.code){ //這是添加的函數(shù),在這個函數(shù)里設(shè)置當(dāng)前要顯示的數(shù)據(jù) SetGridItem(pDispInfo);return TRUE;} } returnCGridCtrlTestView::OnNotify(wParam, lParam, pResult);} 在上面的代碼中,SetGridItem(pDispInfo)是添加的函數(shù),在這個函數(shù)里我們設(shè)置當(dāng)前要顯示的數(shù)據(jù)。pDispInfo是一個GV_DISPINFO的結(jié)構(gòu)體對象,它包含了每個單元格的信息,如行號,列號,有沒有位圖,背景色,前景色等。CGRIDCTRL會把當(dāng)前要顯示那個單元格行號,列號傳遞給我們,我們只要設(shè)置里面顯示的數(shù)據(jù)就可以了。如下面是一個顯示數(shù)據(jù)的例子。
voidCGridCtrlTestView::SetGridItem(GV_DISPINFO *pDispInfo){
pDispInfo->item.strText.Format(”row%d,col%d",pDispInfo->it
http://004km.cn/
em.row, pDispInfo->item.col);}
第四篇:git使用小結(jié)
git使用小結(jié)
1.git-config 配置git,一般需要配置的是user.name,user.email,有時sendemail.smtpserver也要配置,比如,我使用msmtp:
git-config –global sendemail.smtpserver /usr/local/bin/msmtp 如果你僅僅是想給這一個項(xiàng)目配置,把–global選項(xiàng)去掉。查看配置的選項(xiàng)是–list。2.git-pull git-pull沒必要帶后面那長長的url(-_-b 我那么用了好多次,不過我用的是!git-pull)。如果你在給Linux內(nèi)核這樣的項(xiàng)目工作,記得git-pull之前檢查是不是在master分支。3.git-format-patch 如果發(fā)送多于一個補(bǔ)丁,最好用[PATCH n/m]的形式,加上-n。加signed-off-by那行是-s。指定為幾次commit生成補(bǔ)丁,直接加數(shù)字,比如,$ git-format-patch-3 檢查補(bǔ)丁是–check,最好加上這個。4.git-send-email 如果一次提交補(bǔ)丁比較多,最好用–no-chain-reply-to,因?yàn)槿绻挥玫脑挘趖hread嵌套會太深,不利于別人閱讀。這個也可以通過選項(xiàng)sendemail.chainreplyto來控制。–signed-off-by-cc,要加上,可以省去手工處理的麻煩。–compose用來編輯[PATCH 0/m],這個一般是對整個patchset的描述。–smtp-server,如果你不想用git-config指定的話,用它也行。–cc和–to就不用說了。5.git-commit 在git-commit之前最好git-add。git-commit幾個常用的選項(xiàng)有:-s 會增加Signed-off-by行,-e編輯commit message,-a表示all,-m是指定commit信息。同樣,刪除文件是先git-rm。查看commit列表用git-rev-list,查看某個commit用git-show,查看commit的日志用git-log,-p是以補(bǔ)丁的形式查看。6.其它 git-diff也可以比較不同版本之間的差異,某個版本的某個文件的差異,如: $ git-diff v2.6.22 $ git diff v2.6.20 init/main.c $ git-diff v2.6.23 v2.6.24-rc1 init/main.c git-whatchanged也差不多: $ git-whatchanged-p init/main.c 7.錯誤提交了commit怎么辦? a)git-revert 這個本身就會產(chǎn)生一個commit,如果用得多了會讓你的log看起來不那么干凈。;-)b)git-reset 用這個要當(dāng)心,它會把那個commit之后的commit全部刪除。一個好的辦法是:先建立一個臨時的分支,然后再git-reset,再git-rebase,最后再刪除臨時的分支。詳細(xì)可以看這里。
第五篇:ICC使用小結(jié)
ICC使用小結(jié)
(1)ICC的輸入文件
MilkyWay(physical library),TLUPlus文件(interconnect文件),lib文件(logical library),netlist,constraints(sdc),floorplan文件(.fp或.def)
由于ICC會使用MilkyWay數(shù)據(jù)格式,因此有必要先熟悉MilkyWay格式的產(chǎn)生。
(2)ICC的步驟流程
ICC的流程如下:(1)import design(netlist/sdc/database)——(2)create_floorplan或adjust floorplan——(3)placement ——(4)cts——(5)route——(6)final signoff(3)具體每一步過程及注意點(diǎn)(操作點(diǎn))(4)Import design具體操作:
set_link_library xxx set_target_library xxx create_mu_lib design_library –technology xxx.tf –mw_reference_library ref_library open set_tlu_plus_file –max_tluplus max_file –min_tluplus min_file –tech2itf_map map_file read_verilog xxx.v current_design xxx link read_def xxx.def derive_pg_connection –power_net xxx_power_net –power_pin xxx_power_pin –ground_net xxx_ground_net –ground_pin xxx_ground_pin derive_pg_connection –power_net xxx_power_net –power_pin xxx_power_pin –ground_net xxx_ground_net –ground_pin xxx_ground_pin-tie read_floorplan xxx.fp或新創(chuàng)建一個floorplan接下來的任務(wù)了。
(5)Create_floorplan具體操作:
Create_floorplan針對讀入的設(shè)計以及def,開始進(jìn)行floorplan的規(guī)劃,包括IO以及macro的擺放,電源規(guī)劃等。
首先要創(chuàng)建一個floorplan,創(chuàng)建floorplan之前需要讀入IO的約束信息,3101項(xiàng)目將IO視作macro對待。具體的io constraint信號可以使用set_pad_physical_constraints來設(shè)置。
Create_floorplan –control_type width_and_height –core_width xxx –core_height xxx Remove_terminal *-keep_macro_place –keep_std_cell_place,只有設(shè)置了keep之后,才能create_fp_place完成,否則會報utility超出。
設(shè)置好floorplan之后就需要對macro和standcell進(jìn)行place了。Macro的place可以使用腳本set_obj*和set_attribute來設(shè)置,而standcell可以使用create_fP_placement來完成。這個過程中先需要設(shè)置placement以及route的blockage。create_place_blockage和create_route_guide來完成blockage的設(shè)置。
接著設(shè)置在Design Planning的task任務(wù)下,進(jìn)行place macros和standcells?;蛘呤褂胏reate_fp_placement –timing_driven –no_hierarchy_gravity 設(shè)置完macro和standcell之后,就可以進(jìn)行電源規(guī)劃了,可以通過產(chǎn)生power_ring或power_strap來進(jìn)行。create_power_strap –direction horizontal –net {VDD12 VSS_PAD} –layer M5 –configure step_end_stop –start_at 1290 –stop 2170 –step 50 –width 5 –start_low_ends coordinate –start_low_ends_coordinate 583 –start_high_ends coordinate –start_high_ends_coordinate 1710 –extend_low_ends off –extend_high_ends off –keep_floating_wire_pieces –ignore_parallel_targets –define_parallel_targets_by_wire_directions 下面對上面這個strap的創(chuàng)建進(jìn)行解釋說明下,上面的power_strap表示要在位置區(qū)域?yàn)閧{1290 583} {2170 1710}}的方形區(qū)域創(chuàng)建間距為50,線寬為5的水平方向power_strap。
(6)placement的具體操作
place_opt進(jìn)行之前需要先查看report_constraints –all看看主要的violation是哪些,同時也應(yīng)該查看congestion情況以選擇合適的place_opt策略。也需要檢查設(shè)計及物理信息,check_physical_design –for_placement以及check_design –physical,設(shè)置set_ignore_layers –max/-min,接著create_placement –timing_driven/-congestion等,若有congestion,可以設(shè)置set_congestion_options來設(shè)置合理的值,設(shè)置好placement的一些參數(shù)后,可以進(jìn)行place_opt了。
(7)cts的具體操作
cts可以通過GUI—>New Clock Tree Synthesis Window/New Interactive CTS Window查看時鐘樹的直觀形狀,可以設(shè)置clock_routing_rule來合理安排時鐘樹的線寬(NDR,Non-Default Rule)。設(shè)置OCV和bc_wc的工作條件。
(8)route的具體操作
需要先check_physical_design –for_routing檢查布線的物理設(shè)計,以及check_routeability。Set_route_options可以設(shè)置route設(shè)置相關(guān)的選項(xiàng),route_opt包括route clock nets,route signal nets,set_route_opt_strategy可以設(shè)置route相關(guān)的策略。分析route的結(jié)果可以使用verify_route和verify_drc(使用hercules),postroute delay calculation using Arnoldi algorithm。考慮si的route需要設(shè)置set_si_options。Spread_eco_cells/insert_spare_cells,place_freezen_silicon/route_eco