Ejemplo n.º 1
0
PlyOpenDlg::PlyOpenDlg(QWidget* parent) : QDialog(parent), Ui::PlyOpenDlg()
{
    setupUi(this);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(testBeforeAccept()));
    connect(this, SIGNAL(fullyAccepted()), this, SLOT(accept()));
}
Ejemplo n.º 2
0
void PlyOpenDlg::applyAll()
{
	if (isValid())
	{
		saveContext(&s_lastContext);
		s_lastContext.applyAll = true;
		emit fullyAccepted();
	}
}
Ejemplo n.º 3
0
void PlyOpenDlg::testBeforeAccept()
{
    //we need at least two coordinates for a points (i.e. 2D)
    int zeroCoord=0;
    if (xComboBox->currentIndex()==0) ++zeroCoord;
    if (yComboBox->currentIndex()==0) ++zeroCoord;
    if (zComboBox->currentIndex()==0) ++zeroCoord;

    if (zeroCoord>1)
    {
        QMessageBox::warning(0, "Error", "At least two vertex coordinates (X,Y,Z) must be defined!");
        return;
    }

    //we must assure that no property is assigned to more than one field
    int n = xComboBox->count();
	int p = facesComboBox->count();
    assert(n+p>=2);
    int* assignedIndexCount = new int[n+p];
    memset(assignedIndexCount,0,(n+p)*sizeof(int));

    ++assignedIndexCount[xComboBox->currentIndex()];
    ++assignedIndexCount[yComboBox->currentIndex()];
    ++assignedIndexCount[zComboBox->currentIndex()];
    ++assignedIndexCount[rComboBox->currentIndex()];
    ++assignedIndexCount[gComboBox->currentIndex()];
    ++assignedIndexCount[bComboBox->currentIndex()];
    ++assignedIndexCount[iComboBox->currentIndex()];
    ++assignedIndexCount[sfComboBox->currentIndex()];
    ++assignedIndexCount[nxComboBox->currentIndex()];
    ++assignedIndexCount[nyComboBox->currentIndex()];
    ++assignedIndexCount[nzComboBox->currentIndex()];
    ++assignedIndexCount[facesComboBox->currentIndex() > 0 ? n+facesComboBox->currentIndex() : 0];
    ++assignedIndexCount[textCoordsComboBox->currentIndex() > 0 ? n+textCoordsComboBox->currentIndex() : 0];

	bool isValid = true;

    for (int i=1;i<n+p;++i)
        if (assignedIndexCount[i]>1)
        {
			isValid = false;
            QMessageBox::warning(0, "Error",
                QString("Can't assign same property to multiple fields! (%1)").arg(xComboBox->itemText(i)));
			break;
        }

    delete[] assignedIndexCount;
    assignedIndexCount=0;

	if (isValid)
		emit fullyAccepted();
}
Ejemplo n.º 4
0
PlyOpenDlg::PlyOpenDlg(QWidget* parent)
	: QDialog(parent)
	, Ui::PlyOpenDlg()
{
	setupUi(this);

	try
	{
		m_standardCombos.push_back(xComboBox);
		m_standardCombos.push_back(yComboBox);
		m_standardCombos.push_back(zComboBox);
		m_standardCombos.push_back(rComboBox);
		m_standardCombos.push_back(gComboBox);
		m_standardCombos.push_back(bComboBox);
		m_standardCombos.push_back(iComboBox);
		m_standardCombos.push_back(nxComboBox);
		m_standardCombos.push_back(nyComboBox);
		m_standardCombos.push_back(nzComboBox);

		m_sfCombos.push_back(sfComboBox);

		m_listCombos.push_back(facesComboBox);
		m_listCombos.push_back(textCoordsComboBox);

		m_singleCombos.push_back(texIndexComboBox);
	}
	catch(std::bad_alloc)
	{
		//not enough memory?! What can we do...
	}

	connect(addSFToolButton,	SIGNAL(clicked()),			this,	SLOT(addSFComboBox()));
	connect(applyButton,		SIGNAL(clicked()),			this,	SLOT(apply()));
	connect(applyAllButton,		SIGNAL(clicked()),			this,	SLOT(applyAll()));
	connect(cancelButton,		SIGNAL(clicked()),			this,	SLOT(reject()));
	connect(this,				SIGNAL(fullyAccepted()),	this,	SLOT(accept()));
}