//---------------------------------------------------------------
    void DocumentExporter::exportMaxScene()
    {
        mStreamWriter.startDocument();

		createExporters();

		exportAsset();
		exportEffects();
		exportMaterials();
		exportGeometries();
		exportControllers();
		exportCameras();
		exportLights();
		exportImages();
		exportVisualScenes();
		if ( mOptions.getExportAnimations() )
			exportAnimations();
		exportScene();

		deleteExporters();

        mStreamWriter.endDocument();

		const ExportSceneGraph::XRefSceneGraphList& sceneGraphList = mExportSceneGraph->getXRefSceneGraphList();

		for ( ExportSceneGraph::XRefSceneGraphList::const_iterator it = sceneGraphList.begin(); it!=sceneGraphList.end(); ++it )
		{
			NativeString outputFileName(NativeString(getXRefOutputPath(*it)));
			DocumentExporter document(mMaxInterface, it->exportSceneGraph, outputFileName, mOptions, mExportOnlySelected);
			document.exportMaxScene();
		}
    }
Esempio n. 2
0
MaterialXMLExportDialog::MaterialXMLExportDialog(MaterialListModel* model,
                                                 QWidget *parent) :
    QDialog(parent),
    model_(model),
    allItemsChecked_(true),
    exportMode_(ANSYS)
{
    QVBoxLayout * layout = new QVBoxLayout(this);
    layout->setContentsMargins(1, 1, 1, 1);
    setLayout(layout);

    materialView_ = new QTableWidget(model_->getMaterialCount(), 2, this);
    materialView_->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Material")));
    materialView_->setColumnWidth(0, 400);
    materialView_->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Description")));
    materialView_->setSelectionBehavior(QAbstractItemView::SelectItems);
    materialView_->setSelectionMode(QAbstractItemView::NoSelection);

    materialView_->setAcceptDrops(false);
    materialView_->setDropIndicatorShown(false);
    materialView_->setDragDropMode(QAbstractItemView::NoDragDrop);

    materialView_->setAlternatingRowColors(true);
    materialView_->horizontalHeader()->setStretchLastSection(true);
    connect(materialView_->horizontalHeader(), SIGNAL(sectionDoubleClicked(int)),
            this, SLOT(headerViewDoubleClicked(int)));

    materialView_->setMinimumWidth(700);
    materialView_->setMinimumHeight(400);

    int row = 0;
    const std::vector<Material*>& list = model_->getMaterials();
    for (std::vector<Material*>::const_iterator it = list.begin();
         it!=list.end();
         ++it) {
        Material *mat = *it;

        QTableWidgetItem * item;
        item = new MaterialTableItem(mat, QTableWidgetItem::UserType+100);
        item->setText(mat->getName());
        item->setCheckState(Qt::Checked);
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
        materialView_->setItem(row, 0, item);

        item = new QTableWidgetItem(mat->getDescription());
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        materialView_->setItem(row, 1, item);

        row++;
    }

    layout->addWidget(materialView_);

    QWidget *buttons = new QWidget(this);
    QHBoxLayout *buttonLayout = new QHBoxLayout(buttons);
    buttonLayout->setContentsMargins(1, 1, 1, 1);
    buttons->setLayout(buttonLayout);

    buttonLayout->addWidget(new QLabel(tr("Export Mode:"), buttons));

    QButtonGroup* group = new QButtonGroup(buttons);
    connect(group, SIGNAL(buttonClicked(QAbstractButton*)),
            this, SLOT(modeChanged(QAbstractButton*)));

    modeANSYSbutton_ = new QRadioButton("ANSYS", buttons);
    modeANSYSbutton_->setMinimumHeight(1.2*modeANSYSbutton_->minimumSizeHint().height());
    //group->addButton(modeANSYSbutton_, 0);
    buttonLayout->addWidget(modeANSYSbutton_);
    modeANSYSbutton_->setChecked(true);

    modeMATMLbutton_ = new QRadioButton("MatML", buttons);
    modeMATMLbutton_->setMinimumHeight(1.2*modeMATMLbutton_->minimumSizeHint().height());
    //group->addButton(modeMATMLbutton_, 1);
    buttonLayout->addWidget(modeMATMLbutton_);

    layout->addWidget(buttons);

    buttons = new QWidget(this);
    buttonLayout = new QHBoxLayout(buttons);
    buttonLayout->setContentsMargins(1,1,1,1);
    buttons->setLayout(buttonLayout);

    buttonLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));

    QPushButton *button;

    button = new QPushButton(tr("Export"), buttons);
    //button->setFlat(true);
    button->setDefault(false);
    connect(button, SIGNAL(clicked()),
            this, SLOT(exportMaterials()));
    buttonLayout->addWidget(button);

    button = new QPushButton(tr("Cancel"), buttons);
    //button->setFlat(true);
    button->setDefault(true);
    connect(button, SIGNAL(clicked()),
            this, SLOT(reject()));
    buttonLayout->addWidget(button);

    layout->addWidget(buttons);

    updateGeometry();
}
    //---------------------------------------
    MaterialMap* MaterialExporter::getExportedMaterialsMap()
    {
        if ( !materialMapInitialized ) exportMaterials ( false );

        return &mMaterialMap;
    }