Mark,

> There is only one side-effect that I haven't been able to work around:
> Updating the vtkDataArraySelection in this manner *will* cause the
> reader panel to notice that it has been changed (lighting up the Apply
> button). Pressing the Reset button fixes that while still retaining the
> changes that your custom Qt bits did.
> 
> It would still be nice to figure how to avoid this last bit.
> Perhaps someone from the mailing list, or from KitWare, has a good
> suggestion.

I haven't taken the problem so serious since (as you say) it can be
easily cancelled by pressing Reset, but if you do really care (I
recall you mentioned the problem some time ago as well), it looks like
it is because the client side essentially is not made to respect the
(un)modified state of the vtkDataArraySelection in the server side. As
you well know, vtkDataArraySelection remains unmodified when a new
array is added by AddArray(). If I try to fix the problem by somewhat
emulating the behavior in client side, it could be as attached
(pqSignalAdaptorSelectionTreeWidget.cxx.diff).

But I am unsure if it is a right fix and will not cause any unintended
side effects. Perhaps someone from the mailing list, or from KitWare,
has a good suggestion. :)

Anyway, I submitted a bug: http://paraview.org/Bug/view.php?id=10462

Takuya

Takuya OSHIMA, Ph.D.
Faculty of Engineering, Niigata University
8050 Ikarashi-Ninocho, Nishi-ku, Niigata, 950-2181, JAPAN

From: "Mark Olesen" <[email protected]>
Subject: Re: [Paraview] Custom Reader Issue
Date: Wed, 24 Mar 2010 13:21:45 +0100

> On Wed, 2010-03-24 at 12:02 +0000, Adriano Gagliardi wrote:
>> Yeah, that's what I am using at the moment. However, when I select my mesh
>> file initially using File->Open, RequestInformation is called. At this point
>> in time, no data file has been selected. I then have a vtkSetStringMacro
>> that allows me to browse for a second input file (the data file). However,
>> for this to then be read in to obtain the variables contained within (hence
>> populate the point array table), I need to click apply again so that
>> RequestInformation is called. I was just wondering if there was a workaround
>> so I could avoid having to reapply the filter.
> 
> Yes and no.
> 
> You should take a look at how to write custom panels
> http://www.cmake.org/Wiki/CustomObjectPanels
> 
> This will let you add various Qt elements to the reader panel.
> If you mark their corresponding properties with << is_internal="1" >> in
> the SM xml, you can set/unset the values directly.
> One of the elements could, for example, be used to populate/repopulate
> some vtkDataArraySelection containers.
> 
> For these purposes, inheriting from pqAutoGeneratedObjectPanel should be
> sufficient.
> 
> There is only one side-effect that I haven't been able to work around:
> Updating the vtkDataArraySelection in this manner *will* cause the
> reader panel to notice that it has been changed (lighting up the Apply
> button). Pressing the Reset button fixes that while still retaining the
> changes that your custom Qt bits did.
> 
> It would still be nice to figure how to avoid this last bit.
> Perhaps someone from the mailing list, or from KitWare, has a good
> suggestion.
> 
> /mark
Index: Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx
===================================================================
RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx,v
retrieving revision 1.8
diff -u -r1.8 pqSignalAdaptorSelectionTreeWidget.cxx
--- Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx	10 Nov 2008 15:43:43 -0000	1.8
+++ Qt/Components/pqSignalAdaptorSelectionTreeWidget.cxx	26 Mar 2010 03:49:10 -0000
@@ -97,9 +97,10 @@
   QObject::connect(this->Internal->TreeWidget->model(),
     SIGNAL(modelReset()),
     this, SIGNAL(valuesChanged()));
-  QObject::connect(this->Internal->TreeWidget->model(),
-    SIGNAL(rowsInserted(const QModelIndex&, int, int)),
-    this, SIGNAL(valuesChanged()));
+  // No signal emission when new items are appended
+  // QObject::connect(this->Internal->TreeWidget->model(),
+  //   SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+  //   this, SIGNAL(valuesChanged()));
   QObject::connect(this->Internal->TreeWidget->model(),
     SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
     this, SIGNAL(valuesChanged()));
@@ -181,7 +182,7 @@
   QList<QList<QVariant> > oldValues = this->values();
 
   bool equal = true;
-  if(oldValues.size() == newDomain.size())
+  if(oldValues.size() <= newDomain.size())
     {
     for(int i=0; equal && i<oldValues.size(); i++)
       {
@@ -196,20 +197,28 @@
     equal = false;
     }
 
-  if(equal)
+  if(equal && oldValues.size() == newDomain.size())
     {
     return;
     }
- 
+
   // Domain changes should not change the property values. This is overriding
   // the value loaded from state files etc.
   // this->Internal->Property->ResetToDefault();
-  
+
   QList<QList<QVariant> > newValues =
     pqSMAdaptor::getSelectionProperty(this->Internal->Property);
 
-  // Now update the tree widget. We hide any elements no longer in the domain.
-  this->Internal->TreeWidget->clear();
+  if(equal)
+    {
+    // Erase items that are already in the widget
+    newValues.erase(newValues.begin(), newValues.begin() + oldValues.size());
+    }
+  else
+    {
+    // Now update the tree widget. We hide any elements no longer in the domain.
+    this->Internal->TreeWidget->clear();
+    }
 
   foreach (QList<QVariant> newValue, newValues)
     {
@@ -218,13 +227,16 @@
       {
       item = (*this->ItemCreatorFunctionPtr)(this->Internal->TreeWidget, 
         QStringList(newValue[0].toString()));
+      item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
       }
     if (!item)
       {
-      item  = new QTreeWidgetItem(this->Internal->TreeWidget,
-        QStringList(newValue[0].toString()));
+      item  = new QTreeWidgetItem(QStringList(newValue[0].toString()));
+      // Set check state before insertion in order to avoid
+      // dataChanged() to be triggered
+      item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
+      this->Internal->TreeWidget->addTopLevelItem(item);
       }
-    item->setCheckState(0, newValue[1].toInt() ? Qt::Checked : Qt::Unchecked);
     }
 }
 
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to