rosout_text_filter_control.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #include "rosout_text_filter_control.h"
00031 #include "rosout_text_filter.h"
00032 
00033 #include <boost/bind.hpp>
00034 
00035 namespace rxtools
00036 {
00037 
00038 RosoutTextFilterControl::RosoutTextFilterControl(wxWindow* parent, const RosoutTextFilterPtr& filter)
00039 : RosoutTextFilterControlBase(parent, wxID_ANY)
00040 , filter_(filter)
00041 {
00042   filter_changed_connection_ = filter_->getChangedSignal().connect(boost::bind(&RosoutTextFilterControl::read, this));
00043 
00044   read();
00045 }
00046 
00047 void RosoutTextFilterControl::read()
00048 {
00049   regex_->SetValue(filter_->getUseRegex());
00050 
00051   uint32_t field_mask = filter_->getFieldMask();
00052   message_->SetValue(field_mask & RosoutTextFilter::Message);
00053   node_->SetValue(field_mask & RosoutTextFilter::Node);
00054   location_->SetValue(field_mask & RosoutTextFilter::Location);
00055   topics_->SetValue(field_mask & RosoutTextFilter::Topics);
00056 
00057   include_exclude_->SetSelection(filter_->getFilterType());
00058 
00059   text_->ChangeValue(wxString::FromAscii(filter_->getText().c_str()));
00060 
00061   setIncludeExcludeColor();
00062 }
00063 
00064 void RosoutTextFilterControl::setIncludeExcludeColor()
00065 {
00066   if (include_exclude_->GetSelection() == 0)
00067   {
00068     include_exclude_->SetBackgroundColour(wxColour(255, 238, 176));
00069   }
00070   else
00071   {
00072     include_exclude_->SetBackgroundColour(wxColour(198, 203, 255));
00073   }
00074 }
00075 
00076 void RosoutTextFilterControl::checkValid()
00077 {
00078   text_->SetBackgroundColour(wxNullColour);
00079   if (!filter_->isValid())
00080   {
00081     text_->SetBackgroundColour(wxColour(255, 99, 78));
00082   }
00083 }
00084 
00085 void RosoutTextFilterControl::onIncludeExclude( wxCommandEvent& event )
00086 {
00087   filter_changed_connection_.block();
00088   filter_->setFilterType((RosoutTextFilter::FilterType)include_exclude_->GetSelection());
00089   filter_changed_connection_.unblock();
00090 
00091   checkValid();
00092   setIncludeExcludeColor();
00093 }
00094 
00095 void RosoutTextFilterControl::onRegex( wxCommandEvent& event )
00096 {
00097   filter_changed_connection_.block();
00098   filter_->setUseRegex(event.IsChecked());
00099   filter_changed_connection_.unblock();
00100 
00101   checkValid();
00102 }
00103 
00104 void RosoutTextFilterControl::onText( wxCommandEvent& event )
00105 {
00106   filter_changed_connection_.block();
00107   filter_->setText((const char*)text_->GetValue().char_str());
00108   filter_changed_connection_.unblock();
00109 
00110   checkValid();
00111 }
00112 
00113 void RosoutTextFilterControl::onMessage( wxCommandEvent& event )
00114 {
00115   filter_changed_connection_.block();
00116   if (event.IsChecked())
00117   {
00118     filter_->addField(RosoutTextFilter::Message);
00119   }
00120   else
00121   {
00122     filter_->removeField(RosoutTextFilter::Message);
00123   }
00124   filter_changed_connection_.unblock();
00125 
00126   checkValid();
00127 }
00128 
00129 void RosoutTextFilterControl::onNode( wxCommandEvent& event )
00130 {
00131   filter_changed_connection_.block();
00132   if (event.IsChecked())
00133   {
00134     filter_->addField(RosoutTextFilter::Node);
00135   }
00136   else
00137   {
00138     filter_->removeField(RosoutTextFilter::Node);
00139   }
00140   filter_changed_connection_.unblock();
00141 
00142   checkValid();
00143 }
00144 
00145 void RosoutTextFilterControl::onLocation( wxCommandEvent& event )
00146 {
00147   filter_changed_connection_.block();
00148   if (event.IsChecked())
00149   {
00150     filter_->addField(RosoutTextFilter::Location);
00151   }
00152   else
00153   {
00154     filter_->removeField(RosoutTextFilter::Location);
00155   }
00156   filter_changed_connection_.unblock();
00157 
00158   checkValid();
00159 }
00160 
00161 void RosoutTextFilterControl::onTopics( wxCommandEvent& event )
00162 {
00163   filter_changed_connection_.block();
00164   if (event.IsChecked())
00165   {
00166     filter_->addField(RosoutTextFilter::Topics);
00167   }
00168   else
00169   {
00170     filter_->removeField(RosoutTextFilter::Topics);
00171   }
00172   filter_changed_connection_.unblock();
00173 
00174   checkValid();
00175 }
00176 
00177 }


rxtools
Author(s): Josh Faust, Rob Wheeler, Ken Conley
autogenerated on Mon Oct 6 2014 07:25:59