Skip to content

Commit

Permalink
changes to DrishtiPaint and surface visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayLimaye committed Mar 29, 2022
1 parent aed29ca commit 68fc5a2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 55 deletions.
33 changes: 29 additions & 4 deletions drishti/meshinfowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,34 @@ MeshInfoWidget::sectionClicked(int col)

if (col == 3) // colormap
{
emit processCommand("colormap");
QList<int> selIdx;
for(int i=0; i<m_meshList->rowCount(); i++)
{
QTableWidgetItem *wi = m_meshList->item(i, 0);
if (wi->isSelected())
{
selIdx << i;
}
}

if (selIdx.count() == 1)
{
int row = selIdx[0];
QTableWidgetItem *wi;
wi = m_meshList->item(row, col);
QColor pcolor = wi->background().color();
QColor color = DColorDialog::getColor(pcolor);
if (color.isValid())
{
wi->setBackground(QBrush(color));
wi->setForeground(QBrush(color));
emit colorChanged(color);
}
}
else if (selIdx.count() > 1)
emit processCommand(selIdx, "colormap");
else
emit processCommand("colormap");
return;
}

Expand Down Expand Up @@ -659,7 +686,6 @@ MeshInfoWidget::removeMesh()
for(int i=0; i<m_meshList->rowCount(); i++)
{
QTableWidgetItem *wi = m_meshList->item(i, 0);
QColor bgcol = wi->background().color();
if (wi->isSelected())
selIdx << i;
}
Expand Down Expand Up @@ -792,11 +818,10 @@ MeshInfoWidget::on_Command_pressed()
for(int i=0; i<m_meshList->rowCount(); i++)
{
QTableWidgetItem *wi = m_meshList->item(i, 0);
QColor bgcol = wi->background().color();
if (wi->isSelected())
selIdx << i;
}

int row = -1;

if (selIdx.count() == 1)
Expand Down
52 changes: 26 additions & 26 deletions drishti/trisets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,26 +1643,6 @@ Trisets::processCommand(int idx, QString cmd)
return;
}

if (list[0].contains("explode"))
{
Vec damp = Vec(1,1,1);
if (list[0] == "explodex") damp = Vec(1, 0, 0);
if (list[0] == "explodey") damp = Vec(0, 1, 0);
if (list[0] == "explodez") damp = Vec(0, 0, 1);
if (list[0] == "explodexy") damp = Vec(1, 1, 0);
if (list[0] == "explodexz") damp = Vec(0, 1, 1);
if (list[0] == "explodeyz") damp = Vec(0, 1, 1);

float rad = 1;
if (list.count() > 1)
rad = list[1].toFloat(&ok);

QList<int> indices;
indices << idx;
setExplode(indices, rad, damp);
return;
}

}

// Multiple Mesh Command
Expand All @@ -1674,7 +1654,7 @@ Trisets::processCommand(QList<int> indices, QString cmd)
bool ok;
cmd = cmd.toLower();
QStringList list = cmd.split(" ", QString::SkipEmptyParts);

//------------------
// reorder groups
if (list[0] == "movebottom")
Expand Down Expand Up @@ -1879,7 +1859,16 @@ Trisets::processCommand(QList<int> indices, QString cmd)
if (list.count() > 1)
rad = list[1].toFloat(&ok);

setExplode(indices, rad, damp);
float ex,ey,ez;
ex = ey = ez = 0;
if (list.count() == 5)
{
ex = list[2].toFloat(&ok);
ey = list[3].toFloat(&ok);
ez = list[4].toFloat(&ok);
}

setExplode(indices, rad, damp, Vec(ex,ey,ez));
return;
}

Expand Down Expand Up @@ -2047,7 +2036,16 @@ Trisets::processCommand(QString cmd)
if (list.count() > 1)
rad = list[1].toFloat(&ok);

setExplode(rad, damp);
float ex,ey,ez;
ex = ey = ez = 0;
if (list.count() == 5)
{
ex = list[2].toFloat(&ok);
ey = list[3].toFloat(&ok);
ez = list[4].toFloat(&ok);
}

setExplode(rad, damp, Vec(ex,ey,ez));
return;
}

Expand Down Expand Up @@ -3117,7 +3115,7 @@ Trisets::sendParametersToMenu()
}

void
Trisets::setExplode(float rad, Vec damp)
Trisets::setExplode(float rad, Vec damp, Vec eCen)
{
Vec centroid = Vec(0,0,0);
for (int i=0; i<m_trisets.count(); i++)
Expand All @@ -3130,12 +3128,13 @@ Trisets::setExplode(float rad, Vec damp)
Vec dr = m_trisets[i]->centroid() - centroid;
dr = VECPRODUCT(dr, damp);
dr *= rad;
dr += eCen;
m_trisets[i]->setPosition(dr);
}
}

void
Trisets::setExplode(QList<int> indices, float rad, Vec damp)
Trisets::setExplode(QList<int> indices, float rad, Vec damp, Vec eCen)
{
Vec centroid = Vec(0,0,0);
for (int i=0; i<indices.count(); i++)
Expand All @@ -3147,11 +3146,12 @@ Trisets::setExplode(QList<int> indices, float rad, Vec damp)

for (int i=0; i<m_trisets.count(); i++)
{
if (!indices.contains(i))
if (indices.contains(i))
{
Vec dr = m_trisets[i]->centroid() - centroid;
dr = VECPRODUCT(dr, damp);
dr *= rad;
dr += eCen;
m_trisets[i]->setPosition(dr);
}
}
Expand Down
4 changes: 2 additions & 2 deletions drishti/trisets.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class Trisets : public QObject

QStringList getMeshList();

void setExplode(float, Vec);
void setExplode(QList<int>, float, Vec);
void setExplode(float, Vec, Vec);
void setExplode(QList<int>, float, Vec, Vec);

public slots :
void setShow(int, bool);
Expand Down
36 changes: 18 additions & 18 deletions tools/paint/drishtipaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7798,18 +7798,18 @@ DrishtiPaint::on_actionHelp2D_triggered()
help += "\n";
help += "Script Folder : Location to store scripts to be call from Command.\n";
help += "Command : A command promt is provided to run scripts from Script Folder.\n";
help += " Script arguments are provided from the dialog adjoining the\n";
help += " command prompt panel. Each script is stored in its own directory.\n";
help += " Each script directory contains a .json file which exposes the\n";
help += " argument list to the user to modify.\n";
help += " \n";
help += " %DIR% parameter specifies the directory where volume and mask files\n";
help += " reside.\n";
help += " Two arguments are provided by default to the script -\n";
help += " volume=<volume file name> and\n";
help += " mask=<mask file name>\n";
help += " The argument output=<output file name> is also expected.\n";
help += " no need to specify directory for output.\n";
help += " output file will be stored in the same folder as volume and mask.\n";
help += " For example : <script name> output=<file name> is enough\n";
help += " (volume and mask arguments are added by default).\n";
help += " volume=<volume file name> and mask=<mask file name>\n";
help += "\n";
help += " drishtiML.py output=test.raw\n";

QMessageBox::information(0, "Help for 2D boxes", help);
QMessageBox::about(0, "Help for 2D boxes", help);
}

void
Expand All @@ -7830,16 +7830,16 @@ DrishtiPaint::on_actionHelp3D_triggered()
help += "\n";
help += "Script Folder : Location to store scripts to be call from Command.\n";
help += "Command : A command promt is provided to run scripts from Script Folder.\n";
help += " Script arguments are provided from the dialog adjoining the\n";
help += " command prompt panel. Each script is stored in its own directory.\n";
help += " Each script directory contains a .json file which exposes the\n";
help += " argument list to the user to modify.\n";
help += " \n";
help += " %DIR% parameter specifies the directory where volume and mask files\n";
help += " reside.\n";
help += " Two arguments are provided by default to the script -\n";
help += " volume=<volume file name> and\n";
help += " mask=<mask file name>\n";
help += " The argument output=<output file name> is also expected.\n";
help += " no need to specify directory for output.\n";
help += " output file will be stored in the same folder as volume and mask.\n";
help += " For example : <script name> output=<file name> is enough\n";
help += " (volume and mask arguments are added by default).\n";
help += " volume=<volume file name> and mask=<mask file name>\n";
help += "\n";
help += " drishtiML.py output=test.raw\n";

QMessageBox::information(0, "Help for 3D boxes", help);
QMessageBox::about(0, "Help for 3D boxes", help);
}
3 changes: 2 additions & 1 deletion tools/paint/pywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ PyWidget::setFilename(QString volfile)
m_plainTextEdit->appendPlainText(m_fileName);
m_plainTextEdit->appendPlainText(m_maskName+"\n");


m_menu->addRow("%DIR%", QFileInfo(m_fileName).absolutePath());
m_menu->addRow("volume", "%DIR%/"+QFileInfo(m_fileName).fileName());
m_menu->addRow("mask", "%DIR%/"+QFileInfo(m_maskName).fileName());
Expand Down Expand Up @@ -76,9 +75,11 @@ PyWidget::PyWidget(QWidget *parent)

m_plainTextEdit = new QPlainTextEdit(this);
m_plainTextEdit->setReadOnly(true);
m_plainTextEdit->setFont(QFont("MS Reference Sans Serif", 12));

m_lineEdit = new QLineEdit(this);
m_lineEdit->setClearButtonEnabled(true);
m_lineEdit->setFont(QFont("MS Reference Sans Serif", 12));

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(m_plainTextEdit);
Expand Down
8 changes: 4 additions & 4 deletions tools/paint/pywidgetmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ PyWidgetMenu::PyWidgetMenu(QWidget *parent) :
ui.setupUi(this);
setStyleSheet("QWidget{background:gainsboro;}");
ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.tableWidget->setFont(QFont("MS Reference Sans Serif", 10));
ui.scriptList->setFont(QFont("MS Reference Sans Serif", 10));
ui.tableWidget->setFont(QFont("MS Reference Sans Serif", 12));
ui.scriptList->setFont(QFont("MS Reference Sans Serif", 12));

connect(ui.scriptList, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_scriptChanged(int)));
Expand Down Expand Up @@ -193,7 +193,7 @@ PyWidgetMenu::addRow(QString key, QString value)
}

ui.tableWidget->resizeColumnsToContents();
ui.tableWidget->resizeRowsToContents();
//ui.tableWidget->resizeRowsToContents();
}

void
Expand Down Expand Up @@ -229,7 +229,7 @@ PyWidgetMenu::getData()
for (int i=0; i<ui.tableWidget->rowCount(); i++)
{
kv << ui.tableWidget->item(i,0)->text();
kv << ui.tableWidget->item(i,1)->text();
kv << ui.tableWidget->item(i,1)->text();
}
return kv;
}
Expand Down

0 comments on commit 68fc5a2

Please sign in to comment.