Skip to content

Commit

Permalink
Merge branch 'febiostudio3' of github.com:febiosoftware/FEBioStudio i…
Browse files Browse the repository at this point in the history
…nto febiostudio3
  • Loading branch information
michaelrossherron committed Jan 30, 2025
2 parents b6a29ed + 9b2f0fc commit 6eb45b8
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FEBioStudio/DlgSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class CUIProps : public CDataPropertyList

void SetPropertyValue(int i, const QVariant& v) override
{
if (i == 3)
if (i == 2)
{
if (QMessageBox::question(m_dlg, "FEBio Studio", "Are you sure you want to clear all the recent files list.\nThis can not be undone!") == QMessageBox::Yes)
{
Expand Down
50 changes: 50 additions & 0 deletions FEBioStudio/ModelPropsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,56 @@ void CModelPropsPanel::on_select2_clearButtonClicked() { clearSelection(1); }
void CModelPropsPanel::on_select1_pickClicked() { PickSelection(0); }
void CModelPropsPanel::on_select2_pickClicked() { PickSelection(1); }

void CModelPropsPanel::on_select1_currentItemChanged(int nrow)
{
CModelDocument* pdoc = m_wnd->GetModelDocument();
if ((pdoc == nullptr) || !pdoc->IsValid()) return;

FSItemListBuilder* itemList = ui->sel1->GetItemList();
if (itemList)
{
std::vector<int> allItems;
ui->sel1->getAllItems(allItems);

std::vector<int> l;
if (!ui->sel1->isCollapsed()) l = allItems;
else
{
if ((nrow >= 0) && (nrow < allItems.size())) l.push_back(allItems[nrow]);
}

if (!l.empty())
{
emit itemSelected(itemList, l);
}
}
}

void CModelPropsPanel::on_select2_currentItemChanged(int nrow)
{
CModelDocument* pdoc = m_wnd->GetModelDocument();
if ((pdoc == nullptr) || !pdoc->IsValid()) return;

FSItemListBuilder* itemList = ui->sel2->GetItemList();
if (itemList)
{
std::vector<int> allItems;
ui->sel2->getAllItems(allItems);

std::vector<int> l;
if (!ui->sel2->isCollapsed()) l = allItems;
else
{
if ((nrow >= 0) && (nrow < allItems.size())) l.push_back(allItems[nrow]);
}

if (!l.empty())
{
emit itemSelected(itemList, l);
}
}
}

void CModelPropsPanel::PickSelection(int n)
{
CModelDocument* pdoc = m_wnd->GetModelDocument();
Expand Down
3 changes: 3 additions & 0 deletions FEBioStudio/ModelPropsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ private slots:
void on_select2_nameChanged(const QString& t);
void on_select1_pickClicked();
void on_select2_pickClicked();
void on_select1_currentItemChanged(int nrow);
void on_select2_currentItemChanged(int nrow);
void on_object_nameChanged(const QString&);
void on_bcobject_nameChanged(const QString&);
void on_itemInfo_nameChanged(const QString&);
Expand Down Expand Up @@ -255,6 +257,7 @@ private slots:
void dataChanged(bool b);
void modelChanged();
void paramChanged(FSCoreBase* pc, Param* p);
void itemSelected(FSItemListBuilder* il, std::vector<int>& items);

private:
Ui::CModelPropsPanel* ui;
Expand Down
52 changes: 52 additions & 0 deletions FEBioStudio/ModelViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ SOFTWARE.*/
#include <MeshIO/STLExport.h>
#include "FEObjectProps.h"
#include "PropertyList.h"
#include "GLHighlighter.h"
using namespace std;

class CDlgWarnings : public QDialog
Expand Down Expand Up @@ -690,6 +691,57 @@ void CModelViewer::on_props_modelChanged()
Update();
}

void CModelViewer::on_props_itemSelected(FSItemListBuilder* il, std::vector<int>& items)
{
if (IsHighlightSelectionEnabled())
{
GLHighlighter::ClearHighlights();
GNodeList* nl = dynamic_cast<GNodeList*>(il);
if (nl) {
std::vector<GNode*> nodes = nl->GetNodeList();
for (int i : items) {
for (GNode* pn : nodes) {
if (pn->GetID() == i)
GLHighlighter::PickItem(pn);
}
}
}

GEdgeList* el = dynamic_cast<GEdgeList*>(il);
if (el) {
std::vector<GEdge*> edges = el->GetEdgeList();
for (int i : items) {
for (GEdge * pe : edges) {
if (pe->GetID() == i)
GLHighlighter::PickItem(pe);
}
}
}

GFaceList* fl = dynamic_cast<GFaceList*>(il);
if (fl) {
std::vector<GFace*> surfaces = fl->GetFaceList();
for (int i : items) {
for (GFace* pf : surfaces) {
if (pf->GetID() == i)
GLHighlighter::PickItem(pf);
}
}
}

GPartList* pl = dynamic_cast<GPartList*>(il);
if (pl) {
std::vector<GPart*> parts = pl->GetPartList();
for (int i : items) {
for (GPart* pg : parts) {
if (pg->GetID() == i)
GLHighlighter::PickItem(pg);
}
}
}
}
}

void CModelViewer::on_filter_currentIndexChanged(int n)
{
FSObject* po = GetCurrentObject();
Expand Down
1 change: 1 addition & 0 deletions FEBioStudio/ModelViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public slots:
void on_props_selectionChanged();
void on_props_dataChanged(bool b);
void on_props_modelChanged();
void on_props_itemSelected(FSItemListBuilder* il, std::vector<int>& items);
void on_filter_currentIndexChanged(int n);
void on_warnings_clicked();
void on_props_paramChanged(FSCoreBase* pc, Param* p);
Expand Down
14 changes: 13 additions & 1 deletion FEBioStudio/SelectionBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ void CSelectionBox::setCollapsed(bool b)
ui->collapse->setChecked(!b);
}

bool CSelectionBox::isCollapsed() const
{
return ui->collapse->isChecked();
}

void CSelectionBox::on_addButton_clicked()
{
emit addButtonClicked();
Expand Down Expand Up @@ -248,6 +253,11 @@ void CSelectionBox::on_list_itemDoubleClicked(QListWidgetItem *item)
}
}

void CSelectionBox::on_list_currentRowChanged(int nrow)
{
emit currentItemChanged(nrow);
}

void CSelectionBox::clearData()
{
ui->list->clear();
Expand Down Expand Up @@ -429,11 +439,13 @@ void CSelectionBox::removeSelectedItems()
//-----------------------------------------------------------------------------
CItemListSelectionBox::CItemListSelectionBox(QWidget* parent) : CSelectionBox(parent)
{

itemList = nullptr;
}

void CItemListSelectionBox::SetItemList(FSItemListBuilder* item)
{
itemList = item;

// make sure we have an item list
if (item == 0)
{
Expand Down
8 changes: 8 additions & 0 deletions FEBioStudio/SelectionBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CSelectionBox : public QWidget
void enableAllButtons(bool b);

void setCollapsed(bool b);
bool isCollapsed() const;

signals:
void addButtonClicked();
Expand All @@ -91,6 +92,7 @@ class CSelectionBox : public QWidget
void clearButtonClicked();
void nameChanged(const QString& t);
void pickClicked();
void currentItemChanged(int item);

private slots:
void on_addButton_clicked();
Expand All @@ -99,6 +101,7 @@ private slots:
void on_selButton_clicked();
void on_name_textEdited(const QString& t);
void on_list_itemDoubleClicked(QListWidgetItem *item);
void on_list_currentRowChanged(int nrow);
void on_clearSelection_clicked();
void on_toggleCollapse_toggled(bool b);
void on_pick_clicked(bool b);
Expand All @@ -117,6 +120,11 @@ class CItemListSelectionBox : public CSelectionBox
CItemListSelectionBox(QWidget* parent = nullptr);

void SetItemList(FSItemListBuilder* pItem);

FSItemListBuilder* GetItemList() { return itemList; }

private:
FSItemListBuilder* itemList;
};

class CMainWindow;
Expand Down

0 comments on commit 6eb45b8

Please sign in to comment.