mirror of
https://github.com/alsa-project/alsa-tools.git
synced 2025-10-29 05:40:25 -04:00
Various fixes to qlo10k1
Various fixes by Tim <terminator356@users.sourceforge.net>: - ld10k1 0.1.8p1 recommended for best operation. - Fixed link disconnect bug. - Now remembers last file open/save dir. - Now unused IO/FX do not disappear upon refresh. - Refresh/redraw fixups.
This commit is contained in:
parent
700edf08b4
commit
8d95c04c7e
14 changed files with 221 additions and 48 deletions
|
|
@ -2,3 +2,4 @@ Peter Zubaj <pzad@pobox.sk>
|
|||
|
||||
Contributors:
|
||||
Eduardo García-Mádico Portabella <informatica@eurogaran.com>
|
||||
Tim <terminator356@users.sourceforge.net>
|
||||
|
|
@ -1,3 +1,10 @@
|
|||
0.1.2p1
|
||||
- By Tim...
|
||||
- ld10k1 0.1.8p1 recommended for best operation.
|
||||
- Fixed link disconnect bug.
|
||||
- Now remembers last file open/save dir.
|
||||
- Now unused IO/FX do not disappear upon refresh.
|
||||
- Refresh/redraw fixups.
|
||||
0.1.2
|
||||
- ld10k1 0.1.8 required
|
||||
- Colors and better object positioning - Eduardo García-Mádico Portabella
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
AC_INIT(src/main.cpp)
|
||||
AM_INIT_AUTOMAKE(qlo10k1, 0.1.2)
|
||||
AM_INIT_AUTOMAKE(qlo10k1, 0.1.2p1)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_PROG_CXX
|
||||
AC_PROG_LD
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@
|
|||
#include "structure_patch.h"
|
||||
#include "strparam.h"
|
||||
|
||||
QString gLastFileDir;
|
||||
|
||||
class PatchesListViewItem : public QListViewItem
|
||||
{
|
||||
public:
|
||||
|
|
@ -121,6 +123,12 @@ MainWnd::~MainWnd()
|
|||
delete cardGlobal;
|
||||
}
|
||||
|
||||
void MainWnd::closeEvent(QCloseEvent* ce)
|
||||
{
|
||||
saveSettings();
|
||||
ce->accept();
|
||||
}
|
||||
|
||||
void MainWnd::tabMainCurrentChanged(QWidget *tab)
|
||||
{
|
||||
if (!CurrentCard)
|
||||
|
|
@ -163,6 +171,7 @@ void MainWnd::patchesUpdateText()
|
|||
|
||||
void MainWnd::menuQuitActivated(int /*id*/)
|
||||
{
|
||||
saveSettings();
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
|
@ -171,15 +180,17 @@ void MainWnd::menuLoadDSPConfigActivated(int id)
|
|||
if (!CurrentCard)
|
||||
return;
|
||||
QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE);
|
||||
fd->setDir(gLastFileDir);
|
||||
fd->setMode(QFileDialog::ExistingFile);
|
||||
fd->setFilter("DSP config (*.ld10k1)");
|
||||
fd->setCaption("Save DSP config");
|
||||
int err = 0;
|
||||
|
||||
QString fileName;
|
||||
if (fd->exec() == QDialog::Accepted)
|
||||
if (fd->exec() == QDialog::Accepted)
|
||||
{
|
||||
fileName = fd->selectedFile();
|
||||
fileName = fd->selectedFile();
|
||||
gLastFileDir = fd->dirPath();
|
||||
delete fd;
|
||||
|
||||
LD10k1DspFile *dc = NULL;
|
||||
|
|
@ -205,15 +216,17 @@ void MainWnd::menuSaveDSPConfigActivated(int id)
|
|||
if (!CurrentCard)
|
||||
return;
|
||||
QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE);
|
||||
fd->setDir(gLastFileDir);
|
||||
fd->setMode(QFileDialog::AnyFile);
|
||||
fd->setFilter("DSP config (*.ld10k1)");
|
||||
fd->setCaption("Save DSP config");
|
||||
int err = 0;
|
||||
|
||||
QString fileName;
|
||||
if (fd->exec() == QDialog::Accepted)
|
||||
if (fd->exec() == QDialog::Accepted)
|
||||
{
|
||||
fileName = fd->selectedFile();
|
||||
gLastFileDir = fd->dirPath();
|
||||
delete fd;
|
||||
|
||||
if (!fileName.endsWith(".ld10k1"))
|
||||
|
|
@ -379,17 +392,26 @@ void MainWnd::loadClicked()
|
|||
{
|
||||
QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE);
|
||||
fd->setMode(QFileDialog::ExistingFile);
|
||||
fd->setFilter("Patches (*.emu10k1 *.ld10k1)");
|
||||
QStringList filterlist;
|
||||
filterlist << QString( "as10k1 Patch files (*.bin *.as10k1 *.emu10k1)" );
|
||||
filterlist << QString( "ld10k1 Native effect files (*.ld10k1)" );
|
||||
filterlist << QString( "All Files (*)" );
|
||||
QString filters = filterlist.join( ";;" );
|
||||
fd->setFilters( filters );
|
||||
|
||||
fd->setDir(gLastFileDir);
|
||||
fd->setCaption("Load patch");
|
||||
int err = 0;
|
||||
|
||||
QString fileName;
|
||||
if ( fd->exec() == QDialog::Accepted )
|
||||
if ( fd->exec() == QDialog::Accepted )
|
||||
{
|
||||
fileName = fd->selectedFile();
|
||||
gLastFileDir = fd->dirPath();
|
||||
delete fd;
|
||||
LD10k1File *ldfile = NULL;
|
||||
if (fileName.endsWith(".emu10k1"))
|
||||
/* Try loading as an ld10k1 file first. */
|
||||
if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0)
|
||||
{
|
||||
EMU10k1File *emufile = NULL;
|
||||
if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0)
|
||||
|
|
@ -417,13 +439,6 @@ void MainWnd::loadClicked()
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) {
|
||||
QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LoadPatchDlg d(CurrentCard, fileName, ldfile);
|
||||
|
||||
|
|
@ -480,6 +495,7 @@ void MainWnd::saveSettings()
|
|||
settings.writeEntry("/Version", "0.0.1");
|
||||
settings.writeEntry("/RepDirSystem", cardGlobal->RepDirSystem);
|
||||
settings.writeEntry("/RepDirUser", cardGlobal->RepDirUser);
|
||||
settings.writeEntry("/LastDir", gLastFileDir);
|
||||
|
||||
// first save cards
|
||||
settings.beginGroup("/Cards");
|
||||
|
|
@ -510,6 +526,7 @@ void MainWnd::loadSettings()
|
|||
// settings doesn't exists
|
||||
cardGlobal->RepDirSystem = "";
|
||||
cardGlobal->RepDirUser = "";
|
||||
gLastFileDir = "./";
|
||||
|
||||
CardParam *card = new CardParam();
|
||||
card->CardName = "Default card";
|
||||
|
|
@ -524,6 +541,7 @@ void MainWnd::loadSettings()
|
|||
{
|
||||
cardGlobal->RepDirSystem = settings.readEntry("/RepDirSystem", "");
|
||||
cardGlobal->RepDirUser = settings.readEntry("/RepDirUser", "");
|
||||
gLastFileDir = settings.readEntry("/LastDir", "./");
|
||||
|
||||
settings.beginGroup("/Cards");
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ public:
|
|||
void loadSettings();
|
||||
|
||||
void patchesUpdateText();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
public slots:
|
||||
// menu
|
||||
void menuLoadDSPConfigActivated(int id);
|
||||
|
|
|
|||
|
|
@ -62,10 +62,26 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t)
|
|||
|
||||
connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked()));
|
||||
connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
||||
}
|
||||
|
||||
int NewIODlg::init()
|
||||
{
|
||||
int err;
|
||||
|
||||
QString title;
|
||||
QString columnTitle;
|
||||
|
||||
int cnt;
|
||||
if (dt == In)
|
||||
err = global->Card->getInputCount(&cnt);
|
||||
else if (dt == Out)
|
||||
err = global->Card->getOutputCount(&cnt);
|
||||
else
|
||||
err = global->Card->getFXCount(&cnt);
|
||||
|
||||
if(err < 0)
|
||||
return err;
|
||||
|
||||
switch (dt)
|
||||
{
|
||||
case In:
|
||||
|
|
@ -83,17 +99,9 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t)
|
|||
}
|
||||
|
||||
IOListViewItem *after = NULL;
|
||||
int cnt;
|
||||
|
||||
lvIOs->clear();
|
||||
|
||||
if (dt == In)
|
||||
global->Card->getInputCount(&cnt);
|
||||
else if (dt == Out)
|
||||
global->Card->getOutputCount(&cnt);
|
||||
else
|
||||
global->Card->getFXCount(&cnt);
|
||||
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
QString ioname;
|
||||
|
|
@ -109,12 +117,14 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t)
|
|||
if (!used)
|
||||
{
|
||||
if (dt == In)
|
||||
global->Card->getInput(i, ioname);
|
||||
err = global->Card->getInput(i, ioname);
|
||||
else if (dt == Out)
|
||||
global->Card->getOutput(i, ioname);
|
||||
err = global->Card->getOutput(i, ioname);
|
||||
else
|
||||
global->Card->getFX(i, ioname);
|
||||
err = global->Card->getFX(i, ioname);
|
||||
|
||||
if(err < 0)
|
||||
goto Error;
|
||||
|
||||
if (after)
|
||||
after = new IOListViewItem(i, ioname, lvIOs, after);
|
||||
|
|
@ -127,9 +137,14 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t)
|
|||
lvIOs->setColumnText(1, columnTitle);
|
||||
|
||||
connect(lvIOs, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(ioSelectionChanged(QListViewItem *)));
|
||||
|
||||
return 0;
|
||||
|
||||
Error:
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
void NewIODlg::okClicked()
|
||||
{
|
||||
done(Accepted);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ private:
|
|||
QString name;
|
||||
public:
|
||||
NewIODlg(StrGlobal *glob, DlgType t);
|
||||
|
||||
int init();
|
||||
|
||||
StrIOBase *getNewIO();
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ void PreferencesDlg::okClicked()
|
|||
for (i = 0; i < cards.count(); i++)
|
||||
global->Cards.append(new CardParam(cards.at(i)));
|
||||
|
||||
repDirSystem = leRepSystem->text();
|
||||
repDirUser = leRepUser->text();
|
||||
global->RepDirSystem = repDirSystem;
|
||||
global->RepDirUser = repDirUser;
|
||||
|
||||
|
|
|
|||
|
|
@ -888,7 +888,7 @@ void RoutingWidget::putNewObjectAt(int xp, int yp)
|
|||
|
||||
drawing->updateContents();
|
||||
|
||||
modeNormalClicked();
|
||||
//modeNormalClicked();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,16 @@
|
|||
#include "strglobal.h"
|
||||
#include "ld10k1file.h"
|
||||
|
||||
extern QString gLastFileDir;
|
||||
|
||||
void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int xp, int yp, int mxp, int myp)
|
||||
{
|
||||
QPopupMenu *contextMenu = new QPopupMenu();
|
||||
|
||||
enum Action {Refresh, ClearDSP, Delete, Rename, Disconnect, DelPoint, AddPoint, Connect, Save};
|
||||
|
||||
int rn = -1;
|
||||
|
||||
if (mm == MenuNone)
|
||||
{
|
||||
contextMenu->insertItem(tr("&Refresh"), Refresh);
|
||||
|
|
@ -73,7 +77,24 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
else if (pn < 0)
|
||||
contextMenu->insertItem(tr("A&dd point"), AddPoint);
|
||||
|
||||
contextMenu->insertItem(tr("D&isconnect"), Disconnect);
|
||||
if (item->type() == RSItemBaseWithType::Link)
|
||||
{
|
||||
StrLink *lnk = (StrLink *)item;
|
||||
|
||||
rn = lnk->getRouteNumFromPoint(xp, yp);
|
||||
if(rn >= 0)
|
||||
{
|
||||
RSItemIO *io = NULL;
|
||||
RSItemBaseWithType *own = NULL;
|
||||
io = lnk->getRoutePoint(rn);
|
||||
if(io)
|
||||
{
|
||||
own = (RSItemBaseWithType*)io->getOwner();
|
||||
if(own && (own->type() == RSItemBaseWithType::Patch))
|
||||
contextMenu->insertItem(tr("D&isconnect"), Disconnect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contextMenu->insertSeparator();
|
||||
contextMenu->insertItem(tr("&Delete"), Delete);
|
||||
|
|
@ -128,6 +149,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
else if (id == Delete)
|
||||
{
|
||||
drawing->deleteAllSelected();
|
||||
structure->loadFromLD();
|
||||
}
|
||||
else if (id == Connect)
|
||||
{
|
||||
|
|
@ -138,7 +160,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
}
|
||||
else if (id == Disconnect)
|
||||
{
|
||||
RSItemIO *io = NULL;
|
||||
RSItemIO *io = NULL;
|
||||
if (item->type() == RSItemBaseWithType::Patch)
|
||||
{
|
||||
int err;
|
||||
|
|
@ -150,7 +172,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
l->updateContents(drawing, getZoomLevel());
|
||||
|
||||
if ((err = structure->disconnectFromLink(io)) < 0)
|
||||
QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err)));
|
||||
QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -164,15 +186,41 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
StrOutput *out = (StrOutput *)item;
|
||||
io = out->getIO(false, 0);
|
||||
}
|
||||
if (item->type() == RSItemBaseWithType::FX)
|
||||
else if (item->type() == RSItemBaseWithType::FX)
|
||||
{
|
||||
StrFX *fx = (StrFX *)item;
|
||||
io = fx->getIO(true, 0);
|
||||
}
|
||||
|
||||
StrLink *l = io->getConnectedTo();
|
||||
structure->deleteOneLink(l);
|
||||
drawing->updateContents();
|
||||
if(io)
|
||||
{
|
||||
StrLink *l = io->getConnectedTo();
|
||||
structure->deleteOneLink(l);
|
||||
structure->loadFromLD();
|
||||
drawing->updateContents();
|
||||
}
|
||||
else if (item->type() == RSItemBaseWithType::Link)
|
||||
{
|
||||
StrLink *lnk = (StrLink *)item;
|
||||
|
||||
if(rn >= 0)
|
||||
{
|
||||
io = lnk->getRoutePoint(rn);
|
||||
if(io)
|
||||
{
|
||||
RSItemBaseWithType *own = NULL;
|
||||
own = (RSItemBaseWithType*)io->getOwner();
|
||||
if(own && (own->type() == RSItemBaseWithType::Patch))
|
||||
{
|
||||
int err;
|
||||
if ((err = structure->disconnectFromLink(io)) < 0)
|
||||
QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err)));
|
||||
|
||||
drawing->updateContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (id == ClearDSP)
|
||||
|
|
@ -192,20 +240,22 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int
|
|||
|
||||
QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE);
|
||||
fd->setMode(QFileDialog::AnyFile);
|
||||
fd->setFilter("Patch (*.ld10k1)");
|
||||
fd->setFilter("ld10k1 Native effect files (*.ld10k1)");
|
||||
fd->setCaption("Save patch");
|
||||
fd->setDir(gLastFileDir);
|
||||
|
||||
QString fileName;
|
||||
if (fd->exec() == QDialog::Accepted)
|
||||
{
|
||||
fileName = fd->selectedFile();
|
||||
gLastFileDir = fd->dirPath();
|
||||
delete fd;
|
||||
|
||||
if (!fileName.endsWith(".ld10k1"))
|
||||
fileName += ".ld10k1";
|
||||
if (QFile::exists(fileName))
|
||||
{
|
||||
if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exist. Overwite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
|
||||
if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exists. Overwrite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "loadpatchdialog.h"
|
||||
#include "transformpatchdialog.h"
|
||||
|
||||
extern QString gLastFileDir;
|
||||
|
||||
RSItemBaseWithType *RoutingWidget::createNewIO(EditMode em)
|
||||
{
|
||||
|
|
@ -54,6 +55,14 @@ RSItemBaseWithType *RoutingWidget::createNewIO(EditMode em)
|
|||
|
||||
NewIODlg d(structure, t);
|
||||
|
||||
int err;
|
||||
err = d.init();
|
||||
if(err < 0)
|
||||
{
|
||||
QMessageBox::critical(0, APP_NAME, QString("Error creating new IO dialog\n(ld10k1 error:%1)").arg(structure->errorStr(err)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (d.exec() == QDialog::Accepted)
|
||||
return d.getNewIO();
|
||||
else
|
||||
|
|
@ -64,19 +73,28 @@ RSItemBaseWithType *RoutingWidget::createNewPatch()
|
|||
{
|
||||
QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE);
|
||||
fd->setMode(QFileDialog::ExistingFile);
|
||||
fd->setFilter("Patches (*.emu10k1 *.ld10k1)");
|
||||
QStringList filterlist;
|
||||
filterlist << QString( "as10k1 Patch files (*.bin *.as10k1 *.emu10k1)" );
|
||||
filterlist << QString( "ld10k1 Native effect files (*.ld10k1)" );
|
||||
filterlist << QString( "All Files (*)" );
|
||||
QString filters = filterlist.join( ";;" );
|
||||
fd->setFilters( filters );
|
||||
fd->setDir(gLastFileDir);
|
||||
|
||||
fd->setCaption("Load patch");
|
||||
|
||||
StrPatch *loaded = NULL;
|
||||
int err;
|
||||
|
||||
QString fileName;
|
||||
if ( fd->exec() == QDialog::Accepted )
|
||||
if ( fd->exec() == QDialog::Accepted )
|
||||
{
|
||||
fileName = fd->selectedFile();
|
||||
gLastFileDir = fd->dirPath();
|
||||
delete fd;
|
||||
|
||||
LD10k1File *ldfile = NULL;
|
||||
if (fileName.endsWith(".emu10k1"))
|
||||
if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0)
|
||||
{
|
||||
EMU10k1File *emufile = NULL;
|
||||
if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0)
|
||||
|
|
@ -104,13 +122,6 @@ RSItemBaseWithType *RoutingWidget::createNewPatch()
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) {
|
||||
QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(structure->errorStr(err)));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
LoadPatchDlg d(structure, fileName, ldfile);
|
||||
|
||||
|
|
@ -262,7 +273,7 @@ void RoutingDrawWidget::connectLinkDrag(int xp, int yp, int mxp, int myp)
|
|||
}
|
||||
|
||||
stopLinkDrag();
|
||||
parent->modeNormalClicked();
|
||||
//parent->modeNormalClicked();
|
||||
}
|
||||
|
||||
delete contextMenu;
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ int StrGlobal::loadFromLD(void)
|
|||
fx->setName(ioname);
|
||||
fx->setFlagChanged(true);
|
||||
}
|
||||
// Don't make unconnected IO/FX disappear.
|
||||
fx->setFlagUsed(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -154,6 +156,7 @@ int StrGlobal::loadFromLD(void)
|
|||
in->setName(ioname);
|
||||
in->setFlagChanged(true);
|
||||
}
|
||||
in->setFlagUsed(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -179,6 +182,7 @@ int StrGlobal::loadFromLD(void)
|
|||
out->setName(ioname);
|
||||
out->setFlagChanged(true);
|
||||
}
|
||||
out->setFlagUsed(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@ void StrLink::updateOneSegment(QScrollView *sv, int r, float zoom)
|
|||
}
|
||||
}
|
||||
|
||||
// Determines whether a point is close enough to a another point, within LINK_SELECT_WH.
|
||||
bool StrLink::containsPointPoint(QPoint &p, int xp, int yp)
|
||||
{
|
||||
QRect r(p.x() - LINK_SELECT_WH / 2, p.y() - LINK_SELECT_WH / 2,
|
||||
|
|
@ -399,6 +400,7 @@ bool StrLink::containsPointPoint(QPoint &p, int xp, int yp)
|
|||
return r.contains(xp, yp);
|
||||
}
|
||||
|
||||
// Determines whether a point is on a line segment.
|
||||
bool StrLink::containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp)
|
||||
{
|
||||
QRect r(p1, p2);
|
||||
|
|
@ -638,3 +640,55 @@ bool StrLink::delSegmentPoint(int num)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns route number which segment containing point leads to, else -1
|
||||
int StrLink::getRouteNumFromPoint(int xp, int yp)
|
||||
{
|
||||
int i;
|
||||
unsigned j;
|
||||
|
||||
if (xp < x() || xp > x() + width() ||
|
||||
yp < y() || yp > y() + height())
|
||||
return -1;
|
||||
|
||||
if (useMixPoint)
|
||||
{
|
||||
if (containsPointPoint(mixPoint, xp, yp))
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++)
|
||||
{
|
||||
if (routes[i])
|
||||
{
|
||||
QPoint fp = routesEndPoints[i];
|
||||
if (containsPointPoint(fp, xp, yp))
|
||||
return i;
|
||||
|
||||
for (j = 0; j < routesPoints[i].count(); j++)
|
||||
{
|
||||
QPoint tmpp = routesPoints[i][j];
|
||||
|
||||
if (containsPointPoint(tmpp, xp, yp))
|
||||
return i;
|
||||
|
||||
if (containsPointSegment(fp, tmpp, xp, yp))
|
||||
return i;
|
||||
fp = tmpp;
|
||||
}
|
||||
|
||||
if (useMixPoint)
|
||||
{
|
||||
if (containsPointSegment(fp, mixPoint, xp, yp))
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (containsPointSegment(fp, routesEndPoints[0], xp, yp))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,13 @@ private:
|
|||
RSItemIO *routes[POINTINFO_MAX_CONN_PER_POINT + 1];
|
||||
|
||||
QValueList <QPoint> routesPoints[POINTINFO_MAX_CONN_PER_POINT + 1];
|
||||
QPoint routesEndPoints[POINTINFO_MAX_CONN_PER_POINT + 1];
|
||||
QPoint routesEndPoints[POINTINFO_MAX_CONN_PER_POINT + 1];
|
||||
|
||||
bool useMixPoint;
|
||||
QPoint mixPoint;
|
||||
// Determines whether a point is close enough to a another point, within LINK_SELECT_WH.
|
||||
bool containsPointPoint(QPoint &p, int xp, int yp);
|
||||
// Determines whether a point is on a line segment.
|
||||
bool containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp);
|
||||
public:
|
||||
StrLink(int id, LinkType t);
|
||||
|
|
@ -73,6 +75,9 @@ public:
|
|||
void setRoutePoint(int r, RSItemIO *ri);
|
||||
void clearRoutesPoints(int r);
|
||||
|
||||
// Returns route number which segment containing point leads to, else -1
|
||||
int getRouteNumFromPoint(int xp, int yp);
|
||||
|
||||
virtual void calcSize();
|
||||
virtual void draw(DrawingParams *dp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue