SVX日記
2009-02-10(Tue) Fedora9、電子工作チューン外伝EX
昨日、Qt-BSch3Vの使い勝手がイマイチだ、などとオープンソース物件に対して文句を付けてしまったが、文句を付けたからには、自分で改修してしまうのである。文句を付けるからにはそれくらいはする。それが、オープンソース物件を使う際の「掟」である。最近は、使わせてもらっておいて、貢献する気もなく、文句ばかり言うという「失礼な輩」が増えているが、それはエチケットに反する。Oh!X の頃からの「言い出しっぺの法則」というのは、現在も有効なのである。文句があるなら、おまえがやれ、なのである。
- アクティブレイヤの切り替えがサクサクできるように、ショートカットを追加
- お目々が痛くならないように、色を元祖BSchコンパチに
- オブジェクトが、常にトップレイヤに配置されてしまうなど、いくつかのバグ修正
そんなこんなで書いたのが、上の図面。いやぁ、以前より、サクサクですわ。BSch3Vから、レイヤ設定ウィンドウが「ダイアログ」になってしまい、イチイチ閉じないと図面がイジれなくなってしまったのがイヤで、古いBSchを使い続けていたが、ショートカットキーの追加によって、それ以上の操作性になった。キャッホゥ。
と、それはそうと、このQt-BSch3Vは、本家のページにてメンテナンス終了宣言が出されつつあるようだ。少し残念。しかし、別にソースが提供出されていれば、遠慮なく終了宣言もできるってもんである(例え、無料とはいえ)。私は、今回の改造を行ったことで、BSchのコードは、ほぼ好きにイジれる、つまり「オレのモノ」になってしまっており、オマケにQtの基本まで身についた。正直、メンテナンス終了も、全然、痛くはない。
最近、オープンソースの利点のひとつに「気に入った環境が死ぬまで自由に使い倒せる」というのがあるんじゃないかと思い始めた。メンテが止まったって、OSが変わったって、少しの手間で、自分でどうにかできる。作者さんには超感謝である。
diff -U 3 qtbsch3v.org/application.cpp qtbsch3v/application.cpp
--- qtbsch3v.org/application.cpp 2006-07-08 15:02:55.000000000 +0900
+++ qtbsch3v/application.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -449,13 +449,16 @@
//statusBar()->addWidget( msg, 4 );
- m_plabelX = new QLabel(" X:0000 ",statusBar());
- m_plabelY = new QLabel(" Y:0000 ",statusBar());
+ m_plabelL = new QLabel(" L:0 ",statusBar());
+ m_plabelX = new QLabel(" X:0000 ",statusBar());
+ m_plabelY = new QLabel(" Y:0000 ",statusBar());
//QFont statusfont( "helvetica", 10 ) ;
+ m_plabelL->setFont( tipfont );
m_plabelX->setFont( tipfont );
m_plabelY->setFont( tipfont );
//m_plabelX->setAlignment(AlignCenter);
//m_plabelY->setAlignment(AlignCenter);
+ statusBar()->addWidget(m_plabelL,0,true);
statusBar()->addWidget(m_plabelX,0,true);
statusBar()->addWidget(m_plabelY,0,true);
@@ -818,6 +821,38 @@
case Qt::Key_C:
ToolCmnt();
break;
+
+ case Qt::Key_Z:
+ AscentLayer();
+ break;
+ case Qt::Key_X:
+ DescentLayer();
+ break;
+
+ case Qt::Key_0:
+ ActiveLayer(0);
+ break;
+ case Qt::Key_1:
+ ActiveLayer(1);
+ break;
+ case Qt::Key_2:
+ ActiveLayer(2);
+ break;
+ case Qt::Key_3:
+ ActiveLayer(3);
+ break;
+ case Qt::Key_4:
+ ActiveLayer(4);
+ break;
+ case Qt::Key_5:
+ ActiveLayer(5);
+ break;
+ case Qt::Key_6:
+ ActiveLayer(6);
+ break;
+ case Qt::Key_7:
+ ActiveLayer(7);
+ break;
}
}
@@ -964,6 +999,29 @@
g_cfg.setInt("VIEW","GRID",bGridOn);
}
+void ApplicationWindow::AscentLayer()
+{
+ int n;
+ m_pXBSchView->setActiveLayer(n = (m_pXBSchView->activeLayer() - 1 + 8) % 8);
+ layerMove(n);
+ m_pXBSchView->RefreshView();
+}
+
+void ApplicationWindow::DescentLayer()
+{
+ int n;
+ m_pXBSchView->setActiveLayer(n = (m_pXBSchView->activeLayer() + 1) % 8);
+ layerMove(n);
+ m_pXBSchView->RefreshView();
+}
+
+void ApplicationWindow::ActiveLayer(int n)
+{
+ m_pXBSchView->setActiveLayer(n);
+ layerMove(n);
+ m_pXBSchView->RefreshView();
+}
+
//TOOL
void ApplicationWindow::ToolSelector()
{
@@ -1036,12 +1094,18 @@
//ビューでのカーソル位置の移動情報を受け取る
+void ApplicationWindow::layerMove(int l)
+{
+ char buff[16];
+ sprintf(buff," L:%d ",l);
+ m_plabelL->setText(buff);
+}
void ApplicationWindow::cursorMove(int x,int y)
{
char buff[16];
- sprintf(buff," X:%04d ",x);
+ sprintf(buff," X:%04d ",x);
m_plabelX->setText(buff);
- sprintf(buff," Y:%04d ",y);
+ sprintf(buff," Y:%04d ",y);
m_plabelY->setText(buff);
}
@@ -1352,13 +1416,15 @@
void ApplicationWindow::SetupLayer()
{
+ int n;
setlayerdlg dlg(this);
dlg.setVisibleLayer(m_pXBSchView->visibleLayer());
dlg.setActiveLayer(m_pXBSchView->activeLayer());
dlg.setDarkenNonActive(m_pXBSchView->darkenNonActiveLayer());
if(dlg.exec()){
m_pXBSchView->setVisibleLayer(dlg.visibleLayer());
- m_pXBSchView->setActiveLayer(dlg.activeLayer());
+ m_pXBSchView->setActiveLayer(n = dlg.activeLayer());
+ layerMove(n);
bool darken = dlg.darkenNonActive();
m_pXBSchView->setDarkenNonActiveLayer(darken);
g_cfg.setInt("VIEW","DARKEN_NONACTIVE_LAYER",(darken ? 1 : 0));
diff -U 3 qtbsch3v.org/application.h qtbsch3v/application.h
--- qtbsch3v.org/application.h 2006-07-08 15:02:55.000000000 +0900
+++ qtbsch3v/application.h 2009-02-09 22:58:58.000000000 +0900
@@ -95,6 +95,11 @@
void ViewZoomIn();
void ViewZoomOut();
void ViewGridOnOff();
+ //WALKLAYER
+ void AscentLayer();
+ void DescentLayer();
+ void ActiveLayer(int n);
+
//TOOL
void ToolSelector();
void ToolDrag();
@@ -119,6 +124,7 @@
void aboutQt();
//ビューでのカーソル位置の移動情報を受け取る
+ void layerMove(int n);
void cursorMove(int x,int y);
void toolChange();
@@ -140,6 +146,7 @@
Q3ToolBar* toolbar;
QString m_filename;
+ QLabel* m_plabelL;
QLabel* m_plabelX;
QLabel* m_plabelY;
diff -U 3 qtbsch3v.org/componentview.cpp qtbsch3v/componentview.cpp
--- qtbsch3v.org/componentview.cpp 2006-07-08 15:02:55.000000000 +0900
+++ qtbsch3v/componentview.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -39,7 +39,7 @@
m_cursorOffset = -1;
QPalette palette;
- palette.setColor(QPalette::Window,Qt::white);
+ palette.setColor(QPalette::Window,Qt::black);
setPalette(palette);
//m_drawframe = false;
//viewport()->setBackgroundColor(QColor("white"));
@@ -116,7 +116,7 @@
void SComponentWidget::mousePressEvent( QMouseEvent * event )
{
- qDebug("SComponentWidget::mousePressEvent X=%d,Y=%d",event->x(),event->y());
+// qDebug("SComponentWidget::mousePressEvent X=%d,Y=%d",event->x(),event->y());
}
diff -U 3 qtbsch3v.org/drawcomponent.cpp qtbsch3v/drawcomponent.cpp
--- qtbsch3v.org/drawcomponent.cpp 2006-07-08 15:02:56.000000000 +0900
+++ qtbsch3v/drawcomponent.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -57,11 +57,11 @@
QColor colText;
switch(nMode & 0xffff){
- case DRAW_ON: colText = QColor("blue"); break;
+ case DRAW_ON: colText = QColor("yellow"); break;
case DRAW_MONO: colText = Qt::color1; break;
- case DRAW_OFF: colText = QColor("white"); break;
+ case DRAW_OFF: colText = QColor("black"); break;
case DRAW_TEMP: colText = QColor("red"); break;
- case DRAW_DARK: colText = QColor("orange"); break;
+ case DRAW_DARK: colText = QColor("blue"); break;
}
SRect rc;
SSize sz;
diff -U 3 qtbsch3v.org/drawcomponentbase.cpp qtbsch3v/drawcomponentbase.cpp
--- qtbsch3v.org/drawcomponentbase.cpp 2006-07-08 15:02:56.000000000 +0900
+++ qtbsch3v/drawcomponentbase.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -490,10 +490,10 @@
switch(nMode & 0xffff){
- case DRAW_ON: col = QColor("DarkGreen"); break;
+ case DRAW_ON: col = QColor("yellow"); break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_OFF: col = QColor("black"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_TEMP:
default:
col = QColor("red");
@@ -596,15 +596,15 @@
switch(nMode & 0xffff){
case DRAW_ON:
if(nType & PIN_TYPE_ZLENG){
- col = QColor("orange");
+ col = QColor("blue");
}else{
- col = QColor("DarkGreen");
+ col = QColor("yellow");
}
break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
+ case DRAW_OFF: col = QColor("black"); break;
case DRAW_TEMP: col = QColor("red"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
default: return;
}
@@ -826,10 +826,10 @@
QColor colText;
switch(nMode & 0xffff){
- case DRAW_ON: colText = QColor("blue"); break;
+ case DRAW_ON: colText = QColor("orange"); break;
case DRAW_MONO: colText = Qt::color1; break;
- case DRAW_OFF: colText = QColor("white"); break;
- case DRAW_DARK: colText = QColor("orange"); break;
+ case DRAW_OFF: colText = QColor("black"); break;
+ case DRAW_DARK: colText = QColor("blue"); break;
case DRAW_TEMP: colText = QColor("red"); break;
// case DRAW_XOR: colText = QColor("red"); break;
}
diff -U 3 qtbsch3v.org/drawobject.cpp qtbsch3v/drawobject.cpp
--- qtbsch3v.org/drawobject.cpp 2006-07-08 15:02:56.000000000 +0900
+++ qtbsch3v/drawobject.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -140,10 +140,10 @@
switch(nMode & 0xffff){
- case DRAW_ON: col = QColor("darkCyan"); break;
+ case DRAW_ON: col = QColor(0, 255, 0); break; // green
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_OFF: col = QColor("black"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_TEMP: col = QColor("red"); break;
}
//p->setRasterOp(op);
@@ -202,10 +202,10 @@
switch(nMode & 0xffff){
- case DRAW_ON: col = QColor("blue"); break;
+ case DRAW_ON: col = QColor("cyan"); break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_OFF: col = QColor("black"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_TEMP:
col = QColor("red");
break;
@@ -270,10 +270,10 @@
QColor col;
switch(nMode & 0xffff){
- case DRAW_ON: col = QColor("blue"); break;
+ case DRAW_ON: col = QColor("cyan"); break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_OFF: col = QColor("black"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_TEMP: col = QColor("red"); break;
}
//p->setRasterOp(Qt::CopyROP);
@@ -308,20 +308,20 @@
switch(nMode & 0xffff){
case DRAW_ON:
- colText = QColor("blue");
- colFrame = QColor("DarkGreen");
+ colText = QColor("cyan");
+ colFrame = QColor("yellow");
break;
case DRAW_MONO:
colText = Qt::color1;
colFrame = Qt::color1;
break;
case DRAW_OFF:
- colText = QColor("white");
- colFrame = QColor("white");
+ colText = QColor("black");
+ colFrame = QColor("black");
break;
case DRAW_DARK:
- colText = QColor("orange");
- colFrame = QColor("orange");
+ colText = QColor("blue");
+ colFrame = QColor("blue");
break;
case DRAW_TEMP:
colText = QColor("red");
@@ -459,11 +459,11 @@
switch(pObj->id()){
case SXBSchObj::ID_WIRE:
- col = QColor("darkCyan");
+ col = QColor(0, 255, 0); // green
break;
case SXBSchObj::ID_ENTRY:
- col = QColor("darkCyan");
+ col = QColor(0, 255, 0); // green
break;
case SXBSchObj::ID_DASH:
#ifdef Q_WS_MACX
@@ -471,13 +471,13 @@
#else
style = Qt::DotLine;
#endif
- col = QColor("black");
+ col = QColor("yellow");
break;
case SXBSchObj::ID_BUS:
case SXBSchObj::ID_BENTRY:
//style = Qt::DotLine;
width=3*m_viewScaleMul/m_viewScale;
- col = QColor("darkGreen");
+ col = QColor("cyan");
break;
default:
return;
@@ -487,8 +487,8 @@
switch(nMode & 0xffff){
case DRAW_ON: break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_OFF: col = QColor("black"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_TEMP: col = QColor("red"); break;
}
diff -U 3 qtbsch3v.org/stdafx.h qtbsch3v/stdafx.h
--- qtbsch3v.org/stdafx.h 2006-07-08 15:02:58.000000000 +0900
+++ qtbsch3v/stdafx.h 2009-02-10 23:31:18.000000000 +0900
@@ -1 +1,5 @@
//dummy header file
+#include <stdlib.h>
+#include <string.h>
+#define INT_MAX 65535
+#define INT_MIN -65535
diff -U 3 qtbsch3v.org/xbschdrawobject.cpp qtbsch3v/xbschdrawobject.cpp
--- qtbsch3v.org/xbschdrawobject.cpp 2006-07-08 15:02:59.000000000 +0900
+++ qtbsch3v/xbschdrawobject.cpp 2009-02-10 23:54:02.000000000 +0900
@@ -519,6 +519,7 @@
SRect srcClipSheet =SRect(rcClipSheet.left(),rcClipSheet.top(),rcClipSheet.width(),rcClipSheet.height());
painter.begin(&m_viewBuffer);
painter.setRenderHint(QPainter::TextAntialiasing);
+ painter.setBackgroundColor(QColor("black"));
painter.translate(-x,-y);
painter.eraseRect(clipx,clipy,clipw,cliph);
@@ -528,9 +529,9 @@
clipy -= y;
// painter.setClipRect(clipx,clipy,clipw,cliph);
SSize size=m_pDoc->SheetSize();
- g_drawFrame(&painter,size,rcClip,QColor("black"),m_viewScale,m_viewScaleMul);
+ g_drawFrame(&painter,size,rcClip,QColor("yellow"),m_viewScale,m_viewScaleMul);
if(m_bDisplayGrid){
- drawGrid(&painter,rcClipSheet,QColor("DarkGreen"));
+ drawGrid(&painter,rcClipSheet,QColor("red"));
}
drawMainXBSchObj(&painter,DRAW_ON,&srcClipSheet,m_fEditHighLight, m_viewScale,m_viewScaleMul);
diff -U 3 qtbsch3v.org/xbschfont.cpp qtbsch3v/xbschfont.cpp
--- qtbsch3v.org/xbschfont.cpp 2006-07-08 15:02:59.000000000 +0900
+++ qtbsch3v/xbschfont.cpp 2009-02-09 22:58:58.000000000 +0900
@@ -107,9 +107,9 @@
QColor col;
switch(nMode & 0xffff){
case DRAW_ON: col = color; break;
- case DRAW_DARK: col = QColor("orange"); break;
+ case DRAW_DARK: col = QColor("blue"); break;
case DRAW_MONO: col = Qt::color1; break;
- case DRAW_OFF: col = QColor("white"); break;
+ case DRAW_OFF: col = QColor("black"); break;
case DRAW_TEMP: col = QColor("red"); break;
}
diff -U 3 qtbsch3v.org/xbschpattern.cpp qtbsch3v/xbschpattern.cpp
--- qtbsch3v.org/xbschpattern.cpp 2006-07-08 15:03:00.000000000 +0900
+++ qtbsch3v/xbschpattern.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -394,6 +394,10 @@
col = color;
break;
+ case DRAW_DARK:
+ col = color;
+ break;
+
}
x=x*scaleMul / scale - scaleMul / (scale*2);
diff -U 3 qtbsch3v.org/xbschview.cpp qtbsch3v/xbschview.cpp
--- qtbsch3v.org/xbschview.cpp 2006-07-08 15:03:00.000000000 +0900
+++ qtbsch3v/xbschview.cpp 2009-02-10 23:31:18.000000000 +0900
@@ -1026,6 +1026,7 @@
// pObj->setP1(ptSnap);
// drawJunction(&painter,pObj,DRAW_ON);
pObj = m_pCursorObj->duplicate();
+ pObj->setLayer(m_pDoc->editLayer());
//drawXBSchObj(ppainter,pObj,DRAW_ON,NULL);
m_pDoc->addSelect(pObj);
m_pDoc->resetSelect();
@@ -1161,6 +1162,7 @@
pComment->setFontUnderline(dlg->font().underline());
pComment->setFontStrikeOut(dlg->font().strikeOut());
pComment->setSelection(SXBSchObj::SELECT_ALL);
+ pComment->setLayer(m_pDoc->editLayer());
m_pDoc->addSelect(pComment);
//g_cfg.setString("Font","Name",pComment->fontName());
//g_cfg.setInt("Font","Size",pComment->fontSize());
@@ -1195,6 +1197,7 @@
pLabel->setP1(SPoint(point.x(),point.y()));
pLabel->setText(dlg->text().latin1());
pLabel->setSelection(SXBSchObj::SELECT_ALL);
+ pLabel->setLayer(m_pDoc->editLayer());
m_pDoc->addSelect(pLabel);
delete dlg;
return true;
@@ -1223,6 +1226,7 @@
pTag->setText(pc);
pTag->setTagType(dlg->type());
pTag->setSelection(SXBSchObj::SELECT_ALL);
+ pTag->setLayer(m_pDoc->editLayer());
m_pDoc->addSelect(pTag);
//}
delete dlg;
@@ -1252,6 +1256,7 @@
pComp->setName(pCompInfoIndex->name());
pComp->setRefnum(pCompInfoIndex->number());
pComp->setSelection(SXBSchObj::SELECT_ALL);
+ pComp->setLayer(m_pDoc->editLayer());
m_pDoc->addSelect(pComp);
delete dlg;
return true;
@@ -1369,6 +1374,7 @@
}else{
pObj1->setP1(SPoint(ptStart.x(),ptStart.y()));
pObj1->setP2(SPoint(passPoint.x(),passPoint.y()));
+ pObj1->setLayer(m_pDoc->editLayer());
// drawXBSchObj(&painter,pObj1,DRAW_ON,NULL);
m_pDoc->addSelect(pObj1);
m_pDoc->resetSelect();
@@ -1380,6 +1386,7 @@
}else{
pObj2->setP1(SPoint(passPoint.x(),passPoint.y()));
pObj2->setP2(SPoint(ptEnd.x(),ptEnd.y()));
+ pObj2->setLayer(m_pDoc->editLayer());
// drawXBSchObj(&painter,pObj2,DRAW_ON,NULL);
m_pDoc->addSelect(pObj2);
m_pDoc->resetSelect();