@@ -956,7 +956,10 @@ bool GraphicsView::addComponent(QString className, QPointF position)
956956 ModelInstance::Component *pComponent = new ModelInstance::Component (pModelInstance);
957957 pComponent->setName (name);
958958 pComponent->setType (pLibraryTreeItem->getNameStructure ());
959- pComponent->setModel (new ModelInstance::Model (MainWindow::instance ()->getOMCProxy ()->getModelInstance (pLibraryTreeItem->getNameStructure ())));
959+ /* We use getModelInstanceIcon here for bettter performance
960+ * This model will be updated right after this so it doesn't matter if the Component has complete model or not.
961+ */
962+ pComponent->setModel (new ModelInstance::Model (MainWindow::instance ()->getOMCProxy ()->getModelInstance (pLibraryTreeItem->getNameStructure (), false , true )));
960963 pModelInstance->addElement (pComponent);
961964 ModelInfo oldModelInfo = mpModelWidget->createModelInfo ();
962965 addElementToView (pComponent, false , true , true , position);
@@ -5810,9 +5813,24 @@ void ModelWidget::loadModelInstance(bool icon, const ModelInfo &modelInfo)
58105813{
58115814 // save the current ModelInstance pointer so we can delete it later.
58125815 ModelInstance::Model *pOldModelInstance = mpModelInstance;
5816+ // call getModelInstance
5817+ const QJsonObject jsonObject = MainWindow::instance ()->getOMCProxy ()->getModelInstance (mpLibraryTreeItem->getNameStructure (), false , icon);
5818+
5819+ QElapsedTimer timer;
5820+ timer.start ();
58135821 // set the new ModelInstance
5814- mpModelInstance = new ModelInstance::Model (MainWindow::instance ()->getOMCProxy ()->getModelInstance (mpLibraryTreeItem->getNameStructure (), false , icon));
5822+ mpModelInstance = new ModelInstance::Model (jsonObject);
5823+ if (MainWindow::instance ()->isNewApiProfiling ()) {
5824+ qDebug () << " Time for parsing JSON" << (double )timer.elapsed () / 1000.0 << " secs" ;
5825+ }
5826+
5827+ timer.restart ();
5828+ // drawing
58155829 drawModel (modelInfo);
5830+ if (MainWindow::instance ()->isNewApiProfiling ()) {
5831+ qDebug () << " Time for drawing graphical objects" << (double )timer.elapsed () / 1000.0 << " secs" ;
5832+ }
5833+
58165834 // delete the old ModelInstance
58175835 if (pOldModelInstance) {
58185836 delete pOldModelInstance;
0 commit comments