コード例 #1
0
ファイル: RimGeoMechView.cpp プロジェクト: atgeirr/ResInsight
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateCurrentTimeStep()
{
    updateLegends();

    if (this->isTimeStepDependentDataVisible())
    {
        if (m_viewer)
        {
            cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
            if (frameScene)
            {
                // Grid model
                cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
                frameParts->setName("GridModel");
                m_vizLogic->appendPartsToModel(m_currentTimeStep, frameParts.p());
                frameParts->updateBoundingBoxesRecursive();

                this->removeModelByName(frameScene, frameParts->name());
                frameScene->addModel(frameParts.p());
            }
        }

        if (this->cellResult()->hasResult())
            m_vizLogic->updateCellResultColor(m_currentTimeStep(), this->cellResult());
        else
            m_vizLogic->updateStaticCellColors(m_currentTimeStep());

        if (this->cellResult()->hasResult())
            crossSectionCollection->updateCellResultColor(m_currentTimeStep);
        else
            crossSectionCollection->applySingleColorEffect();

    }
    else
    {
        m_vizLogic->updateStaticCellColors(-1);
        m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background
    }

    m_overlayInfoConfig()->update3DInfo();
}
コード例 #2
0
ファイル: RimGeoMechView.cpp プロジェクト: atgeirr/ResInsight
//--------------------------------------------------------------------------------------------------
/// Create display model,
/// or at least empty scenes as frames that is delivered to the viewer
/// The real geometry generation is done inside RivReservoirViewGeometry and friends
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::createDisplayModel()
{
   if (m_viewer.isNull()) return;

   if (!(m_geomechCase 
          && m_geomechCase->geoMechData() 
          && m_geomechCase->geoMechData()->femParts())) 
        return;

   int partCount = m_geomechCase->geoMechData()->femParts()->partCount();

   if (partCount <= 0) return;

   // Remove all existing animation frames from the viewer. 
   // The parts are still cached in the RivReservoir geometry and friends

   m_viewer->removeAllFrames();

   if (isTimeStepDependentDataVisible())
   {
       // Create empty frames in the viewer 

       int frameCount = geoMechCase()->geoMechData()->femPartResults()->frameCount();
       for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
       {
           cvf::ref<cvf::Scene> scene = new cvf::Scene;
           scene->addModel(new cvf::ModelBasicList);
           m_viewer->addFrame(scene.p());
       }
   }

   // Set the Main scene in the viewer. Used when the animation is in "Stopped" state

   cvf::ref<cvf::Scene> mainScene = new cvf::Scene;
   m_viewer->setMainScene(mainScene.p());

   // Grid model
   cvf::ref<cvf::ModelBasicList> mainSceneGridVizModel =  new cvf::ModelBasicList;
   mainSceneGridVizModel->setName("GridModel");
   m_vizLogic->appendNoAnimPartsToModel(mainSceneGridVizModel.p());
   mainSceneGridVizModel->updateBoundingBoxesRecursive();
   mainScene->addModel(mainSceneGridVizModel.p());

   // Well path model

   double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize();
   cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox();

   m_wellPathPipeVizModel->removeAllParts();
   addWellPathsToModel(m_wellPathPipeVizModel.p(),
                       cvf::Vec3d(0, 0, 0),
                       characteristicCellSize,
                       femBBox,
                       scaleTransform());

   m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p());


   // Cross sections

   m_crossSectionVizModel->removeAllParts();
   crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), scaleTransform());
   m_viewer->addStaticModelOnce(m_crossSectionVizModel.p());

   // If the animation was active before recreating everything, make viewer view current frame

   if (isTimeStepDependentDataVisible())
   {
        m_viewer->animationControl()->setCurrentFrameOnly(m_currentTimeStep);
        m_viewer->setCurrentFrame(m_currentTimeStep);
   }
   else
   {
       updateLegends();
       m_vizLogic->updateStaticCellColors(-1);
       m_overlayInfoConfig()->update3DInfo();
   }
}
コード例 #3
0
void SignalDataVisualizer::add2dPlotToChart(int _nodeLabel, STACCATO_VectorField_components _type) {
	// Preparing Plot Data
	xValues.clear();
	yValues.clear();

	for (int it = 0; it < myHMesh->myOutputDatabase->getTimeDescription(myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX).size(); it++) {
		if (myHMesh->myOutputDatabase->myAnalyses[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].type == STACCATO_Analysis_Static)
			xValues.push_back(0);
		else
			xValues.push_back(std::stoi(myHMesh->myOutputDatabase->getTimeDescription(myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX)[it]));
	}
	for (int i = 0; i < xValues.size(); i++) {
		yValues.push_back(myHMesh->myOutputDatabase->getVectorFieldFromDatabase()[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].getResultScalarFieldAtNodes(_type, i)[_nodeLabel]);
	}
	// Data Series
	mySeries2D = new QLineSeries();
	for (int i = 0; i < xValues.size(); i++) {
		mySeries2D->append(xValues[i], yValues[i]);;
	}
	if (_type == STACCATO_x_Re) {
		mySeries2D->setName(tr("Ux_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_y_Re) {
		mySeries2D->setName(tr("Uy_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_z_Re) {
		mySeries2D->setName(tr("Uz_Re Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_x_Im) {
		mySeries2D->setName(tr("Ux_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_y_Im) {
		mySeries2D->setName(tr("Uy_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	else if (_type == STACCATO_z_Im) {
		mySeries2D->setName(tr("Uz_Im Node ") + QString::fromStdString(std::to_string(_nodeLabel)));
	}
	mySeries2D->setPointsVisible(myPointVisibilityBox->isChecked());

	mySeriesList.append(mySeries2D);

	myChart2D->addSeries(mySeriesList.last());
	myChart2D->setTitle("Solution Distribution over Node");
	myChart2D->legend()->setAlignment(Qt::AlignBottom);				// Legend Alignment

	QPen pen(mySeriesList.last()->color());							// Line Width
	pen.setWidth(myLineWidthText->text().toDouble());
	mySeriesList.last()->setPen(pen);

	myAxisX->setTitleText("Frequency (in Hz)");
	myAxisX->setLabelFormat("%d");
	//myAxisX->setMinorTickCount(0);
	myAxisX->setTickCount(10);

	myAxisLogX->setTitleText("Frequency (in Hz), Log Scale");
	myAxisLogX->setLabelFormat("%g");
	myAxisLogX->setBase(10.0);
	myAxisLogX->setMinorTickCount(-1);

	// Chart Axes
	if (myHMesh->myOutputDatabase->myAnalyses[myVisualizerSetting->PROPERTY_CURRENT_ANALYSIS_INDEX].type == STACCATO_Analysis_Static)
	{
		myAxisX->setTitleText("Static");
		myAxisLogX->setTitleText("Static, Log Scale");
	}

	if (_type == STACCATO_x_Re || _type == STACCATO_y_Re || _type == STACCATO_z_Re || _type == STACCATO_x_Im || _type == STACCATO_y_Im || _type == STACCATO_z_Im) {
		myAxisY->setTitleText("Displacement");
	}
	else {
		myAxisY->setTitleText("Unrecognized Axis");
	}
	myAxisY->setLabelFormat("%d");

	// Set Connections
	connect(mySeriesList.last(), &QLineSeries::clicked, this, &SignalDataVisualizer::handleClickedPoint);
	connect(mySeriesList.last(), &QLineSeries::hovered, this, &SignalDataVisualizer::tooltip);

	enableInteractiveClick(mySeriesList.last());		// Enable Scattering

	// Axes-Chart Association
	myChart2D->addAxis(myAxisX, Qt::AlignBottom);
	myChart2D->setAcceptHoverEvents(true);
	myChart2D->addAxis(myAxisY, Qt::AlignLeft);

	chartView2D->setChart(myChart2D);
	chartView2D->setRenderHint(QPainter::Antialiasing);
	chartView2D->setMinimumSize(600, 300);

	myAxisX->setTickCount(mySeriesList.last()->count());
	mySeriesList.last()->attachAxis(myAxisX);
	//myAxisY->setTickCount(mySeries2D->count());
	mySeriesList.last()->attachAxis(myAxisY);
	mySeries2scatter->attachAxis(myAxisX);
	mySeries2scatter->attachAxis(myAxisY);
	mySnapSeries2scatter->attachAxis(myAxisX);
	mySnapSeries2scatter->attachAxis(myAxisY);

	updateLegends();

	// Coordinate Hover
	myCoordX = new QGraphicsSimpleTextItem(myChart2D);
	myCoordX->setPos(myChart2D->size().width() / 2 - 50, myChart2D->size().height());
	myCoordY = new QGraphicsSimpleTextItem(myChart2D);
	myCoordY->setPos(myChart2D->size().width() / 2 + 50, myChart2D->size().height());

	double yValueMinNew = *std::min_element(yValues.begin(), yValues.end());
	double yValueMaxNew = *std::max_element(yValues.begin(), yValues.end());
	
	autoScale(yValueMinNew, yValueMaxNew);
	if(myLogXAxisBox->isChecked()){
		myLogScaleTriggered();
	}
}