From 3812435e917cbe0baf1fac93e7d912f839915ee3 Mon Sep 17 00:00:00 2001
From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Fri, 5 Mar 2010 12:58:11 +0000
Subject: [PATCH] Gfx::Entity, fixed bug in SetSelection

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1769 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/gfx/src/entity.cc                  | 2 +-
 modules/gui/src/tools/tool_bar.cc          | 4 ++--
 modules/mol/base/src/query_view_wrapper.hh | 1 +
 modules/mol/base/src/view_op.cc            | 2 ++
 modules/mol/base/src/view_type_fw.hh       | 3 +++
 5 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc
index 45dbe8f70..27ebbe957 100644
--- a/modules/gfx/src/entity.cc
+++ b/modules/gfx/src/entity.cc
@@ -674,7 +674,7 @@ void Entity::SetDetailColor(const Color& col, const String& selection)
 /// \brief set selection
 void Entity::SetSelection(const mol::EntityView& view)
 {
-  if (!sel_.IsValid()) {
+  if (!view.IsValid()) {
     sel_=this->GetView().CreateEmptyView();
   } else {
     sel_=view;
diff --git a/modules/gui/src/tools/tool_bar.cc b/modules/gui/src/tools/tool_bar.cc
index b3cb11437..11621af0f 100644
--- a/modules/gui/src/tools/tool_bar.cc
+++ b/modules/gui/src/tools/tool_bar.cc
@@ -20,7 +20,7 @@
 #include <QDebug>
 #include <QActionGroup>
 
-
+#include <ost/mol/query_view_wrapper.hh>
 #include <ost/gui/tools/tool_manager.hh>
 #include <ost/gui/gosty_app.hh>
 #include "tool_bar.hh"
@@ -37,7 +37,7 @@ ToolBar::ToolBar(QWidget* parent):
           SLOT(ActivateTool(QAction*)));  
   connect(this, SIGNAL(actionTriggered(QAction*)),
           this,SLOT(OnAction(QAction*)));
-  connect(scene_win, SIGNAL(ActiveNodesChanged(gfx::NodePtrList)),
+  connect(scene_win, SIGNAL(ActiveNodesChanged(gfx::NodePtrList,gfx::EntityP,mol::QueryViewWrapperList)),
           this,SLOT(OnActiveGfxNodeChanged(gfx::NodePtrList)));
   connect(&ToolManager::Instance(), SIGNAL(ToolAdded(const Tool*&)),
           this, SLOT(OnToolAdded(const Tool*&)));          
diff --git a/modules/mol/base/src/query_view_wrapper.hh b/modules/mol/base/src/query_view_wrapper.hh
index 40aa3f981..e2dc1fc1b 100644
--- a/modules/mol/base/src/query_view_wrapper.hh
+++ b/modules/mol/base/src/query_view_wrapper.hh
@@ -19,6 +19,7 @@
 #ifndef OST_QUERY_VIEW_WRAPPER_HH
 #define OST_QUERY_VIEW_WRAPPER_HH
 
+#include <ost/mol/view_type_fw.hh>
 #include <ost/mol/module_config.hh>
 #include <ost/mol/entity_view.hh>
 #include <ost/mol/entity_handle.hh>
diff --git a/modules/mol/base/src/view_op.cc b/modules/mol/base/src/view_op.cc
index 88e964d92..c186931a7 100644
--- a/modules/mol/base/src/view_op.cc
+++ b/modules/mol/base/src/view_op.cc
@@ -109,7 +109,9 @@ mol::EntityView Difference(const mol::EntityView& ev1,
   if (ev1.GetHandle()!=ev2.GetHandle()) {
     throw IntegrityError(combining_not_allowed);
   }
+  if(ev2.GetChainCount()==0 && ev2.GetResidueCount()==0 && ev2.GetAtomCount()==0)return ev1.Copy();
   mol::EntityView diff=ev1.CreateEmptyView();
+  if(ev1.GetChainCount()==0 && ev1.GetResidueCount()==0 && ev1.GetAtomCount()==0)return diff;
   mol::ChainViewList::const_iterator c_it=ev1.GetChainList().begin();
   for ( ; c_it!=ev1.GetChainList().end(); ++c_it) {
     mol::ChainView cv=*c_it;
diff --git a/modules/mol/base/src/view_type_fw.hh b/modules/mol/base/src/view_type_fw.hh
index de600d79e..0916266f2 100644
--- a/modules/mol/base/src/view_type_fw.hh
+++ b/modules/mol/base/src/view_type_fw.hh
@@ -48,6 +48,9 @@ typedef boost::shared_ptr<EntityViewData> EntityViewDataPtr;
 typedef boost::weak_ptr<EntityViewData> EntityViewDataWeakPtr;
 typedef std::vector<EntityView> EntityViewList;
 
+class QueryViewWrapper;
+typedef std::vector<QueryViewWrapper> QueryViewWrapperList;
+
 /// \brief Flags to control the behaviour when adding handles to views.
 struct ViewAddFlag {
   typedef enum {
-- 
GitLab