Skip to content
Permalink
Browse files
fix (partially) #44226 (#44723)
  • Loading branch information
vcloarec committed Aug 17, 2021
1 parent a4b1d0b commit 9a4f0f5d606915a4375b985f1afaee4a8a403f89
Showing with 59 additions and 51 deletions.
  1. +14 −4 src/app/mesh/qgsnewmeshlayerdialog.cpp
  2. +45 −47 src/ui/mesh/qgsnewmeshlayerdialogbase.ui
@@ -63,7 +63,7 @@ QgsNewMeshLayerDialog::QgsNewMeshLayerDialog( QWidget *parent, Qt::WindowFlags f
connect( mFormatComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, &QgsNewMeshLayerDialog::onFormatChanged );
connect( mFileWidget, &QgsFileWidget::fileChanged, this, &QgsNewMeshLayerDialog::onFilePathChanged );
connect( mEmptyMeshRadioButton, &QRadioButton::toggled, this, &QgsNewMeshLayerDialog::updateDialog );
connect( mInitializeMeshGroupBox, &QGroupBox::toggled, this, &QgsNewMeshLayerDialog::updateDialog );
connect( mMeshFileRadioButton, &QRadioButton::toggled, this, &QgsNewMeshLayerDialog::updateDialog );
connect( mMeshFromFileWidget, &QgsFileWidget::fileChanged, this, &QgsNewMeshLayerDialog::updateDialog );
connect( mMeshProjectComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsNewMeshLayerDialog::updateDialog );
@@ -107,7 +107,7 @@ void QgsNewMeshLayerDialog::updateSourceMeshframe()
{
mMeshProjectComboBox->setEnabled( false );
mMeshFromFileWidget->setEnabled( false );
if ( mEmptyMeshRadioButton->isChecked() )
if ( !mInitializeMeshGroupBox->isChecked() )
{
mSourceMeshFromFile.reset();
mSourceMeshFrameReady = true;
@@ -222,7 +222,7 @@ bool QgsNewMeshLayerDialog::apply()

QgsMeshLayer *source = nullptr;

if ( mEmptyMeshRadioButton->isChecked() )
if ( !mInitializeMeshGroupBox->isChecked() )
{
crs = mProjectionSelectionWidget->crs();
}
@@ -247,7 +247,17 @@ bool QgsNewMeshLayerDialog::apply()
result = providerMetadata->createMeshData( mesh, fileName, format, crs );
if ( result )
{
std::unique_ptr<QgsMeshLayer> newMeshLayer = std::make_unique<QgsMeshLayer>( fileName, mLayerNameLineEdit->text(), QStringLiteral( "mdal" ) );
QString layerName = mLayerNameLineEdit->text();
if ( layerName.isEmpty() )
{
layerName = fileName;
QFileInfo fileInfo( fileName );
layerName = fileInfo.baseName();
}
std::unique_ptr<QgsMeshLayer> newMeshLayer = std::make_unique<QgsMeshLayer>( fileName, layerName, QStringLiteral( "mdal" ) );

if ( newMeshLayer->crs() != crs )
newMeshLayer->setCrs( crs );

if ( newMeshLayer->isValid() )
QgsProject::instance()->addMapLayer( newMeshLayer.release(), true, true );
@@ -14,45 +14,42 @@
<string>New Mesh Layer</string>
</property>
<layout class="QGridLayout" name="gridLayout1">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<item row="4" column="1">
<widget class="QgsProjectionSelectionWidget" name="mProjectionSelectionWidget" native="true"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mLayerNameLineEdit">
<property name="text">
<string>Layer name</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mLayerNameLineEdit">
<property name="text">
<string>New mesh layer</string>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>File name</string>
<string>Layer name</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsFileWidget" name="mFileWidget" native="true"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>File format</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="mFormatComboBox"/>
</item>
<item row="3" column="1">
<widget class="QgsProjectionSelectionWidget" name="mProjectionSelectionWidget" native="true"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="mInitializeMeshGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -62,6 +59,12 @@
<property name="title">
<string>Initialize Mesh Using</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
@@ -75,52 +78,48 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<item row="1" column="1">
<widget class="QgsFileWidget" name="mMeshFromFileWidget" native="true"/>
</item>
<item row="0" column="1">
<widget class="QgsMapLayerComboBox" name="mMeshProjectComboBox"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTextBrowser" name="mInformationTextBrowser"/>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="mMeshFileRadioButton">
<property name="text">
<string>Mesh from file</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QRadioButton" name="mMeshProjectRadioButton">
<property name="text">
<string>Mesh from the current project</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="mEmptyMeshRadioButton">
<property name="text">
<string>Empty mesh</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsFileWidget" name="mMeshFromFileWidget" native="true"/>
</item>
<item row="1" column="1">
<widget class="QgsMapLayerComboBox" name="mMeshProjectComboBox"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QTextBrowser" name="mInformationTextBrowser"/>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<item row="3" column="1">
<widget class="QComboBox" name="mFormatComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>File name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsFileWidget" name="mFileWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
@@ -145,7 +144,6 @@
<tabstops>
<tabstop>mLayerNameLineEdit</tabstop>
<tabstop>mFormatComboBox</tabstop>
<tabstop>mEmptyMeshRadioButton</tabstop>
<tabstop>mMeshProjectRadioButton</tabstop>
<tabstop>mMeshProjectComboBox</tabstop>
<tabstop>mMeshFileRadioButton</tabstop>

0 comments on commit 9a4f0f5

Please sign in to comment.