#include <SMESHGUI_FilterLibraryDlg.h>

Data Structures | |
| class | Dialog |
| Class : SMESHGUI_FilterLibraryDlg.Dialog Description : Dialog for opening filter library. More... | |
Public Types | |
| enum | { ADD_TO, COPY_FROM, EDIT } |
Public Member Functions | |
| SMESHGUI_FilterLibraryDlg (SMESHGUI *, QWidget *, const QList< int > &, const int) | |
| Class : SMESHGUI_FilterLibraryDlg Description : Dialog to specify filters for VTK viewer. | |
| SMESHGUI_FilterLibraryDlg (SMESHGUI *, QWidget *, const int, const int) | |
| virtual | ~SMESHGUI_FilterLibraryDlg () |
| void | Init (const QList< int > &, const int) |
| void | Init (const int, const int) |
| const SMESHGUI_FilterTable * | GetTable () const |
| void | SetTable (const SMESHGUI_FilterTable *) |
Private Types | |
| enum | { BTN_OK, BTN_Apply, BTN_Close, BTN_Help } |
Private Slots | |
| void | onOk () |
| bool | onApply () |
| void | onClose () |
| void | onHelp () |
| void | onDeactivate () |
| void | onBrowse () |
| void | onReturnPressed () |
| void | onFilterChanged () |
| void | onAddBtnPressed () |
| void | onDeleteBtnPressed () |
| void | onFilterNameChanged (const QString &) |
| void | onEntityTypeChanged (const int) |
| void | onNeedValidation () |
Private Member Functions | |
| void | closeEvent (QCloseEvent *) |
| void | enterEvent (QEvent *) |
| void | keyPressEvent (QKeyEvent *) |
| void | construct (const QList< int > &, const int) |
| QWidget * | createButtonFrame (QWidget *) |
| QWidget * | createMainFrame (QWidget *) |
| bool | isValid (const bool=true) const |
| bool | isNameValid (const bool=true) const |
| SMESH::Filter_ptr | createFilter (const int=-1) |
| QStringList | prepareFilters () const |
| QString | autoExtension (const QString &) const |
| bool | setSelected (const QString &) |
| int | getIndex (const QString &) const |
| void | updateControlsVisibility () |
| void | updateMainButtons () |
| void | enableMainButtons () |
| void | processNewLibrary () |
| QString | getFileName () const |
| void | setFileName (const QString &, const bool=true) |
| QStringList | filterWildCards (const QString &) const |
| QString & | getDefaultLibraryName () const |
| QString | getDefaultFilterName () const |
| void | addFilterToLib (const QString &) |
| void | updateList () |
| bool | isPermissionValid (const bool) |
Private Attributes | |
| QWidget * | myMainFrame |
| QMap< int, QPushButton * > | myButtons |
| SMESHGUI_FilterTable * | myTable |
| QLineEdit * | myFileName |
| QPushButton * | myOpenBtn |
| QListWidget * | myListBox |
| QPushButton * | myAddBtn |
| QPushButton * | myDeleteBtn |
| QWidget * | myNameGrp |
| QLineEdit * | myName |
| SMESHGUI * | mySMESHGUI |
| QList< int > | myTypes |
| int | myMode |
| SMESH::FilterLibrary_var | myLibrary |
| QString | myCurrFilterName |
| int | myCurrFilter |
| QString | myHelpFileName |
Definition at line 54 of file SMESHGUI_FilterLibraryDlg.h.
anonymous enum [private] |
| anonymous enum |
Definition at line 66 of file SMESHGUI_FilterLibraryDlg.h.
| SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg | ( | SMESHGUI * | theModule, |
| QWidget * | parent, | ||
| const QList< int > & | theTypes, | ||
| const int | theMode | ||
| ) |
Class : SMESHGUI_FilterLibraryDlg Description : Dialog to specify filters for VTK viewer.
Definition at line 102 of file SMESHGUI_FilterLibraryDlg.cxx.
References construct().
: QDialog( parent ), mySMESHGUI( theModule ) { setModal(false); construct(theTypes, theMode); }
| SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg | ( | SMESHGUI * | theModule, |
| QWidget * | parent, | ||
| const int | theType, | ||
| const int | theMode | ||
| ) |
Definition at line 117 of file SMESHGUI_FilterLibraryDlg.cxx.
References construct().
: QDialog( parent ), mySMESHGUI( theModule ) { setModal(true); QList<int> aTypes; aTypes.append(theType); construct(aTypes, theMode); }
| SMESHGUI_FilterLibraryDlg::~SMESHGUI_FilterLibraryDlg | ( | ) | [virtual] |
Definition at line 303 of file SMESHGUI_FilterLibraryDlg.cxx.
{
}
| void SMESHGUI_FilterLibraryDlg::addFilterToLib | ( | const QString & | theName | ) | [private] |
Definition at line 949 of file SMESHGUI_FilterLibraryDlg.cxx.
References createFilter(), SMESHGUI.desktop(), getDefaultFilterName(), SMESHGUI_FilterTable.GetType(), myCurrFilter, myCurrFilterName, myLibrary, myTable, setSelected(), and updateList().
Referenced by onAddBtnPressed(), onBrowse(), onReturnPressed(), and SetTable().
{
if (myLibrary->_is_nil()) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
tr("LIBRARY_IS_NOT_LOADED"));
return;
}
// create filter
SMESH::Filter_var aFilter = createFilter();
// if name of filter already exist in the library assign default name for the filter
QString aName(theName);
SMESH::string_array_var aNames = myLibrary->GetAllNames();
for (int i = 0, n = aNames->length(); i < n; i++)
if (aName == QString(aNames[ i ]))
{
aName = getDefaultFilterName();
break;
}
// add new filter in library
bool aResult = !aFilter->GetPredicate()->_is_nil()
? myLibrary->Add(aName.toLatin1().constData(), aFilter)
: myLibrary->AddEmpty(aName.toLatin1().constData(), (SMESH::ElementType)myTable->GetType());
if (!aResult) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_OF_ADDING"));
}
updateList();
myCurrFilterName = "";
myCurrFilter = -1;
setSelected(aName);
if (theName != aName)
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"),
tr("ASSIGN_NEW_NAME").arg(theName).arg(aName));
}
| QString SMESHGUI_FilterLibraryDlg::autoExtension | ( | const QString & | theFileName | ) | const [private] |
Definition at line 563 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESH_Nut.theFileName.
Referenced by isPermissionValid(), onBrowse(), processNewLibrary(), and setFileName().
{
QString anExt = theFileName.section('.', -1);
return anExt != "xml" && anExt != "XML" ? theFileName + ".xml" : theFileName;
}
| void SMESHGUI_FilterLibraryDlg::closeEvent | ( | QCloseEvent * | e | ) | [private] |
| void SMESHGUI_FilterLibraryDlg::construct | ( | const QList< int > & | theTypes, |
| const int | theMode | ||
| ) | [private] |
Definition at line 134 of file SMESHGUI_FilterLibraryDlg.cxx.
References createButtonFrame(), createMainFrame(), Init(), MARGIN, myHelpFileName, myMainFrame, myMode, myTypes, and SPACING.
Referenced by SMESHGUI_FilterLibraryDlg().
{
myTypes = theTypes;
myMode = theMode;
QVBoxLayout* aDlgLay = new QVBoxLayout(this);
aDlgLay->setMargin(MARGIN);
aDlgLay->setSpacing(SPACING);
myMainFrame = createMainFrame (this);
QWidget* aBtnFrame = createButtonFrame(this);
aDlgLay->addWidget(myMainFrame);
aDlgLay->addWidget(aBtnFrame);
aDlgLay->setStretchFactor(myMainFrame, 1);
myHelpFileName = "selection_filter_library_page.html";
Init(myTypes, myMode);
}
Definition at line 250 of file SMESHGUI_FilterLibraryDlg.cxx.
References BTN_Apply, BTN_Close, BTN_Help, BTN_OK, MARGIN, myButtons, onApply(), onClose(), onHelp(), onOk(), SPACING, and updateMainButtons().
Referenced by construct().
{
QGroupBox* aGrp = new QGroupBox(theParent);
QHBoxLayout* aLay = new QHBoxLayout(aGrp);
aLay->setMargin(MARGIN);
aLay->setSpacing(SPACING);
myButtons[ BTN_OK ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp);
myButtons[ BTN_Apply ] = new QPushButton(tr("SMESH_BUT_APPLY"), aGrp);
myButtons[ BTN_Close ] = new QPushButton(tr("SMESH_BUT_CLOSE"), aGrp);
myButtons[ BTN_Help ] = new QPushButton(tr("SMESH_BUT_HELP"), aGrp);
aLay->addWidget(myButtons[ BTN_OK ]);
aLay->addSpacing(10);
aLay->addWidget(myButtons[ BTN_Apply ]);
aLay->addSpacing(10);
aLay->addStretch();
aLay->addWidget(myButtons[ BTN_Close ]);
aLay->addWidget(myButtons[ BTN_Help ]);
connect(myButtons[ BTN_OK ], SIGNAL(clicked()), SLOT(onOk()));
connect(myButtons[ BTN_Close ], SIGNAL(clicked()), SLOT(onClose()));
connect(myButtons[ BTN_Apply ], SIGNAL(clicked()), SLOT(onApply()));
connect(myButtons[ BTN_Help ], SIGNAL(clicked()), SLOT(onHelp()));
QMap<int, QPushButton*>::iterator anIter;
for (anIter = myButtons.begin(); anIter != myButtons.end(); ++anIter)
anIter.value()->setAutoDefault(false);
updateMainButtons();
return aGrp;
}
| SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter | ( | const int | theType = -1 | ) | [private] |
Definition at line 900 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESH_freebord.aCriterion, createCriterion(), SMESHGUI_FilterTable.GetCriterion(), SMESH.GetFilterManager(), myTable, and SMESHGUI_FilterTable.NumRows().
Referenced by addFilterToLib(), onAddBtnPressed(), onApply(), onFilterChanged(), and onNeedValidation().
{
int n = myTable->NumRows(theType);
SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
aCriteria->length(n);
for (int i = 0; i < n; i++)
{
SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion();
myTable->GetCriterion(i, aCriterion);
aCriteria[ i ] = aCriterion;
}
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
aFilter->SetCriteria(aCriteria.in());
return aFilter._retn();
}
Definition at line 161 of file SMESHGUI_FilterLibraryDlg.cxx.
References EDIT, MARGIN, myAddBtn, myDeleteBtn, myFileName, myListBox, myMode, myName, myNameGrp, myOpenBtn, mySMESHGUI, myTable, myTypes, onAddBtnPressed(), onBrowse(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onFilterNameChanged(), onNeedValidation(), onReturnPressed(), SMESHGUI_FilterTable.SetEditable(), SMESHGUI_FilterTable.SetLibsEnabled(), and SPACING.
Referenced by construct().
{
QWidget* aMainFrame = new QWidget(theParent);
QGridLayout* aMainLay = new QGridLayout(aMainFrame);
aMainLay->setMargin(0);
aMainLay->setSpacing(SPACING);
// library name
QLabel* aFileLab = new QLabel(tr("LIBRARY_FILE"), aMainFrame);
myFileName = new QLineEdit(aMainFrame);
myOpenBtn = new QPushButton(aMainFrame);
myOpenBtn->setIcon(SUIT_Session::session()->resourceMgr()->loadPixmap(
"SUIT", tr("ICON_FILE_OPEN")));
// filters list box
QGroupBox* aFiltersGrp = new QGroupBox(tr("FILTER_NAMES"), aMainFrame);
QGridLayout* aLay = new QGridLayout(aFiltersGrp);
aLay->setMargin(MARGIN);
aLay->setSpacing(SPACING);
myListBox = new QListWidget(aFiltersGrp);
myAddBtn = new QPushButton(tr("ADD"), aFiltersGrp);
myDeleteBtn = new QPushButton(tr("DELETE"), aFiltersGrp);
aLay->addWidget(myListBox, 0, 0, 3, 1);
aLay->addWidget(myAddBtn, 0, 1);
aLay->addWidget(myDeleteBtn, 1, 1);
aLay->setRowStretch(2, 5);
// filter name
myNameGrp = new QWidget(aMainFrame);
QHBoxLayout* myNameGrpLayout = new QHBoxLayout(myNameGrp);
myNameGrpLayout->setMargin(0);
myNameGrpLayout->setSpacing(SPACING);
myNameGrpLayout->addWidget( new QLabel(tr("FILTER_NAME"), myNameGrp) );
myNameGrpLayout->addWidget( myName = new QLineEdit(myNameGrp) );
// table
myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes);
myTable->SetEditable(myMode == EDIT);
myTable->SetLibsEnabled(false);
myListBox->setMinimumHeight((int)(myTable->sizeHint().height() * 0.5));
//myListBox->setRowMode(QListWidget::FitToWidth); //VSR : TODO ???
myListBox->setSelectionMode(QListWidget::SingleSelection);
myOpenBtn->setAutoDefault(false);
myAddBtn->setAutoDefault(false);
myDeleteBtn->setAutoDefault(false);
aMainLay->addWidget(aFileLab, 0, 0);
aMainLay->addWidget(myFileName, 0, 1);
aMainLay->addWidget(myOpenBtn, 0, 2);
aMainLay->addWidget(aFiltersGrp, 1, 0, 1, 3);
aMainLay->addWidget(myNameGrp, 2, 0, 1, 3);
aMainLay->addWidget(myTable, 3, 0, 1, 3);
// connect signals and slots
connect(myFileName, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
connect(myOpenBtn, SIGNAL(clicked()), this, SLOT(onBrowse()));
connect(myListBox, SIGNAL(itemSelectionChanged()),
this, SLOT(onFilterChanged()));
connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAddBtnPressed()));
connect(myDeleteBtn, SIGNAL(clicked()), this, SLOT(onDeleteBtnPressed()));
connect(myName, SIGNAL(textChanged(const QString&)),
this, SLOT(onFilterNameChanged(const QString&)));
connect(myTable, SIGNAL(EntityTypeChanged(const int)),
this, SLOT(onEntityTypeChanged(const int)));
connect(myTable, SIGNAL(NeedValidation()), this, SLOT(onNeedValidation()));
return aMainFrame;
}
| void SMESHGUI_FilterLibraryDlg::enableMainButtons | ( | ) | [private] |
Definition at line 882 of file SMESHGUI_FilterLibraryDlg.cxx.
{
/*bool isEnabled = isValid(false);
if (myButtons.contains(BTN_OK))
myButtons[ BTN_OK ]->setEnabled(isEnabled);
else if (myButtons.contains(BTN_Apply))
myButtons[ BTN_OK ]->setEnabled(isEnabled);
if (myButtons.contains(BTN_Cancel))
myButtons[ BTN_Cancel ]->setEnabled(isEnabled);
else if (myButtons.contains(BTN_Close))
myButtons[ BTN_Cancel ]->setEnabled(isEnabled);
*/
}
| void SMESHGUI_FilterLibraryDlg::enterEvent | ( | QEvent * | ) | [private] |
Definition at line 525 of file SMESHGUI_FilterLibraryDlg.cxx.
{
setEnabled(true);
}
| QStringList SMESHGUI_FilterLibraryDlg::filterWildCards | ( | const QString & | theFilter | ) | const [private] |
Definition at line 573 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESH_AdvancedEditor.res.
{
QStringList res;
int b = theFilter.lastIndexOf("(");
int e = theFilter.lastIndexOf(")");
if (b != -1 && e != -1)
{
QString content = theFilter.mid(b + 1, e - b - 1).trimmed();
QStringList lst = content.split(" ", QString::SkipEmptyParts);
for (QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it)
if ((*it).indexOf(".") != -1)
res.append((*it).trimmed());
}
return res;
}
| QString SMESHGUI_FilterLibraryDlg::getDefaultFilterName | ( | ) | const [private] |
Definition at line 1009 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESH.ALL, EDGE, FACE, SMESHGUI_FilterTable.GetType(), myLibrary, myTable, SMESH.NODE, and VOLUME.
Referenced by addFilterToLib(), onAddBtnPressed(), and SetTable().
{
QString aName;
if (myTable->GetType() == SMESH::NODE)
aName = tr("NODE");
else if (myTable->GetType() == SMESH::EDGE)
aName = tr("EDGE");
else if (myTable->GetType() == SMESH::FACE)
aName = tr("FACE");
else if (myTable->GetType() == SMESH::VOLUME)
aName = tr("VOLUME");
else if (myTable->GetType() == SMESH::ALL)
aName = tr("ELEMENT");
else
aName = tr("SELECTION");
aName += tr("FILTER");
QMap< QString, int > anAllNames;
SMESH::string_array_var aNames = myLibrary->GetAllNames();
for(int i = 0, n = aNames->length(); i < n; i++)
anAllNames[ QString(aNames[ i ]) ] = -1;
bool isNotValid = true;
int k = 1;
QString aNewName;
while (isNotValid)
{
isNotValid = false;
aNewName = aName + "_" + QString("%1").arg(k);
if (anAllNames.contains(aNewName))
{
isNotValid = true;
k++;
}
}
return aNewName;
}
| QString & SMESHGUI_FilterLibraryDlg::getDefaultLibraryName | ( | ) | const [private] |
Definition at line 994 of file SMESHGUI_FilterLibraryDlg.cxx.
Referenced by Init(), and onApply().
{
static QString aName;
if (aName.isEmpty())
{
QString aHomeDir = QDir(QDir::home()).absolutePath();
aName = aHomeDir + "/" + tr ("LIB_NAME");
}
return aName;
}
| QString SMESHGUI_FilterLibraryDlg::getFileName | ( | ) | const [private] |
Definition at line 543 of file SMESHGUI_FilterLibraryDlg.cxx.
References myFileName.
Referenced by onBrowse(), and processNewLibrary().
{
return myFileName != 0 ? myFileName->text() : QString("");
}
| int SMESHGUI_FilterLibraryDlg::getIndex | ( | const QString & | theName | ) | const [private] |
Definition at line 1071 of file SMESHGUI_FilterLibraryDlg.cxx.
References myListBox.
Referenced by onDeleteBtnPressed(), and setSelected().
| const SMESHGUI_FilterTable * SMESHGUI_FilterLibraryDlg::GetTable | ( | ) | const |
Definition at line 1148 of file SMESHGUI_FilterLibraryDlg.cxx.
References myTable.
Referenced by SMESHGUI_FilterTable.onCopyFromBtn().
{
return myTable;
}
Definition at line 311 of file SMESHGUI_FilterLibraryDlg.cxx.
References Init().
{
QList<int> aTypes;
aTypes.append(type);
Init(aTypes, theMode);
}
Definition at line 322 of file SMESHGUI_FilterLibraryDlg.cxx.
References ADD_TO, SMESHGUI_FilterTable.Clear(), COPY_FROM, getDefaultLibraryName(), SMESHGUI_FilterTable.Init(), isPermissionValid(), myCurrFilter, myCurrFilterName, myFileName, myListBox, myMode, myName, mySMESHGUI, myTable, myTypes, onClose(), onDeactivate(), processNewLibrary(), updateControlsVisibility(), and updateMainButtons().
Referenced by construct(), Init(), SMESHGUI_FilterTable.onAddToBtn(), SMESHGUI_FilterTable.onCopyFromBtn(), and SMESHGUI.OnGUIEvent().
{
myMode = theMode;
myTypes = theTypes;
myTable->Init(theTypes);
myCurrFilterName = "";
myCurrFilter = -1;
myListBox->blockSignals(true);
myListBox->clear();
myListBox->blockSignals(false);
myName->clear();
myTable->Clear();
updateControlsVisibility();
setEnabled(true);
connect( mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
connect( mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
if (myMode == ADD_TO)
{
setWindowTitle(tr("ADD_TO_TLT"));
if (myFileName->text().isEmpty())
myFileName->setText(getDefaultLibraryName());
processNewLibrary();
}
else if (myMode == COPY_FROM)
{
setWindowTitle(tr("COPY_FROM_TLT"));
if (myFileName->text().isEmpty())
myFileName->setText(getDefaultLibraryName());
processNewLibrary();
if (myListBox->count() > 0)
myListBox->setCurrentItem(0);
}
else
{
setWindowTitle(tr("EDIT_LIB_TLT"));
if (myFileName->text().isEmpty())
myFileName->setText(getDefaultLibraryName());
processNewLibrary();
if (myListBox->count() > 0)
myListBox->setCurrentItem(0);
}
this->show();
updateMainButtons();
isPermissionValid(false);
}
Definition at line 720 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESHGUI.desktop(), myCurrFilterName, myLibrary, and myName.
Referenced by isValid().
{
// verify validity of filter name
if (myName->isEnabled() && !myCurrFilterName.isEmpty()) {
QString aCurrName = myName->text();
if (aCurrName.isEmpty()) {
if (theMess)
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("EMPTY_FILTER_NAME"));
return false;
}
SMESH::string_array_var aNames = myLibrary->GetAllNames();
for (int f = 0, n = aNames->length(); f < n; f++) {
if (aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName) {
if (theMess)
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("ERROR_FILTER_NAME"));
return false;
}
}
}
return true;
}
Definition at line 750 of file SMESHGUI_FilterLibraryDlg.cxx.
References autoExtension(), COPY_FROM, SMESHGUI.desktop(), myFileName, and myMode.
Referenced by Init(), onApply(), onBrowse(), and onReturnPressed().
{
if (myMode == COPY_FROM)
return true;
// Verify write permission
bool isWritable = false;
QString fName(myFileName->text());
if (QFileInfo(fName).suffix().isEmpty())
fName = autoExtension(fName);
fName = QDir::convertSeparators(fName);
if (QFileInfo(fName).exists()) {
isWritable = QFileInfo(fName).isWritable();
} else if (!theIsExistingOnly) {
QFileInfo aDirInfo(QFileInfo(fName).absolutePath());
isWritable = aDirInfo.isWritable();
/*if (QDir(QFileInfo(fName).dirPath(true)).exists() ||
QDir().mkdir(QFileInfo(fName).dirPath(true)))
{
QFile aFile(fName);
if (aFile.open(IO_WriteOnly))
isWritable = true;
else
aFile.close();
}
*/
} else {
isWritable = true;
}
if (!isWritable) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
tr("NO_PERMISSION"));
return false;
}
return true;
}
Definition at line 796 of file SMESHGUI_FilterLibraryDlg.cxx.
References isNameValid(), SMESHGUI_FilterTable.IsValid(), and myTable.
Referenced by onAddBtnPressed(), onApply(), onFilterChanged(), and onNeedValidation().
{
// verify validity of table
if (!myTable->IsValid(theMess) || !isNameValid(theMess))
return false;
else
return true;
}
| void SMESHGUI_FilterLibraryDlg::keyPressEvent | ( | QKeyEvent * | e | ) | [private] |
Definition at line 1196 of file SMESHGUI_FilterLibraryDlg.cxx.
References onHelp().
{
QDialog::keyPressEvent( e );
if ( e->isAccepted() )
return;
if ( e->key() == Qt::Key_F1 ) {
e->accept();
onHelp();
}
}
| void SMESHGUI_FilterLibraryDlg::onAddBtnPressed | ( | ) | [private, slot] |
Definition at line 926 of file SMESHGUI_FilterLibraryDlg.cxx.
References addFilterToLib(), SMESHGUI_FilterTable.Clear(), createFilter(), getDefaultFilterName(), SMESHGUI_FilterTable.GetType(), SMESHGUI_FilterTable.IsEditable(), isValid(), myCurrFilterName, myLibrary, myName, and myTable.
Referenced by createMainFrame().
{
// Save parameters of filter if it was changed
if (!myCurrFilterName.isEmpty() && myTable->IsEditable())
{
if (!isValid(true))
return;
SMESH::Filter_var aFilter = createFilter();
myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
myName->text().toLatin1().constData(),
aFilter);
}
myTable->Clear(myTable->GetType());
addFilterToLib(getDefaultFilterName());
}
| bool SMESHGUI_FilterLibraryDlg::onApply | ( | ) | [private, slot] |
Definition at line 414 of file SMESHGUI_FilterLibraryDlg.cxx.
References ADD_TO, SMESH_test5.aFileName, COPY_FROM, createFilter(), SMESHGUI.desktop(), EDIT, getDefaultLibraryName(), isPermissionValid(), isValid(), myCurrFilterName, myFileName, myLibrary, myListBox, myMode, and myName.
Referenced by createButtonFrame(), and onOk().
{
if (!isValid(true) || !isPermissionValid(false))
return false;
if (myLibrary->_is_nil()) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
tr("LIBRARY_IS_NOT_LOADED"));
return false;
}
if (myFileName->text() != myLibrary->GetFileName())
myLibrary->SetFileName( myFileName->text().toLatin1().constData() );
bool aResult = false;
if (myMode == COPY_FROM || myListBox->count() == 0) {
aResult = true;
} else if (myMode == EDIT || myMode == ADD_TO) {
SMESH::Filter_var aFilter = createFilter();
if (!myListBox->selectedItems().empty() &&
!myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
myName->text().toLatin1().constData(),
aFilter.in())) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_OF_EDITING"));
aResult = false;
}
else
aResult = true;
}
if (aResult && myMode != COPY_FROM)
aResult = myLibrary->Save();
if (aResult) {
char* aFileName = myLibrary->GetFileName();
getDefaultLibraryName() = QString(aFileName);
delete aFileName;
} else if (myMode != COPY_FROM) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_OF_SAVING"));
} else {
}
return aResult;
}
| void SMESHGUI_FilterLibraryDlg::onBrowse | ( | ) | [private, slot] |
Definition at line 610 of file SMESHGUI_FilterLibraryDlg.cxx.
References ADD_TO, addFilterToLib(), autoExtension(), SMESHGUI_FilterTable.Copy(), COPY_FROM, getFileName(), isPermissionValid(), myCurrFilter, myCurrFilterName, myListBox, myMode, myTable, prepareFilters(), processNewLibrary(), and setFileName().
Referenced by createMainFrame().
{
Dialog* aDlg = new Dialog(this, true);
aDlg->setWindowTitle(tr("OPEN_LIBRARY"));
//aDlg->setMode(myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile);
aDlg->setFileMode(myMode == COPY_FROM ? QFileDialog::ExistingFile : QFileDialog::AnyFile);
aDlg->setFilters(prepareFilters());
aDlg->selectFile(getFileName());
QPushButton* anOkBtn = (QPushButton*)aDlg->findChild<QPushButton*>("OK");
if (anOkBtn != 0)
anOkBtn->setText(tr("SMESH_BUT_OK"));
if (aDlg->exec() != Accepted)
return;
QString fName = aDlg->selectedFile();
if (fName.isEmpty())
return;
if (QFileInfo(fName).suffix().isEmpty())
fName = autoExtension(fName);
fName = QDir::convertSeparators(fName);
QString prev = QDir::convertSeparators(getFileName());
if (prev == fName)
return;
setFileName(fName);
QListWidgetItem* item = myListBox->item( myListBox->count()-1 );
QString aName = item ? item->text() : QString::null;
processNewLibrary();
if (myMode == ADD_TO)
{
myTable->Copy((SMESHGUI_FilterTable*)parentWidget());
myCurrFilterName = "";
myCurrFilter = -1;
addFilterToLib(aName);
}
isPermissionValid(false);
}
| void SMESHGUI_FilterLibraryDlg::onClose | ( | ) | [private, slot] |
Definition at line 481 of file SMESHGUI_FilterLibraryDlg.cxx.
References mySMESHGUI, and SMESHGUI.ResetState().
Referenced by closeEvent(), createButtonFrame(), and Init().
{
disconnect( mySMESHGUI, 0, this, 0);
mySMESHGUI->ResetState();
reject();
}
| void SMESHGUI_FilterLibraryDlg::onDeactivate | ( | ) | [private, slot] |
Definition at line 516 of file SMESHGUI_FilterLibraryDlg.cxx.
Referenced by Init().
{
setEnabled(false);
}
| void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed | ( | ) | [private, slot] |
Definition at line 1083 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESHGUI_FilterTable.Clear(), SMESHGUI.desktop(), getIndex(), myCurrFilter, myCurrFilterName, myLibrary, myListBox, myName, myTable, and SMESHGUI_FilterTable.SetEnabled().
Referenced by createMainFrame().
{
if (myLibrary->_is_nil()) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
tr("LIBRARY_IS_NOT_LOADED"));
return;
}
int anIndex = getIndex(myCurrFilterName);
if (anIndex == -1 || !myLibrary->Delete(myCurrFilterName.toLatin1().constData())) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_OF_DELETING"));
} else {
myCurrFilterName = "";
myCurrFilter = -1;
delete myListBox->item(anIndex);
if (anIndex >= 1)
myListBox->item(anIndex - 1)->setSelected(true);
else if (anIndex == 0 && myListBox->count() > 0)
myListBox->item(0)->setSelected(true);
else
myTable->Clear();
}
myTable->SetEnabled(myListBox->count() > 0);
if (myListBox->count() == 0) {
myName->setText("");
myName->setEnabled(false);
}
}
| void SMESHGUI_FilterLibraryDlg::onEntityTypeChanged | ( | const int | theType | ) | [private, slot] |
Definition at line 1158 of file SMESHGUI_FilterLibraryDlg.cxx.
References myCurrFilter, myCurrFilterName, myLibrary, myListBox, myName, and updateList().
Referenced by createMainFrame().
{
if (myLibrary->_is_nil())
return;
myName->clear();
myCurrFilterName = "";
myCurrFilter = -1;
updateList();
if (myListBox->count())
myListBox->setCurrentItem(0);
}
| void SMESHGUI_FilterLibraryDlg::onFilterChanged | ( | ) | [private, slot] |
Definition at line 809 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESHGUI_FilterTable.AddCriterion(), SMESHGUI_FilterTable.Clear(), createFilter(), SMESHGUI_FilterTable.GetType(), SMESHGUI_FilterTable.IsEditable(), isValid(), myCurrFilter, myCurrFilterName, myLibrary, myListBox, myName, myTable, SMESHGUI_FilterTable.Update(), and updateControlsVisibility().
Referenced by createMainFrame().
{
QString theName = myListBox->currentItem() ? myListBox->currentItem()->text() : QString::null;
if (myLibrary->_is_nil())
return;
// Save parameters of filter if it was changed
if (!myCurrFilterName.isEmpty() && myTable->IsEditable())
{
if (!isValid(true))
{
myListBox->blockSignals(true);
myListBox->setCurrentRow(myCurrFilter);
myListBox->blockSignals(false);
return;
}
SMESH::Filter_var aFilter = createFilter();
myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
myName->text().toLatin1().constData(),
aFilter);
}
// Fill table with filter parameters
SMESH::Filter_var aFilter = myLibrary->Copy(theName.toLatin1().constData());
myCurrFilterName = theName;
myCurrFilter = myListBox->currentRow();
myName->setText(theName);
SMESH::Filter::Criteria_var aCriteria;
myTable->Clear(myTable->GetType());
if (CORBA::is_nil( aFilter ) || !aFilter->GetCriteria(aCriteria))
return;
for (int i = 0, n = aCriteria->length(); i < n; i++)
myTable->AddCriterion(aCriteria[ i ], myTable->GetType());
myTable->Update();
updateControlsVisibility(); // IPAL19974
}
| void SMESHGUI_FilterLibraryDlg::onFilterNameChanged | ( | const QString & | theName | ) | [private, slot] |
Definition at line 1121 of file SMESHGUI_FilterLibraryDlg.cxx.
References myListBox.
Referenced by createMainFrame().
| void SMESHGUI_FilterLibraryDlg::onHelp | ( | ) | [private, slot] |
Definition at line 492 of file SMESHGUI_FilterLibraryDlg.cxx.
References myHelpFileName, and mySMESHGUI.
Referenced by createButtonFrame(), and keyPressEvent().
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
else {
QString platform;
#ifdef WIN32
platform = "winapplication";
#else
platform = "application";
#endif
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
arg(app->resourceMgr()->stringValue("ExternalBrowser",
platform)).
arg(myHelpFileName));
}
}
| void SMESHGUI_FilterLibraryDlg::onNeedValidation | ( | ) | [private, slot] |
Definition at line 1175 of file SMESHGUI_FilterLibraryDlg.cxx.
References createFilter(), SMESHGUI_FilterTable.GetType(), isValid(), myCurrFilterName, myLibrary, myName, myTable, and SMESHGUI_FilterTable.SetValidity().
Referenced by createMainFrame().
{
if (!myCurrFilterName.isEmpty())
{
bool valid = isValid(true);
myTable->SetValidity(valid);
if (valid)
{
SMESH::Filter_var aFilter = createFilter(myTable->GetType());
myLibrary->Replace(myCurrFilterName.toLatin1().constData(),
myName->text().toLatin1().constData(),
aFilter);
}
}
}
| void SMESHGUI_FilterLibraryDlg::onOk | ( | ) | [private, slot] |
Definition at line 467 of file SMESHGUI_FilterLibraryDlg.cxx.
References mySMESHGUI, onApply(), and SMESHGUI.ResetState().
Referenced by createButtonFrame().
{
if (onApply())
{
disconnect( mySMESHGUI, 0, this, 0);
mySMESHGUI->ResetState();
accept();
}
}
| void SMESHGUI_FilterLibraryDlg::onReturnPressed | ( | ) | [private, slot] |
Definition at line 860 of file SMESHGUI_FilterLibraryDlg.cxx.
References ADD_TO, addFilterToLib(), SMESHGUI_FilterTable.Copy(), isPermissionValid(), myCurrFilter, myCurrFilterName, myListBox, myMode, myTable, and processNewLibrary().
Referenced by createMainFrame().
{
QListWidgetItem* item = myListBox->item( myListBox->count()-1 );
QString aName = item ? item->text() : QString::null;
processNewLibrary();
if (myMode == ADD_TO)
{
myTable->Copy((SMESHGUI_FilterTable*)parentWidget());
myCurrFilterName = "";
myCurrFilter = -1;
addFilterToLib(aName);
}
isPermissionValid(false);
}
| QStringList SMESHGUI_FilterLibraryDlg::prepareFilters | ( | ) | const [private] |
Definition at line 594 of file SMESHGUI_FilterLibraryDlg.cxx.
Referenced by onBrowse().
{
static QStringList aList;
if (aList.isEmpty())
{
aList.append(tr("XML_FILT"));
//aList.append(tr("ALL_FILES_FILTER"));
}
return aList;
}
| void SMESHGUI_FilterLibraryDlg::processNewLibrary | ( | ) | [private] |
Definition at line 662 of file SMESHGUI_FilterLibraryDlg.cxx.
References autoExtension(), COPY_FROM, SMESHGUI.desktop(), getFileName(), SMESH.GetFilterManager(), myLibrary, myMode, and updateList().
Referenced by Init(), onBrowse(), and onReturnPressed().
{
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
if (aFilterMgr->_is_nil())
return;
myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName()).toLatin1().constData());
if (myLibrary->_is_nil()) {
if (myMode == COPY_FROM) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_LOAD"));
return;
} else {
myLibrary = aFilterMgr->CreateLibrary();
myLibrary->SetFileName(getFileName().toLatin1().constData());
}
}
updateList();
}
| void SMESHGUI_FilterLibraryDlg::setFileName | ( | const QString & | txt, |
| const bool | autoExt = true |
||
| ) | [private] |
Definition at line 552 of file SMESHGUI_FilterLibraryDlg.cxx.
References autoExtension(), and myFileName.
Referenced by onBrowse().
{
if (myFileName == 0)
return;
myFileName->setText(autoExt ? autoExtension(txt) : txt);
}
| bool SMESHGUI_FilterLibraryDlg::setSelected | ( | const QString & | theName | ) | [private] |
Definition at line 1055 of file SMESHGUI_FilterLibraryDlg.cxx.
References getIndex(), myCurrFilter, myCurrFilterName, and myListBox.
Referenced by addFilterToLib().
{
int anIndex = getIndex(theName);
if (anIndex != -1)
{
myListBox->setCurrentRow(anIndex);
myCurrFilterName = theName;
myCurrFilter = anIndex;
}
return anIndex != -1;
}
| void SMESHGUI_FilterLibraryDlg::SetTable | ( | const SMESHGUI_FilterTable * | theTable | ) |
Definition at line 1136 of file SMESHGUI_FilterLibraryDlg.cxx.
References addFilterToLib(), SMESHGUI_FilterTable.Copy(), getDefaultFilterName(), myName, myTable, and SMESHGUI_FilterTable.Update().
Referenced by SMESHGUI_FilterTable.onAddToBtn().
{
myTable->Copy(theTable);
myName->setText(getDefaultFilterName());
addFilterToLib(myName->text());
myTable->Update();
}
| void SMESHGUI_FilterLibraryDlg::updateControlsVisibility | ( | ) | [private] |
Definition at line 378 of file SMESHGUI_FilterLibraryDlg.cxx.
References ADD_TO, COPY_FROM, EDIT, myAddBtn, myDeleteBtn, myMode, myNameGrp, myTable, and SMESHGUI_FilterTable.SetEditable().
Referenced by Init(), and onFilterChanged().
{
if (myMode == ADD_TO)
{
myNameGrp->show();
myNameGrp->setEnabled(true);
myAddBtn->hide();
myDeleteBtn->hide();
myTable->SetEditable(false);
}
else if (myMode == COPY_FROM)
{
myNameGrp->hide();
myNameGrp->setEnabled(false);
myAddBtn->hide();
myDeleteBtn->hide();
myTable->SetEditable(false);
}
else if (myMode == EDIT)
{
myNameGrp->show();
myNameGrp->setEnabled(true);
myAddBtn->show();
myDeleteBtn->show();
myTable->SetEditable(true);
}
qApp->processEvents();
updateGeometry();
adjustSize();
}
| void SMESHGUI_FilterLibraryDlg::updateList | ( | ) | [private] |
Definition at line 687 of file SMESHGUI_FilterLibraryDlg.cxx.
References SMESHGUI_FilterTable.Clear(), SMESHGUI_FilterTable.GetType(), myCurrFilterName, myLibrary, myListBox, myName, myTable, and SMESHGUI_FilterTable.SetEnabled().
Referenced by addFilterToLib(), onEntityTypeChanged(), and processNewLibrary().
{
QStringList aList;
SMESH::string_array_var aNames = myLibrary->GetNames((SMESH::ElementType)myTable->GetType());
for (int i = 0, n = aNames->length(); i < n; i++)
aList.append(QString(aNames[ i ]));
myListBox->blockSignals(true);
myListBox->clear();
myListBox->blockSignals(false);
myListBox->addItems(aList);
if (myListBox->count() == 0)
{
myTable->Clear(myTable->GetType());
myName->clear();
myName->setEnabled(false);
myTable->SetEnabled(false);
}
else
{
myName->setEnabled(true);
myTable->SetEnabled(true);
if (myListBox->count())
{
myCurrFilterName = "";
myListBox->setCurrentItem(0);
}
}
}
| void SMESHGUI_FilterLibraryDlg::updateMainButtons | ( | ) | [private] |
Definition at line 289 of file SMESHGUI_FilterLibraryDlg.cxx.
References BTN_Apply, BTN_Close, myButtons, and myTypes.
Referenced by createButtonFrame(), and Init().
QPushButton* SMESHGUI_FilterLibraryDlg.myAddBtn [private] |
Definition at line 133 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), and updateControlsVisibility().
QMap<int, QPushButton*> SMESHGUI_FilterLibraryDlg.myButtons [private] |
Definition at line 128 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createButtonFrame(), and updateMainButtons().
int SMESHGUI_FilterLibraryDlg.myCurrFilter [private] |
Definition at line 144 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by addFilterToLib(), Init(), onBrowse(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onReturnPressed(), and setSelected().
QString SMESHGUI_FilterLibraryDlg.myCurrFilterName [private] |
Definition at line 143 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by addFilterToLib(), Init(), isNameValid(), onAddBtnPressed(), onApply(), onBrowse(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onNeedValidation(), onReturnPressed(), setSelected(), and updateList().
QPushButton* SMESHGUI_FilterLibraryDlg.myDeleteBtn [private] |
Definition at line 134 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), and updateControlsVisibility().
QLineEdit* SMESHGUI_FilterLibraryDlg.myFileName [private] |
Definition at line 130 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), getFileName(), Init(), isPermissionValid(), onApply(), and setFileName().
QString SMESHGUI_FilterLibraryDlg.myHelpFileName [private] |
Definition at line 146 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by construct(), and onHelp().
SMESH::FilterLibrary_var SMESHGUI_FilterLibraryDlg.myLibrary [private] |
Definition at line 142 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by addFilterToLib(), getDefaultFilterName(), isNameValid(), onAddBtnPressed(), onApply(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onNeedValidation(), processNewLibrary(), and updateList().
QListWidget* SMESHGUI_FilterLibraryDlg.myListBox [private] |
Definition at line 132 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), getIndex(), Init(), onApply(), onBrowse(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onFilterNameChanged(), onReturnPressed(), setSelected(), and updateList().
QWidget* SMESHGUI_FilterLibraryDlg.myMainFrame [private] |
Definition at line 127 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by construct().
int SMESHGUI_FilterLibraryDlg.myMode [private] |
Definition at line 140 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by construct(), createMainFrame(), Init(), isPermissionValid(), onApply(), onBrowse(), onReturnPressed(), processNewLibrary(), and updateControlsVisibility().
QLineEdit* SMESHGUI_FilterLibraryDlg.myName [private] |
Definition at line 136 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), Init(), isNameValid(), onAddBtnPressed(), onApply(), onDeleteBtnPressed(), onEntityTypeChanged(), onFilterChanged(), onNeedValidation(), SetTable(), and updateList().
QWidget* SMESHGUI_FilterLibraryDlg.myNameGrp [private] |
Definition at line 135 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), and updateControlsVisibility().
QPushButton* SMESHGUI_FilterLibraryDlg.myOpenBtn [private] |
Definition at line 131 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame().
SMESHGUI* SMESHGUI_FilterLibraryDlg.mySMESHGUI [private] |
Definition at line 137 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by createMainFrame(), Init(), onClose(), onHelp(), and onOk().
Definition at line 129 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by addFilterToLib(), createFilter(), createMainFrame(), getDefaultFilterName(), GetTable(), Init(), isValid(), onAddBtnPressed(), onBrowse(), onDeleteBtnPressed(), onFilterChanged(), onNeedValidation(), onReturnPressed(), SetTable(), updateControlsVisibility(), and updateList().
QList<int> SMESHGUI_FilterLibraryDlg.myTypes [private] |
Definition at line 139 of file SMESHGUI_FilterLibraryDlg.h.
Referenced by construct(), createMainFrame(), Init(), and updateMainButtons().