<commit_before>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                      API Library for libparaver-kernel                    *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in hope that it will be      *
 *   \  \__         useful but WITHOUT ANY WARRANTY; without even the        *
 *    \___          implied warranty of MERCHANTABILITY or FITNESS FOR A     *
 *                  PARTICULAR PURPOSE. See the GNU LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *\
 | @file: $HeadURL$
 | @last_commit: $Date$
 | @version:     $Revision$
\* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */

#include "eventlabels.h"

#ifdef OLD_PCFPARSER
#include "utils/pcfparser/old/ParaverEventType.h"
#include "utils/pcfparser/old/ParaverEventValue.h"
#endif

using namespace std;

const string EventLabels::unknownLabel = "Unknown";

EventLabels::EventLabels()
{}

#ifdef OLD_PCFPARSER

EventLabels::EventLabels( const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/
}

EventLabels::EventLabels( const libparaver::ParaverTraceConfig& config,
                          const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/

  const vector<ParaverEventType *>& types = config.get_eventTypes();
  for ( vector<ParaverEventType *>::const_iterator it = types.begin();
        it != types.end(); ++it )
  {
    eventType2Label[ ( *it )->get_key() ] = ( *it )->get_description();
    label2eventType[ ( *it )->get_description().c_str() ] = ( *it )->get_key();
    eventValue2Label[ ( *it )->get_key() ] = map<TEventValue, string>();
    const vector<ParaverEventValue *>& values = ( *it )->get_eventValues();
    for ( vector<ParaverEventValue *>::const_iterator itVal = values.begin();
          itVal != values.end(); ++itVal )
    {
      ( eventValue2Label[ ( *it )->get_key() ] )[ ( *itVal )->get_key() ] =
        ( *itVal )->get_value();

      multimap< TEventType, TEventValue >& tmpEventMap = label2eventValue[ ( *itVal )->get_value().c_str() ];
      tmpEventMap.insert( make_pair( ( *it )->get_key(), ( *itVal )->get_key() ) );
    }
  }
}

#else

EventLabels::EventLabels( const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/
}

EventLabels::EventLabels( const libparaver::UIParaverTraceConfig& config,
                          const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/

  try
  {
    const vector<unsigned int>& types = config.getEventTypes();
    for ( vector<unsigned int>::const_iterator it = types.begin(); it != types.end(); ++it )
    {
      eventType2Label[ *it ] = config.getEventType( *it );
      label2eventType[ config.getEventType( *it ).c_str() ] = *it;
      eventValue2Label[ *it ] = map<TEventValue, string>();
      try
      {
        vector<unsigned int> values = config.getEventValues( *it );
        for ( vector<unsigned int>::const_iterator itVal = values.begin(); itVal != values.end(); ++itVal )
        {
          ( eventValue2Label[ *it ] )[ *itVal ] = config.getEventValue( *it, *itVal );

          multimap< TEventType, TEventValue >& tmpEventMap = label2eventValue[ config.getEventValue( *it, *itVal ).c_str() ];
          tmpEventMap.insert( make_pair( *it, *itVal ) );
        }
      }
      catch( libparaver::UIParaverTraceConfig::value_not_found )
      {
      }
    }
  }
  catch( libparaver::UIParaverTraceConfig::value_not_found )
  {
  }
}

#endif

EventLabels::~EventLabels()
{}

void EventLabels::getTypes( vector<TEventType>& onVector ) const
{
  for ( map<TEventType, string>::const_iterator it = eventType2Label.begin();
        it != eventType2Label.end(); ++it )
    onVector.push_back( ( *it ).first );
}

bool EventLabels::getEventTypeLabel( TEventType type, string& onStr ) const
{
  map<TEventType, string>::const_iterator it = eventType2Label.find( type );
  if ( it == eventType2Label.end() )
  {
    onStr = unknownLabel;
    return false;
  }
  onStr = ( *it ).second;
  return true;
}

bool EventLabels::getEventValueLabel( TEventType type, TEventValue value, string& onStr ) const
{
  map<TEventType, map<TEventValue, string> >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    //onStr = unknownLabel;
    onStr.clear();
    return false;
  }
  map<TEventValue, string>::const_iterator itVal = ( *it ).second.find( value );
  if ( itVal == ( *it ).second.end() )
  {
    //onStr = unknownLabel;
    onStr.clear();
    return false;
  }
  onStr = ( *itVal ).second;
  return true;
}

bool EventLabels::getEventValueLabel( TEventValue value, string& onStr ) const
{
  bool found = false;

  map<TEventType, map<TEventValue, string> >::const_iterator it = eventValue2Label.begin();
  while ( !found && it != eventValue2Label.end() )
  {
    map<TEventValue, string>::const_iterator itVal = ( *it ).second.find( value );
    if ( itVal != ( *it ).second.end() )
    {
      onStr = ( *itVal ).second;
      found = true;
    }
    ++it;
  }

  return found;
}

bool EventLabels::getValues( TEventType type, vector<string> &values ) const
{
  map< TEventType, map< TEventValue, string > >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    //onStr = unknownLabel;
    return false;
  }
  else
  {
    for ( map< TEventValue, string >::const_iterator it2 = (*it).second.begin(); it2 != (*it).second.end(); ++it2 )
      values.push_back((*it2).second );
  }

  return true;
}

bool EventLabels::getValues( TEventType type, map<TEventValue, string> &values ) const
{
  map< TEventType, map< TEventValue, string > >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    //onStr = unknownLabel;
    return false;
  }
  else
  {
    for ( map<TEventValue, string>::const_iterator it2 = (*it).second.begin(); it2 != (*it).second.end(); ++it2 )
      values[ (*it2).first ] = (*it2).second;
  }

  return true;
}

bool EventLabels::getEventType( const string& whichTypeLabel, TEventType& onType ) const
{
  hash_map<const char *, TEventType, hash<const char *> >::const_iterator it = label2eventType.find( whichTypeLabel.c_str() );
  if( it == label2eventType.end() )
    return false;

  onType = (*it).second;
  return true;
}

bool EventLabels::getEventValue( const string& whichValueLabel, multimap< TEventType, TEventValue >& onMap ) const
{
  hash_map<const char *, multimap< TEventType, TEventValue >, hash<const char *> >::const_iterator it = label2eventValue.find( whichValueLabel.c_str() );

  if( it == label2eventValue.end() )
    return false;

  onMap = (*it).second;
  return true;
}
<commit_msg>Restored 'unknown' label for not found event values<commit_after>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                      API Library for libparaver-kernel                    *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in hope that it will be      *
 *   \  \__         useful but WITHOUT ANY WARRANTY; without even the        *
 *    \___          implied warranty of MERCHANTABILITY or FITNESS FOR A     *
 *                  PARTICULAR PURPOSE. See the GNU LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *\
 | @file: $HeadURL$
 | @last_commit: $Date$
 | @version:     $Revision$
\* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */

#include "eventlabels.h"

#ifdef OLD_PCFPARSER
#include "utils/pcfparser/old/ParaverEventType.h"
#include "utils/pcfparser/old/ParaverEventValue.h"
#endif

using namespace std;

const string EventLabels::unknownLabel = "Unknown";

EventLabels::EventLabels()
{}

#ifdef OLD_PCFPARSER

EventLabels::EventLabels( const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/
}

EventLabels::EventLabels( const libparaver::ParaverTraceConfig& config,
                          const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/

  const vector<ParaverEventType *>& types = config.get_eventTypes();
  for ( vector<ParaverEventType *>::const_iterator it = types.begin();
        it != types.end(); ++it )
  {
    eventType2Label[ ( *it )->get_key() ] = ( *it )->get_description();
    label2eventType[ ( *it )->get_description().c_str() ] = ( *it )->get_key();
    eventValue2Label[ ( *it )->get_key() ] = map<TEventValue, string>();
    const vector<ParaverEventValue *>& values = ( *it )->get_eventValues();
    for ( vector<ParaverEventValue *>::const_iterator itVal = values.begin();
          itVal != values.end(); ++itVal )
    {
      ( eventValue2Label[ ( *it )->get_key() ] )[ ( *itVal )->get_key() ] =
        ( *itVal )->get_value();

      multimap< TEventType, TEventValue >& tmpEventMap = label2eventValue[ ( *itVal )->get_value().c_str() ];
      tmpEventMap.insert( make_pair( ( *it )->get_key(), ( *itVal )->get_key() ) );
    }
  }
}

#else

EventLabels::EventLabels( const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/
}

EventLabels::EventLabels( const libparaver::UIParaverTraceConfig& config,
                          const set<TEventType>& eventsLoaded )
{
/*  for ( set<TEventType>::const_iterator it = eventsLoaded.begin();
        it != eventsLoaded.end(); ++it )
    eventType2Label[ *it ] = unknownLabel + " type ";*/

  try
  {
    const vector<unsigned int>& types = config.getEventTypes();
    for ( vector<unsigned int>::const_iterator it = types.begin(); it != types.end(); ++it )
    {
      eventType2Label[ *it ] = config.getEventType( *it );
      label2eventType[ config.getEventType( *it ).c_str() ] = *it;
      eventValue2Label[ *it ] = map<TEventValue, string>();
      try
      {
        vector<unsigned int> values = config.getEventValues( *it );
        for ( vector<unsigned int>::const_iterator itVal = values.begin(); itVal != values.end(); ++itVal )
        {
          ( eventValue2Label[ *it ] )[ *itVal ] = config.getEventValue( *it, *itVal );

          multimap< TEventType, TEventValue >& tmpEventMap = label2eventValue[ config.getEventValue( *it, *itVal ).c_str() ];
          tmpEventMap.insert( make_pair( *it, *itVal ) );
        }
      }
      catch( libparaver::UIParaverTraceConfig::value_not_found )
      {
      }
    }
  }
  catch( libparaver::UIParaverTraceConfig::value_not_found )
  {
  }
}

#endif

EventLabels::~EventLabels()
{}

void EventLabels::getTypes( vector<TEventType>& onVector ) const
{
  for ( map<TEventType, string>::const_iterator it = eventType2Label.begin();
        it != eventType2Label.end(); ++it )
    onVector.push_back( ( *it ).first );
}

bool EventLabels::getEventTypeLabel( TEventType type, string& onStr ) const
{
  map<TEventType, string>::const_iterator it = eventType2Label.find( type );
  if ( it == eventType2Label.end() )
  {
    onStr = unknownLabel;
    return false;
  }
  onStr = ( *it ).second;
  return true;
}

bool EventLabels::getEventValueLabel( TEventType type, TEventValue value, string& onStr ) const
{
  map<TEventType, map<TEventValue, string> >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    onStr = unknownLabel;
    return false;
  }
  map<TEventValue, string>::const_iterator itVal = ( *it ).second.find( value );
  if ( itVal == ( *it ).second.end() )
  {
    onStr = unknownLabel;
    return false;
  }
  onStr = ( *itVal ).second;
  return true;
}

bool EventLabels::getEventValueLabel( TEventValue value, string& onStr ) const
{
  bool found = false;

  map<TEventType, map<TEventValue, string> >::const_iterator it = eventValue2Label.begin();
  while ( !found && it != eventValue2Label.end() )
  {
    map<TEventValue, string>::const_iterator itVal = ( *it ).second.find( value );
    if ( itVal != ( *it ).second.end() )
    {
      onStr = ( *itVal ).second;
      found = true;
    }
    ++it;
  }

  return found;
}

bool EventLabels::getValues( TEventType type, vector<string> &values ) const
{
  map< TEventType, map< TEventValue, string > >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    return false;
  }
  else
  {
    for ( map< TEventValue, string >::const_iterator it2 = (*it).second.begin(); it2 != (*it).second.end(); ++it2 )
      values.push_back((*it2).second );
  }

  return true;
}

bool EventLabels::getValues( TEventType type, map<TEventValue, string> &values ) const
{
  map< TEventType, map< TEventValue, string > >::const_iterator it = eventValue2Label.find( type );
  if ( it == eventValue2Label.end() )
  {
    return false;
  }
  else
  {
    for ( map<TEventValue, string>::const_iterator it2 = (*it).second.begin(); it2 != (*it).second.end(); ++it2 )
      values[ (*it2).first ] = (*it2).second;
  }

  return true;
}

bool EventLabels::getEventType( const string& whichTypeLabel, TEventType& onType ) const
{
  hash_map<const char *, TEventType, hash<const char *> >::const_iterator it = label2eventType.find( whichTypeLabel.c_str() );
  if( it == label2eventType.end() )
    return false;

  onType = (*it).second;
  return true;
}

bool EventLabels::getEventValue( const string& whichValueLabel, multimap< TEventType, TEventValue >& onMap ) const
{
  hash_map<const char *, multimap< TEventType, TEventValue >, hash<const char *> >::const_iterator it = label2eventValue.find( whichValueLabel.c_str() );

  if( it == label2eventValue.end() )
    return false;

  onMap = (*it).second;
  return true;
}
<|endoftext|>


<commit_before>#include "stdafx.h"
#include "Digitizer.h"
#include "ShapeEditor.h"
#include "EditorHelper.h"
#include "ShapefileHelper.h"

// ************************************************************
//		Start
// ************************************************************
void Digitizer::StartNewBoundShape(CShapeEditor* editor, IShapefile* sf, long layerHandle)
{
	if (!editor || !sf || layerHandle == -1) return;

	ShpfileType shpType;
	sf->get_ShapefileType(&shpType);

	editor->Clear();
	editor->put_ShapeType(shpType);
	editor->put_LayerHandle(layerHandle);
	editor->put_EditorState(esDigitize);

	CComPtr<IShapeDrawingOptions> options = NULL;
	sf->get_DefaultDrawingOptions(&options);
	editor->CopyOptionsFrom(options);
	return;
}

// ************************************************************
//		OnMouseDown
// ************************************************************
bool Digitizer::OnMouseDown(CShapeEditor* editor, double projX, double projY, bool ctrl)
{
	if (!editor) return false;

	// an attempt to finish shape
	if (ctrl) {
		return editor->TryStop();
	}

	// add another point
	editor->HandleProjPointAdd(projX, projY);
	editor->SetRedrawNeeded(rtShapeEditor);

	// for point layer save the new shape at once
	if (EditorHelper::GetShapeType2D(editor) == SHP_POINT)
	{
		return editor->TryStop();
	}

	return true;
}<commit_msg>MWGIS-138; fix 'select by polygon' tool, adding last point before validating<commit_after>#include "stdafx.h"
#include "Digitizer.h"
#include "ShapeEditor.h"
#include "EditorHelper.h"
#include "ShapefileHelper.h"

// ************************************************************
//		Start
// ************************************************************
void Digitizer::StartNewBoundShape(CShapeEditor* editor, IShapefile* sf, long layerHandle)
{
	if (!editor || !sf || layerHandle == -1) return;

	ShpfileType shpType;
	sf->get_ShapefileType(&shpType);

	editor->Clear();
	editor->put_ShapeType(shpType);
	editor->put_LayerHandle(layerHandle);
	editor->put_EditorState(esDigitize);

	CComPtr<IShapeDrawingOptions> options = NULL;
	sf->get_DefaultDrawingOptions(&options);
	editor->CopyOptionsFrom(options);
	return;
}

// ************************************************************
//		OnMouseDown
// ************************************************************
bool Digitizer::OnMouseDown(CShapeEditor* editor, double projX, double projY, bool ctrl)
{
	if (!editor) return false;

	// add another point
	editor->HandleProjPointAdd(projX, projY);
	editor->SetRedrawNeeded(rtShapeEditor);

	// for point layer save the new shape at once
	if (EditorHelper::GetShapeType2D(editor) == SHP_POINT)
	{
		return editor->TryStop();
	}
    else if (ctrl)
    {
        // if an attempt to finish a multipoint shape
        return editor->TryStop();
    }

	return true;
}<|endoftext|>


<commit_before>#include <votca/tools/version.h>
#include <iostream>
#include "version.h"

namespace votca { namespace csg {

static const std::string version_str = "VERSION NOT SET (compiled " __DATE__ ", " __TIME__ ")";

const std::string &CsgVersionStr()
{
    return version_str;
}

void HelpTextHeader(const std::string &tool_name)
{
    std::cout << tool_name << ", version " << votca::csg::CsgVersionStr()
         << "\nvotca_tools, version " << votca::tools::ToolsVersionStr()
         << "\n\n";
}

}}

<commit_msg>updated help header<commit_after>#include <votca/tools/version.h>
#include <iostream>
#include "version.h"

namespace votca { namespace csg {

static const std::string version_str = "VERSION NOT SET (compiled " __DATE__ ", " __TIME__ ")";

const std::string &CsgVersionStr()
{
    return version_str;
}

void HelpTextHeader(const std::string &tool_name)
{
    std::cout <<
         << "\tVOTCA ( http://www.votca.org )\n"
         << tool_name << ", version " << votca::csg::CsgVersionStr()
         << "\nvotca_tools, version " << votca::tools::ToolsVersionStr()
         << "\n\n";
}

}}

<|endoftext|>


<commit_before>
/*
  Morse - Arduino libary to create Morse code on any output pin.
  Copyright (c) 2015 Hermann-Josef Mathes.  All right reserved.

  Contributors:
  - add your name and eMail address

  Project home: https://github.com/thjm/morse

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "Morse.h"

typedef struct _MorseCode_t {

  byte code;
  byte len;

} MorseCode_t;

// Morse code table for ASCII characters 0x20 .. 0x5f
// 1st byte : code, 0=dit, 1=dah
// 2nd byte : number of dits/dahs
// For the idea of this table, see:
// http://www.avr-asm-tutorial.net/cq-dl/teil4/Cw01_200.asm
// �2002 by Gerhard Schmidt, DG4FAC
static const MorseCode_t gMorseCode[] PROGMEM = {

  // 0x20 .. 0x2F
  { 0b00000000, 0 }, // Blank
  { 0b01000000, 5 }, // ! = Warten
  { 0b01001000, 6 }, // "
  { 0b11011000, 5 }, // # = ~n
  { 0b01101000, 5 }, // $ = �, �a
  { 0b01000000, 5 }, // % = �
  { 0b00000000, 0 }, // & = not used
  { 0b01111000, 6 }, // '
  { 0b10110000, 5 }, // (, KN
  { 0b10110100, 6 }, // ), KK
  { 0b00000000, 0 }, // * = not used
  { 0b01010000, 5 }, // + = Spruchende, AR
  { 0b11001100, 6 }, // ,
  { 0b10000100, 6 }, // -
  { 0b01010100, 6 }, // .
  { 0b10010000, 5 }, // /
  // 0x30 .. 0x3F
  { 0b11111000, 5 }, // 0
  { 0b01111000, 5 }, // 1
  { 0b00111000, 5 }, // 2
  { 0b00011000, 5 }, // 3
  { 0b00001000, 5 }, // 4
  { 0b00000000, 5 }, // 5
  { 0b10000000, 5 }, // 6
  { 0b11000000, 5 }, // 7
  { 0b11100000, 5 }, // 8
  { 0b11110000, 5 }, // 9
  { 0b11100000, 6 }, // :
  { 0b10101000, 6 }, // ;
  { 0b10101000, 5 }, // < = Verkehrsanfang
  { 0b10001000, 5 }, // =
  { 0b01010000, 5 }, // > = Verkehrsende
  { 0b00110000, 6 }, // ?
  // 0x40 .. 0x4F
  { 0b01101000, 6 }, // @
  { 0b01000000, 2 }, // A
  { 0b10000000, 4 }, // B
  { 0b10100000, 4 }, // C
  { 0b10000000, 3 }, // D
  { 0b00000000, 1 }, // E
  { 0b00100000, 4 }, // F
  { 0b11000000, 3 }, // G
  { 0b00000000, 4 }, // H
  { 0b00000000, 2 }, // I
  { 0b01110000, 4 }, // J
  { 0b10100000, 3 }, // K
  { 0b01000000, 4 }, // L
  { 0b11000000, 2 }, // M
  { 0b10000000, 2 }, // N
  { 0b11100000, 3 }, // O
  // 0x50 .. 0x5F
  { 0b01100000, 4 }, // P
  { 0b11010000, 4 }, // Q
  { 0b01000000, 3 }, // R
  { 0b00000000, 3 }, // S
  { 0b10000000, 1 }, // T
  { 0b00100000, 3 }, // U
  { 0b00010000, 4 }, // V
  { 0b01100000, 3 }, // W
  { 0b10010000, 4 }, // X
  { 0b10110000, 4 }, // Y
  { 0b11000000, 4 }, // Z
  { 0b01010000, 4 }, // [ = AE
  { 0b11100000, 4 }, // \ = OE
  { 0b00110000, 4 }, // ] = UE
  { 0b00000000, 8 }, // ^ = Irrung
  { 0b00110100, 6 }, // _
};

// ---------------------------------------------------------------------------

Morse::Morse()
 : nTransmitterPin(0), dotLength(1200/10) { }

// ---------------------------------------------------------------------------

void Morse::enableTransmit(int pin) {
  nTransmitterPin = pin;
  pinMode(pin, OUTPUT);
}

// ---------------------------------------------------------------------------

void Morse::disableTransmit() {
  pinMode(nTransmitterPin, INPUT);
  nTransmitterPin = 0;
}

// ---------------------------------------------------------------------------

void Morse::setSpeed(unsigned int speed) {
  dotLength = 1200 / speed;
}

// ---------------------------------------------------------------------------

size_t Morse::write(uint8_t val) {

  val = toupper(val);
  if ( val < 0x20 || val > 0x5f ) return 0;

  MorseCode_t morse;
  byte *ptr = (byte *)&morse;
  for ( int i=0; i<sizeof(MorseCode_t); ++i )
    *ptr++ = pgm_read_byte_near((byte *)&gMorseCode[val - 0x20] + i);

#if 0
  // debug output (to check pgm_read_byte_near() operation...)
  Serial.print(val);
  Serial.print(" ");
  Serial.print((int)val, HEX);
  Serial.print(": ");
  Serial.print((int)morse.code, BIN);
  Serial.print(" ");
  Serial.print(morse.len);
  Serial.println();
#endif

  byte mask = 0x80;
  for ( int i=0; i<morse.len; ++i ) {
    if ( morse.code & mask )
      dah();  // 3 dots and 1 dot pause
    else
      dit();  // 1 dot and 1 dot pause
    mask >>= 1;
  }

  // gap between letters is 3 dots
  if ( morse.len ) delay(2*dotLength);

  // gap between words is 7 dots
  if ( val == 0x20 ) delay(6*dotLength);

  return 1;
}

// ---------------------------------------------------------------------------

void Morse::dit() {
  digitalWrite(nTransmitterPin, HIGH);
  delay(dotLength);
  digitalWrite(nTransmitterPin, LOW);
  delay(dotLength);
}

// ---------------------------------------------------------------------------

void Morse::dah() {
  digitalWrite(nTransmitterPin, HIGH);
  delay(3*dotLength);
  digitalWrite(nTransmitterPin, LOW);
  delay(dotLength);
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
<commit_msg>fixed ASCII encoding<commit_after>
/*
  Morse - Arduino libary to create Morse code on any output pin.
  Copyright (c) 2015 Hermann-Josef Mathes.  All right reserved.

  Contributors:
  - add your name and eMail address

  Project home: https://github.com/thjm/morse

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "Morse.h"

typedef struct _MorseCode_t {

  byte code;
  byte len;

} MorseCode_t;

// Morse code table for ASCII characters 0x20 .. 0x5f
// 1st byte : code, 0=dit, 1=dah
// 2nd byte : number of dits/dahs
// For the idea of this table, see:
// http://www.avr-asm-tutorial.net/cq-dl/teil4/Cw01_200.asm
// (C) 2002 by Gerhard Schmidt, DG4FAC
static const MorseCode_t gMorseCode[] PROGMEM = {

  // 0x20 .. 0x2F
  { 0b00000000, 0 }, // Blank
  { 0b01000000, 5 }, // ! = Warten
  { 0b01001000, 6 }, // "
  { 0b11011000, 5 }, // # = ~n
  { 0b01101000, 5 }, // $ = ?, ?a
  { 0b01000000, 5 }, // % = ?
  { 0b00000000, 0 }, // & = not used
  { 0b01111000, 6 }, // '
  { 0b10110000, 5 }, // (, KN
  { 0b10110100, 6 }, // ), KK
  { 0b00000000, 0 }, // * = not used
  { 0b01010000, 5 }, // + = Spruchende, AR
  { 0b11001100, 6 }, // ,
  { 0b10000100, 6 }, // -
  { 0b01010100, 6 }, // .
  { 0b10010000, 5 }, // /
  // 0x30 .. 0x3F
  { 0b11111000, 5 }, // 0
  { 0b01111000, 5 }, // 1
  { 0b00111000, 5 }, // 2
  { 0b00011000, 5 }, // 3
  { 0b00001000, 5 }, // 4
  { 0b00000000, 5 }, // 5
  { 0b10000000, 5 }, // 6
  { 0b11000000, 5 }, // 7
  { 0b11100000, 5 }, // 8
  { 0b11110000, 5 }, // 9
  { 0b11100000, 6 }, // :
  { 0b10101000, 6 }, // ;
  { 0b10101000, 5 }, // < = Verkehrsanfang
  { 0b10001000, 5 }, // =
  { 0b01010000, 5 }, // > = Verkehrsende
  { 0b00110000, 6 }, // ?
  // 0x40 .. 0x4F
  { 0b01101000, 6 }, // @
  { 0b01000000, 2 }, // A
  { 0b10000000, 4 }, // B
  { 0b10100000, 4 }, // C
  { 0b10000000, 3 }, // D
  { 0b00000000, 1 }, // E
  { 0b00100000, 4 }, // F
  { 0b11000000, 3 }, // G
  { 0b00000000, 4 }, // H
  { 0b00000000, 2 }, // I
  { 0b01110000, 4 }, // J
  { 0b10100000, 3 }, // K
  { 0b01000000, 4 }, // L
  { 0b11000000, 2 }, // M
  { 0b10000000, 2 }, // N
  { 0b11100000, 3 }, // O
  // 0x50 .. 0x5F
  { 0b01100000, 4 }, // P
  { 0b11010000, 4 }, // Q
  { 0b01000000, 3 }, // R
  { 0b00000000, 3 }, // S
  { 0b10000000, 1 }, // T
  { 0b00100000, 3 }, // U
  { 0b00010000, 4 }, // V
  { 0b01100000, 3 }, // W
  { 0b10010000, 4 }, // X
  { 0b10110000, 4 }, // Y
  { 0b11000000, 4 }, // Z
  { 0b01010000, 4 }, // [ = AE
  { 0b11100000, 4 }, // \ = OE
  { 0b00110000, 4 }, // ] = UE
  { 0b00000000, 8 }, // ^ = Irrung
  { 0b00110100, 6 }, // _
};

// ---------------------------------------------------------------------------

Morse::Morse()
 : nTransmitterPin(0), dotLength(1200/10) { }

// ---------------------------------------------------------------------------

void Morse::enableTransmit(int pin) {
  nTransmitterPin = pin;
  pinMode(pin, OUTPUT);
}

// ---------------------------------------------------------------------------

void Morse::disableTransmit() {
  pinMode(nTransmitterPin, INPUT);
  nTransmitterPin = 0;
}

// ---------------------------------------------------------------------------

void Morse::setSpeed(unsigned int speed) {
  dotLength = 1200 / speed;
}

// ---------------------------------------------------------------------------

size_t Morse::write(uint8_t val) {

  val = toupper(val);
  if ( val < 0x20 || val > 0x5f ) return 0;

  MorseCode_t morse;
  byte *ptr = (byte *)&morse;
  for ( int i=0; i<sizeof(MorseCode_t); ++i )
    *ptr++ = pgm_read_byte_near((byte *)&gMorseCode[val - 0x20] + i);

#if 0
  // debug output (to check pgm_read_byte_near() operation...)
  Serial.print(val);
  Serial.print(" ");
  Serial.print((int)val, HEX);
  Serial.print(": ");
  Serial.print((int)morse.code, BIN);
  Serial.print(" ");
  Serial.print(morse.len);
  Serial.println();
#endif

  byte mask = 0x80;
  for ( int i=0; i<morse.len; ++i ) {
    if ( morse.code & mask )
      dah();  // 3 dots and 1 dot pause
    else
      dit();  // 1 dot and 1 dot pause
    mask >>= 1;
  }

  // gap between letters is 3 dots
  if ( morse.len ) delay(2*dotLength);

  // gap between words is 7 dots
  if ( val == 0x20 ) delay(6*dotLength);

  return 1;
}

// ---------------------------------------------------------------------------

void Morse::dit() {
  digitalWrite(nTransmitterPin, HIGH);
  delay(dotLength);
  digitalWrite(nTransmitterPin, LOW);
  delay(dotLength);
}

// ---------------------------------------------------------------------------

void Morse::dah() {
  digitalWrite(nTransmitterPin, HIGH);
  delay(3*dotLength);
  digitalWrite(nTransmitterPin, LOW);
  delay(dotLength);
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
<|endoftext|>


<commit_before>#include "globals.hh"
#include "nar-info.hh"

namespace nix {

NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
{
    auto corrupt = [&]() {
        throw Error(format("NAR info file ‘%1%’ is corrupt") % whence);
    };

    auto parseHashField = [&](const string & s) {
        try {
            return parseHash(s);
        } catch (BadHash &) {
            corrupt();
            return Hash(); // never reached
        }
    };

    size_t pos = 0;
    while (pos < s.size()) {

        size_t colon = s.find(':', pos);
        if (colon == std::string::npos) corrupt();

        std::string name(s, pos, colon - pos);

        size_t eol = s.find('\n', colon + 2);
        if (eol == std::string::npos) corrupt();

        std::string value(s, colon + 2, eol - colon - 2);

        if (name == "StorePath") {
            if (!store.isStorePath(value)) corrupt();
            path = value;
        }
        else if (name == "URL")
            url = value;
        else if (name == "Compression")
            compression = value;
        else if (name == "FileHash")
            fileHash = parseHashField(value);
        else if (name == "FileSize") {
            if (!string2Int(value, fileSize)) corrupt();
        }
        else if (name == "NarHash")
            narHash = parseHashField(value);
        else if (name == "NarSize") {
            if (!string2Int(value, narSize)) corrupt();
        }
        else if (name == "References") {
            auto refs = tokenizeString<Strings>(value, " ");
            if (!references.empty()) corrupt();
            for (auto & r : refs) {
                auto r2 = store.storeDir + "/" + r;
                if (!store.isStorePath(r2)) corrupt();
                references.insert(r2);
            }
        }
        else if (name == "Deriver") {
            auto p = store.storeDir + "/" + value;
            if (!store.isStorePath(p)) corrupt();
            deriver = p;
        }
        else if (name == "System")
            system = value;
        else if (name == "Sig")
            sigs.insert(value);
        else if (name == "CA") {
            if (!ca.empty()) corrupt();
            ca = value;
        }

        pos = eol + 1;
    }

    if (compression == "") compression = "bzip2";

    if (path.empty() || url.empty() || narSize == 0 || !narHash) corrupt();
}

std::string NarInfo::to_string() const
{
    std::string res;
    res += "StorePath: " + path + "\n";
    res += "URL: " + url + "\n";
    assert(compression != "");
    res += "Compression: " + compression + "\n";
    assert(fileHash.type == htSHA256);
    res += "FileHash: sha256:" + printHash32(fileHash) + "\n";
    res += "FileSize: " + std::to_string(fileSize) + "\n";
    assert(narHash.type == htSHA256);
    res += "NarHash: sha256:" + printHash32(narHash) + "\n";
    res += "NarSize: " + std::to_string(narSize) + "\n";

    res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";

    if (!deriver.empty())
        res += "Deriver: " + baseNameOf(deriver) + "\n";

    if (!system.empty())
        res += "System: " + system + "\n";

    for (auto sig : sigs)
        res += "Sig: " + sig + "\n";

    if (!ca.empty())
        res += "CA: " + ca + "\n";

    return res;
}

}
<commit_msg>Ignore broken "Deriver: unknown-deriver" fields in .narinfo<commit_after>#include "globals.hh"
#include "nar-info.hh"

namespace nix {

NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
{
    auto corrupt = [&]() {
        throw Error(format("NAR info file ‘%1%’ is corrupt") % whence);
    };

    auto parseHashField = [&](const string & s) {
        try {
            return parseHash(s);
        } catch (BadHash &) {
            corrupt();
            return Hash(); // never reached
        }
    };

    size_t pos = 0;
    while (pos < s.size()) {

        size_t colon = s.find(':', pos);
        if (colon == std::string::npos) corrupt();

        std::string name(s, pos, colon - pos);

        size_t eol = s.find('\n', colon + 2);
        if (eol == std::string::npos) corrupt();

        std::string value(s, colon + 2, eol - colon - 2);

        if (name == "StorePath") {
            if (!store.isStorePath(value)) corrupt();
            path = value;
        }
        else if (name == "URL")
            url = value;
        else if (name == "Compression")
            compression = value;
        else if (name == "FileHash")
            fileHash = parseHashField(value);
        else if (name == "FileSize") {
            if (!string2Int(value, fileSize)) corrupt();
        }
        else if (name == "NarHash")
            narHash = parseHashField(value);
        else if (name == "NarSize") {
            if (!string2Int(value, narSize)) corrupt();
        }
        else if (name == "References") {
            auto refs = tokenizeString<Strings>(value, " ");
            if (!references.empty()) corrupt();
            for (auto & r : refs) {
                auto r2 = store.storeDir + "/" + r;
                if (!store.isStorePath(r2)) corrupt();
                references.insert(r2);
            }
        }
        else if (name == "Deriver") {
            if (value != "unknown-deriver") {
                auto p = store.storeDir + "/" + value;
                if (!store.isStorePath(p)) corrupt();
                deriver = p;
            }
        }
        else if (name == "System")
            system = value;
        else if (name == "Sig")
            sigs.insert(value);
        else if (name == "CA") {
            if (!ca.empty()) corrupt();
            ca = value;
        }

        pos = eol + 1;
    }

    if (compression == "") compression = "bzip2";

    if (path.empty() || url.empty() || narSize == 0 || !narHash) corrupt();
}

std::string NarInfo::to_string() const
{
    std::string res;
    res += "StorePath: " + path + "\n";
    res += "URL: " + url + "\n";
    assert(compression != "");
    res += "Compression: " + compression + "\n";
    assert(fileHash.type == htSHA256);
    res += "FileHash: sha256:" + printHash32(fileHash) + "\n";
    res += "FileSize: " + std::to_string(fileSize) + "\n";
    assert(narHash.type == htSHA256);
    res += "NarHash: sha256:" + printHash32(narHash) + "\n";
    res += "NarSize: " + std::to_string(narSize) + "\n";

    res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";

    if (!deriver.empty())
        res += "Deriver: " + baseNameOf(deriver) + "\n";

    if (!system.empty())
        res += "System: " + system + "\n";

    for (auto sig : sigs)
        res += "Sig: " + sig + "\n";

    if (!ca.empty())
        res += "CA: " + ca + "\n";

    return res;
}

}
<|endoftext|>


<commit_before>    /**
  *********************************************************************
*************************************************************************
***
*** \file  GizmoATIX10.cpp
*** \brief GizmoATIX10 class body
***
*****************************************
  *****************************************
    **/

/*

  Copyright (c) 2007, Tim Burrell
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

#include "GizmoATIX10.hpp"
#include "GizmoEventATIX10.hpp"
#include "../libH/Debug.hpp"
#include "../libH/Exception.hpp"
#include <boost/shared_ptr.hpp>

using namespace std;
using namespace boost;
using namespace H;

////////////////////////////////////////////////////////////////////////////
// Type Defs
///////////////////////////////////////

/**
 * \def   GIZMO_ATIX10_TYPE
 * \brief String type of this gizmo
 */
#define GIZMO_ATIX10_TYPE	"ATIX10"

/**
 * \def   GIZMO_ATIX10_EVENTDELAY
 * \brief Default minimum time between ATIX10 events
 */
#define GIZMO_ATIX10_EVENTDELAY	0.25f

////////////////////////////////////////////////////////////////////////////
// Construction
///////////////////////////////////////

/**
 * \brief GizmoATIX10 Default Constructor
 */
GizmoATIX10::GizmoATIX10(const H::DeviceInfo & deviceInfo, int DeviceID, int DeviceClassID) : Gizmo(GIZMO_CLASS_ATIX10, deviceInfo, DeviceID, DeviceClassID), GizmoLinuxInputDevice(deviceInfo) {
	setMinimumTimeBetweenEvents(GIZMO_ATIX10_EVENTDELAY);
}

/**
 * \brief GizmoATIX10 Destructor
 */
GizmoATIX10::~GizmoATIX10() {
}

////////////////////////////////////////////////////////////////////////////
// Class Body
///////////////////////////////////////

/**
 * \brief  Get the type of this Gizmo
 * \return Type of the Gizmo
 */
std::string GizmoATIX10::getType() {
	return GIZMO_ATIX10_TYPE;
}

/**
 * \brief  Process an event
 * \param  pEvent The event to process
 * \return True on if the event should get passed on to the script
 */
bool GizmoATIX10::processEvent(GizmoEvent * pEvent) {
	if (!GizmoLinuxInputDevice::processEvent())
		return false;

	GizmoEventATIX10 * pATIX10Event = static_cast<GizmoEventATIX10 *>(pEvent);

	switch (pATIX10Event->Type) {
	case EV_KEY:
		setKeyState(pATIX10Event->Code, pATIX10Event->Value);
		break;
	default:
		// do nothing
		break;
	}

	return true;
}
<commit_msg>more debugging<commit_after>    /**
  *********************************************************************
*************************************************************************
***
*** \file  GizmoATIX10.cpp
*** \brief GizmoATIX10 class body
***
*****************************************
  *****************************************
    **/

/*

  Copyright (c) 2007, Tim Burrell
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

#include "GizmoATIX10.hpp"
#include "GizmoEventATIX10.hpp"
#include "../libH/Debug.hpp"
#include "../libH/Exception.hpp"
#include <boost/shared_ptr.hpp>

using namespace std;
using namespace boost;
using namespace H;

////////////////////////////////////////////////////////////////////////////
// Type Defs
///////////////////////////////////////

/**
 * \def   GIZMO_ATIX10_TYPE
 * \brief String type of this gizmo
 */
#define GIZMO_ATIX10_TYPE	"ATIX10"

/**
 * \def   GIZMO_ATIX10_EVENTDELAY
 * \brief Default minimum time between ATIX10 events
 */
#define GIZMO_ATIX10_EVENTDELAY	0.175f

////////////////////////////////////////////////////////////////////////////
// Construction
///////////////////////////////////////

/**
 * \brief GizmoATIX10 Default Constructor
 */
GizmoATIX10::GizmoATIX10(const H::DeviceInfo & deviceInfo, int DeviceID, int DeviceClassID) : Gizmo(GIZMO_CLASS_ATIX10, deviceInfo, DeviceID, DeviceClassID), GizmoLinuxInputDevice(deviceInfo) {
	setMinimumTimeBetweenEvents(GIZMO_ATIX10_EVENTDELAY);
}

/**
 * \brief GizmoATIX10 Destructor
 */
GizmoATIX10::~GizmoATIX10() {
}

////////////////////////////////////////////////////////////////////////////
// Class Body
///////////////////////////////////////

/**
 * \brief  Get the type of this Gizmo
 * \return Type of the Gizmo
 */
std::string GizmoATIX10::getType() {
	return GIZMO_ATIX10_TYPE;
}

/**
 * \brief  Process an event
 * \param  pEvent The event to process
 * \return True on if the event should get passed on to the script
 */
bool GizmoATIX10::processEvent(GizmoEvent * pEvent) {
	if (!GizmoLinuxInputDevice::processEvent())
		return false;

	GizmoEventATIX10 * pATIX10Event = static_cast<GizmoEventATIX10 *>(pEvent);

	switch (pATIX10Event->Type) {
	case EV_KEY:
		setKeyState(pATIX10Event->Code, pATIX10Event->Value);
		break;
	default:
		// do nothing
		break;
	}

	return true;
}
<|endoftext|>


<commit_before>/*  -*-c++-*-
 *  Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#include <iostream>
#include <osg/Geometry>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgUtil/SmoothingVisitor>
#include <osg/io_utils>

#include <osgAnimation/Bone>
#include <osgAnimation/Skeleton>
#include <osgAnimation/RigGeometry>
#include <osgAnimation/Skinning>
#include <osgAnimation/BasicAnimationManager>

osg::Geode* createAxis()
{
    osg::Geode* geode (new osg::Geode());
    osg::Geometry* geometry (new osg::Geometry());

    osg::Vec3Array* vertices (new osg::Vec3Array());
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 1.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 1.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 1.0));
    geometry->setVertexArray (vertices);

    osg::Vec4Array* colors (new osg::Vec4Array());
    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
    geometry->setColorArray (colors);

    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
    geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));

    geode->addDrawable( geometry );
    return geode;
}

osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
{
    osgAnimation::RigGeometry* geometry = new osgAnimation::RigGeometry;

    osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
    osg::ref_ptr<osg::Vec3Array> colors (new osg::Vec3Array());
    geometry->setVertexArray (vertices.get());
    geometry->setColorArray (colors.get());
    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);

    float step = size / nsplit;
    float s = 0.5/4.0;
    for (int i = 0; i < nsplit; i++)
    {
        float x = -1 + i * step;
        std::cout << x << std::endl;
        vertices->push_back (osg::Vec3 ( x, s, s));
        vertices->push_back (osg::Vec3 ( x, -s, s));
        vertices->push_back (osg::Vec3 ( x, -s, -s));
        vertices->push_back (osg::Vec3 ( x, s, -s));
        osg::Vec3 c (0,0,0);
        c[i%3] = 1;
        colors->push_back (c);
        colors->push_back (c);
        colors->push_back (c);
        colors->push_back (c);
    }

    osg::ref_ptr<osg::UIntArray> array = new osg::UIntArray;
    for (int i = 0; i < nsplit - 1; i++)
    {
        int base = i * 4;
        array->push_back(base);
        array->push_back(base+1);
        array->push_back(base+4);
        array->push_back(base+1);
        array->push_back(base+5);
        array->push_back(base+4);

        array->push_back(base+3);
        array->push_back(base);
        array->push_back(base+4);
        array->push_back(base+7);
        array->push_back(base+3);
        array->push_back(base+4);

        array->push_back(base+5);
        array->push_back(base+1);
        array->push_back(base+2);
        array->push_back(base+2);
        array->push_back(base+6);
        array->push_back(base+5);

        array->push_back(base+2);
        array->push_back(base+3);
        array->push_back(base+7);
        array->push_back(base+6);
        array->push_back(base+2);
        array->push_back(base+7);
    }

    geometry->addPrimitiveSet(new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, array->size(), &array->front()));
    geometry->setUseDisplayList( false );
    return geometry;
}

void initVertexMap(osgAnimation::Bone* b0,
                   osgAnimation::Bone* b1,
                   osgAnimation::Bone* b2,
                   osgAnimation::RigGeometry* geom,
                   osg::Vec3Array* array)
{
    osgAnimation::VertexInfluenceSet vertexesInfluences;
    osgAnimation::VertexInfluenceMap* vim = new osgAnimation::VertexInfluenceMap;

    (*vim)[b0->getName()].setName(b0->getName());
    (*vim)[b1->getName()].setName(b1->getName());
    (*vim)[b2->getName()].setName(b2->getName());

    for (int i = 0; i < (int)array->size(); i++)
    {
        float val = (*array)[i][0];
        std::cout << val << std::endl;
        if (val >= -1 && val <= 0)
            (*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
        else if ( val > 0 && val <= 1)
            (*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
        else if ( val > 1)
            (*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
    }

    geom->setInfluenceMap(vim);
}

int main (int argc, char* argv[])
{
    osg::ArgumentParser arguments(&argc, argv);
    osgViewer::Viewer viewer(arguments);

    viewer.setCameraManipulator(new osgGA::TrackballManipulator());

    osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton;
    skelroot->setDefaultUpdateCallback();
    osg::ref_ptr<osgAnimation::Bone> root = new osgAnimation::Bone;
    {
        root->setBindMatrixInBoneSpace(osg::Matrix::identity());
        root->setBindMatrixInBoneSpace(osg::Matrix::translate(-1,0,0));
        root->setName("root");
        root->setDefaultUpdateCallback();
    }

    osg::ref_ptr<osgAnimation::Bone> right0 = new osgAnimation::Bone;
    right0->setBindMatrixInBoneSpace(osg::Matrix::translate(1,0,0));
    right0->setName("right0");
    right0->setDefaultUpdateCallback("right0");

    osg::ref_ptr<osgAnimation::Bone> right1 = new osgAnimation::Bone;
    right1->setBindMatrixInBoneSpace(osg::Matrix::translate(1,0,0));
    right1->setName("right1");
    right1->setDefaultUpdateCallback("right1");

    root->addChild(right0.get());
    right0->addChild(right1.get());
    skelroot->addChild(root.get());

    osg::Group* scene = new osg::Group;
    osg::ref_ptr<osgAnimation::BasicAnimationManager> manager = new osgAnimation::BasicAnimationManager;
    scene->setUpdateCallback(manager.get());

    osgAnimation::Animation* anim = new osgAnimation::Animation;
    {
        osgAnimation::QuatKeyframeContainer* keys0 = new osgAnimation::QuatKeyframeContainer;
        osg::Quat rotate;
        rotate.makeRotate(osg::PI_2, osg::Vec3(0,0,1));
        keys0->push_back(osgAnimation::QuatKeyframe(0,osg::Quat(0,0,0,1)));
        keys0->push_back(osgAnimation::QuatKeyframe(3,rotate));
        keys0->push_back(osgAnimation::QuatKeyframe(6,rotate));
        osgAnimation::QuatSphericalLinearSampler* sampler = new osgAnimation::QuatSphericalLinearSampler;
        sampler->setKeyframeContainer(keys0);
        osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(right0->getUpdateCallback());
        osgAnimation::QuatSphericalLinearChannel* channel = new osgAnimation::QuatSphericalLinearChannel(sampler);
        channel->setName("quaternion");
        channel->setTargetName("right0");
        anim->addChannel(channel);
    }

    {
        osgAnimation::QuatKeyframeContainer* keys1 = new osgAnimation::QuatKeyframeContainer;
        osg::Quat rotate;
        rotate.makeRotate(osg::PI_2, osg::Vec3(0,0,1));
        keys1->push_back(osgAnimation::QuatKeyframe(0,osg::Quat(0,0,0,1)));
        keys1->push_back(osgAnimation::QuatKeyframe(3,osg::Quat(0,0,0,1)));
        keys1->push_back(osgAnimation::QuatKeyframe(6,rotate));
        osgAnimation::QuatSphericalLinearSampler* sampler = new osgAnimation::QuatSphericalLinearSampler;
        sampler->setKeyframeContainer(keys1);
        osgAnimation::QuatSphericalLinearChannel* channel = new osgAnimation::QuatSphericalLinearChannel(sampler);
        osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(right1->getUpdateCallback());
        channel->setName("quaternion");
        channel->setTargetName("right1");
        anim->addChannel(channel);
    }
    manager->registerAnimation(anim);
    manager->buildTargetReference();

    // let's start !
    manager->playAnimation(anim);

    // we will use local data from the skeleton
    osg::MatrixTransform* rootTransform = new osg::MatrixTransform;
    rootTransform->setMatrix(osg::Matrix::rotate(osg::PI_2,osg::Vec3(1,0,0)));
    right0->addChild(createAxis());
    right0->setDataVariance(osg::Object::DYNAMIC);
    right1->addChild(createAxis());
    right1->setDataVariance(osg::Object::DYNAMIC);
    osg::MatrixTransform* trueroot = new osg::MatrixTransform;
    trueroot->setMatrix(osg::Matrix(root->getMatrixInBoneSpace().ptr()));
    trueroot->addChild(createAxis());
    trueroot->addChild(skelroot);
    trueroot->setDataVariance(osg::Object::DYNAMIC);
    rootTransform->addChild(trueroot);
    scene->addChild(rootTransform);

    osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0);
    osg::Geode* geode = new osg::Geode;
    geode->addDrawable(geom);
    skelroot->addChild(geode);
    osg::ref_ptr<osg::Vec3Array> src = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
    geom->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
    geom->setDataVariance(osg::Object::DYNAMIC);

    initVertexMap(root.get(), right0.get(), right1.get(), geom, src.get());

    geom->buildVertexSet();
    geom->buildTransformer(skelroot.get());

    // let's run !
    viewer.setSceneData( scene );
    viewer.realize();

    while (!viewer.done())
    {
        viewer.frame();
    }

    return 0;
}

<commit_msg>Fixed warning<commit_after>/*  -*-c++-*-
 *  Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#include <iostream>
#include <osg/Geometry>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgUtil/SmoothingVisitor>
#include <osg/io_utils>

#include <osgAnimation/Bone>
#include <osgAnimation/Skeleton>
#include <osgAnimation/RigGeometry>
#include <osgAnimation/Skinning>
#include <osgAnimation/BasicAnimationManager>

osg::Geode* createAxis()
{
    osg::Geode* geode (new osg::Geode());
    osg::Geometry* geometry (new osg::Geometry());

    osg::Vec3Array* vertices (new osg::Vec3Array());
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 1.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 1.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices->push_back (osg::Vec3 ( 0.0, 0.0, 1.0));
    geometry->setVertexArray (vertices);

    osg::Vec4Array* colors (new osg::Vec4Array());
    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (1.0f, 0.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 1.0f, 0.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
    colors->push_back (osg::Vec4 (0.0f, 0.0f, 1.0f, 1.0f));
    geometry->setColorArray (colors);

    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);
    geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,6));

    geode->addDrawable( geometry );
    return geode;
}

osgAnimation::RigGeometry* createTesselatedBox(int nsplit, float size)
{
    osgAnimation::RigGeometry* geometry = new osgAnimation::RigGeometry;

    osg::ref_ptr<osg::Vec3Array> vertices (new osg::Vec3Array());
    osg::ref_ptr<osg::Vec3Array> colors (new osg::Vec3Array());
    geometry->setVertexArray (vertices.get());
    geometry->setColorArray (colors.get());
    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);

    float step = size / nsplit;
    float s = 0.5/4.0;
    for (int i = 0; i < nsplit; i++)
    {
        float x = -1 + i * step;
        std::cout << x << std::endl;
        vertices->push_back (osg::Vec3 ( x, s, s));
        vertices->push_back (osg::Vec3 ( x, -s, s));
        vertices->push_back (osg::Vec3 ( x, -s, -s));
        vertices->push_back (osg::Vec3 ( x, s, -s));
        osg::Vec3 c (0,0,0);
        c[i%3] = 1;
        colors->push_back (c);
        colors->push_back (c);
        colors->push_back (c);
        colors->push_back (c);
    }

    osg::ref_ptr<osg::UIntArray> array = new osg::UIntArray;
    for (int i = 0; i < nsplit - 1; i++)
    {
        int base = i * 4;
        array->push_back(base);
        array->push_back(base+1);
        array->push_back(base+4);
        array->push_back(base+1);
        array->push_back(base+5);
        array->push_back(base+4);

        array->push_back(base+3);
        array->push_back(base);
        array->push_back(base+4);
        array->push_back(base+7);
        array->push_back(base+3);
        array->push_back(base+4);

        array->push_back(base+5);
        array->push_back(base+1);
        array->push_back(base+2);
        array->push_back(base+2);
        array->push_back(base+6);
        array->push_back(base+5);

        array->push_back(base+2);
        array->push_back(base+3);
        array->push_back(base+7);
        array->push_back(base+6);
        array->push_back(base+2);
        array->push_back(base+7);
    }

    geometry->addPrimitiveSet(new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, array->size(), &array->front()));
    geometry->setUseDisplayList( false );
    return geometry;
}

void initVertexMap(osgAnimation::Bone* b0,
                   osgAnimation::Bone* b1,
                   osgAnimation::Bone* b2,
                   osgAnimation::RigGeometry* geom,
                   osg::Vec3Array* array)
{
    osgAnimation::VertexInfluenceSet vertexesInfluences;
    osgAnimation::VertexInfluenceMap* vim = new osgAnimation::VertexInfluenceMap;

    (*vim)[b0->getName()].setName(b0->getName());
    (*vim)[b1->getName()].setName(b1->getName());
    (*vim)[b2->getName()].setName(b2->getName());

    for (int i = 0; i < (int)array->size(); i++)
    {
        float val = (*array)[i][0];
        std::cout << val << std::endl;
        if (val >= -1 && val <= 0)
            (*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
        else if ( val > 0 && val <= 1)
            (*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
        else if ( val > 1)
            (*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1));
    }

    geom->setInfluenceMap(vim);
}

int main (int argc, char* argv[])
{
    osg::ArgumentParser arguments(&argc, argv);
    osgViewer::Viewer viewer(arguments);

    viewer.setCameraManipulator(new osgGA::TrackballManipulator());

    osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton;
    skelroot->setDefaultUpdateCallback();
    osg::ref_ptr<osgAnimation::Bone> root = new osgAnimation::Bone;
    {
        root->setBindMatrixInBoneSpace(osg::Matrix::identity());
        root->setBindMatrixInBoneSpace(osg::Matrix::translate(-1,0,0));
        root->setName("root");
        root->setDefaultUpdateCallback();
    }

    osg::ref_ptr<osgAnimation::Bone> right0 = new osgAnimation::Bone;
    right0->setBindMatrixInBoneSpace(osg::Matrix::translate(1,0,0));
    right0->setName("right0");
    right0->setDefaultUpdateCallback("right0");

    osg::ref_ptr<osgAnimation::Bone> right1 = new osgAnimation::Bone;
    right1->setBindMatrixInBoneSpace(osg::Matrix::translate(1,0,0));
    right1->setName("right1");
    right1->setDefaultUpdateCallback("right1");

    root->addChild(right0.get());
    right0->addChild(right1.get());
    skelroot->addChild(root.get());

    osg::Group* scene = new osg::Group;
    osg::ref_ptr<osgAnimation::BasicAnimationManager> manager = new osgAnimation::BasicAnimationManager;
    scene->setUpdateCallback(manager.get());

    osgAnimation::Animation* anim = new osgAnimation::Animation;
    {
        osgAnimation::QuatKeyframeContainer* keys0 = new osgAnimation::QuatKeyframeContainer;
        osg::Quat rotate;
        rotate.makeRotate(osg::PI_2, osg::Vec3(0,0,1));
        keys0->push_back(osgAnimation::QuatKeyframe(0,osg::Quat(0,0,0,1)));
        keys0->push_back(osgAnimation::QuatKeyframe(3,rotate));
        keys0->push_back(osgAnimation::QuatKeyframe(6,rotate));
        osgAnimation::QuatSphericalLinearSampler* sampler = new osgAnimation::QuatSphericalLinearSampler;
        sampler->setKeyframeContainer(keys0);
        // osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(right0->getUpdateCallback());
        osgAnimation::QuatSphericalLinearChannel* channel = new osgAnimation::QuatSphericalLinearChannel(sampler);
        channel->setName("quaternion");
        channel->setTargetName("right0");
        anim->addChannel(channel);
    }

    {
        osgAnimation::QuatKeyframeContainer* keys1 = new osgAnimation::QuatKeyframeContainer;
        osg::Quat rotate;
        rotate.makeRotate(osg::PI_2, osg::Vec3(0,0,1));
        keys1->push_back(osgAnimation::QuatKeyframe(0,osg::Quat(0,0,0,1)));
        keys1->push_back(osgAnimation::QuatKeyframe(3,osg::Quat(0,0,0,1)));
        keys1->push_back(osgAnimation::QuatKeyframe(6,rotate));
        osgAnimation::QuatSphericalLinearSampler* sampler = new osgAnimation::QuatSphericalLinearSampler;
        sampler->setKeyframeContainer(keys1);
        osgAnimation::QuatSphericalLinearChannel* channel = new osgAnimation::QuatSphericalLinearChannel(sampler);
        //osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(right1->getUpdateCallback());
        channel->setName("quaternion");
        channel->setTargetName("right1");
        anim->addChannel(channel);
    }
    manager->registerAnimation(anim);
    manager->buildTargetReference();

    // let's start !
    manager->playAnimation(anim);

    // we will use local data from the skeleton
    osg::MatrixTransform* rootTransform = new osg::MatrixTransform;
    rootTransform->setMatrix(osg::Matrix::rotate(osg::PI_2,osg::Vec3(1,0,0)));
    right0->addChild(createAxis());
    right0->setDataVariance(osg::Object::DYNAMIC);
    right1->addChild(createAxis());
    right1->setDataVariance(osg::Object::DYNAMIC);
    osg::MatrixTransform* trueroot = new osg::MatrixTransform;
    trueroot->setMatrix(osg::Matrix(root->getMatrixInBoneSpace().ptr()));
    trueroot->addChild(createAxis());
    trueroot->addChild(skelroot);
    trueroot->setDataVariance(osg::Object::DYNAMIC);
    rootTransform->addChild(trueroot);
    scene->addChild(rootTransform);

    osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0);
    osg::Geode* geode = new osg::Geode;
    geode->addDrawable(geom);
    skelroot->addChild(geode);
    osg::ref_ptr<osg::Vec3Array> src = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
    geom->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
    geom->setDataVariance(osg::Object::DYNAMIC);

    initVertexMap(root.get(), right0.get(), right1.get(), geom, src.get());

    geom->buildVertexSet();
    geom->buildTransformer(skelroot.get());

    // let's run !
    viewer.setSceneData( scene );
    viewer.realize();

    while (!viewer.done())
    {
        viewer.frame();
    }

    return 0;
}

<|endoftext|>


<commit_before>#include "filterimporterexporter.h"

#include "kmfilter.h"
#include "kmfilteraction.h"
#include "util.h"

#include <kconfig.h>
#include <kdebug.h>
#include <kfiledialog.h>
#include <kdialogbase.h>
#include <klistview.h>

#include <qregexp.h>

using namespace KMail;

class FilterSelectionDialog : public KDialogBase
{
public:
    FilterSelectionDialog( QWidget * parent = 0 )
        :KDialogBase( parent, "filterselection", true, i18n("Select Filters"), Ok|Cancel, Ok, true ),
        wasCancelled( false )
    {
        filtersListView = new KListView( this );
        setMainWidget(filtersListView);
        filtersListView->setSorting( -1 );
        filtersListView->setSelectionMode( QListView::NoSelection );
        filtersListView->addColumn( i18n("Filters"), 300 );
        filtersListView->setFullWidth( true );
        resize( 300, 350 );
    }

    virtual ~FilterSelectionDialog()
    {
    }

    virtual void slotCancel()
    {
        wasCancelled = true;
        KDialogBase::slotCancel();
    }

    bool cancelled()
    {
        return wasCancelled;
    }

    void setFilters( const QValueList<KMFilter*>& filters )
    {
        originalFilters = filters;
        filtersListView->clear();
        QValueListConstIterator<KMFilter*> it = filters.constEnd();
        while ( it != filters.constBegin() ) {
            --it;
            KMFilter* filter = *it;
            QCheckListItem* item = new QCheckListItem( filtersListView, filter->name(), QCheckListItem::CheckBox );
            item->setOn( true );
        }
    }

    QValueList<KMFilter*> selectedFilters() const
    {
        QValueList<KMFilter*> filters;
        QListViewItemIterator it( filtersListView );
        int i = 0;
        while( it.current() ) {
            QCheckListItem* item = static_cast<QCheckListItem*>( it.current() );
            if ( item->isOn() )
                filters << originalFilters[i];
            ++i; ++it;
        }
        return filters;
    }
private:
    KListView *filtersListView;
    QValueList<KMFilter*> originalFilters;
    bool wasCancelled;
};

/* static */
QValueList<KMFilter*> FilterImporterExporter::readFiltersFromConfig( KConfig* config, bool bPopFilter )
{
    KConfigGroupSaver saver(config, "General");
    int numFilters = 0;
    if (bPopFilter)
      numFilters = config->readNumEntry("popfilters",0);
    else
      numFilters = config->readNumEntry("filters",0);

    QValueList<KMFilter*> filters;
    for ( int i=0 ; i < numFilters ; ++i ) {
      QString grpName;
      grpName.sprintf("%s #%d", (bPopFilter ? "PopFilter" : "Filter") , i);
      KConfigGroupSaver saver(config, grpName);
      KMFilter * filter = new KMFilter(config, bPopFilter);
      filter->purify();
      if ( filter->isEmpty() ) {
    #ifndef NDEBUG
        kdDebug(5006) << "KMFilter::readConfig: filter\n" << filter->asString()
          << "is empty!" << endl;
    #endif
        delete filter;
      } else
        filters.append(filter);
    }
    return filters;
}

/* static */
void FilterImporterExporter::writeFiltersToConfig( const QValueList<KMFilter*>& filters, KConfig* config, bool bPopFilter )
{
    // first, delete all groups:
    QStringList filterGroups =
      config->groupList().grep( QRegExp( bPopFilter ? "PopFilter #\\d+" : "Filter #\\d+" ) );
    for ( QStringList::Iterator it = filterGroups.begin() ;
          it != filterGroups.end() ; ++it )
      config->deleteGroup( *it );

    int i = 0;
    for ( QValueListConstIterator<KMFilter*> it = filters.constBegin() ;
          it != filters.constEnd() ; ++it ) {
      if ( !(*it)->isEmpty() ) {
        QString grpName;
        if ( bPopFilter )
          grpName.sprintf("PopFilter #%d", i);
        else
          grpName.sprintf("Filter #%d", i);
        KConfigGroupSaver saver(config, grpName);
        (*it)->writeConfig(config);
        ++i;
      }
    }
    KConfigGroupSaver saver(config, "General");
    if (bPopFilter)
      config->writeEntry("popfilters", i);
    else
      config->writeEntry("filters", i);
}

FilterImporterExporter::FilterImporterExporter( QWidget* parent, bool popFilter )
:mParent( parent), mPopFilter( popFilter )
{
}

FilterImporterExporter::~FilterImporterExporter()
{
}

QValueList<KMFilter*> FilterImporterExporter::importFilters()
{
    QString fileName = KFileDialog::getOpenFileName( QDir::homeDirPath(), QString::null, mParent, i18n("Import Filters") );
    if ( fileName.isEmpty() ) return QValueList<KMFilter*>();

    KConfig config( fileName );
    QValueList<KMFilter*> imported = readFiltersFromConfig( &config, mPopFilter );
    FilterSelectionDialog dlg( mParent );
    dlg.setFilters( imported );
    dlg.exec();
    return dlg.cancelled() ? QValueList<KMFilter*>() : dlg.selectedFilters();
}

void FilterImporterExporter::exportFilters(const QValueList<KMFilter*> & filters )
{
    KURL saveUrl = KFileDialog::getSaveURL( QDir::homeDirPath(), QString::null, mParent, i18n("Export Filters") );

    if ( saveUrl.isEmpty() || !Util::checkOverwrite( saveUrl, mParent ) )
      return;

    KConfig config( saveUrl.path() );
    FilterSelectionDialog dlg( mParent );
    dlg.setFilters( filters );
    dlg.exec();
    if ( !dlg.cancelled() )
        writeFiltersToConfig( dlg.selectedFilters(), &config, mPopFilter );
}

<commit_msg>Show an error message if the to-be-imported filters file can't be read.<commit_after>#include "filterimporterexporter.h"

#include "kmfilter.h"
#include "kmfilteraction.h"
#include "util.h"

#include <kconfig.h>
#include <kdebug.h>
#include <kfiledialog.h>
#include <kdialogbase.h>
#include <klistview.h>

#include <qregexp.h>

using namespace KMail;

class FilterSelectionDialog : public KDialogBase
{
public:
    FilterSelectionDialog( QWidget * parent = 0 )
        :KDialogBase( parent, "filterselection", true, i18n("Select Filters"), Ok|Cancel, Ok, true ),
        wasCancelled( false )
    {
        filtersListView = new KListView( this );
        setMainWidget(filtersListView);
        filtersListView->setSorting( -1 );
        filtersListView->setSelectionMode( QListView::NoSelection );
        filtersListView->addColumn( i18n("Filters"), 300 );
        filtersListView->setFullWidth( true );
        resize( 300, 350 );
    }

    virtual ~FilterSelectionDialog()
    {
    }

    virtual void slotCancel()
    {
        wasCancelled = true;
        KDialogBase::slotCancel();
    }

    bool cancelled()
    {
        return wasCancelled;
    }

    void setFilters( const QValueList<KMFilter*>& filters )
    {
        originalFilters = filters;
        filtersListView->clear();
        QValueListConstIterator<KMFilter*> it = filters.constEnd();
        while ( it != filters.constBegin() ) {
            --it;
            KMFilter* filter = *it;
            QCheckListItem* item = new QCheckListItem( filtersListView, filter->name(), QCheckListItem::CheckBox );
            item->setOn( true );
        }
    }

    QValueList<KMFilter*> selectedFilters() const
    {
        QValueList<KMFilter*> filters;
        QListViewItemIterator it( filtersListView );
        int i = 0;
        while( it.current() ) {
            QCheckListItem* item = static_cast<QCheckListItem*>( it.current() );
            if ( item->isOn() )
                filters << originalFilters[i];
            ++i; ++it;
        }
        return filters;
    }
private:
    KListView *filtersListView;
    QValueList<KMFilter*> originalFilters;
    bool wasCancelled;
};

/* static */
QValueList<KMFilter*> FilterImporterExporter::readFiltersFromConfig( KConfig* config, bool bPopFilter )
{
    KConfigGroupSaver saver(config, "General");
    int numFilters = 0;
    if (bPopFilter)
      numFilters = config->readNumEntry("popfilters",0);
    else
      numFilters = config->readNumEntry("filters",0);

    QValueList<KMFilter*> filters;
    for ( int i=0 ; i < numFilters ; ++i ) {
      QString grpName;
      grpName.sprintf("%s #%d", (bPopFilter ? "PopFilter" : "Filter") , i);
      KConfigGroupSaver saver(config, grpName);
      KMFilter * filter = new KMFilter(config, bPopFilter);
      filter->purify();
      if ( filter->isEmpty() ) {
    #ifndef NDEBUG
        kdDebug(5006) << "KMFilter::readConfig: filter\n" << filter->asString()
          << "is empty!" << endl;
    #endif
        delete filter;
      } else
        filters.append(filter);
    }
    return filters;
}

/* static */
void FilterImporterExporter::writeFiltersToConfig( const QValueList<KMFilter*>& filters, KConfig* config, bool bPopFilter )
{
    // first, delete all groups:
    QStringList filterGroups =
      config->groupList().grep( QRegExp( bPopFilter ? "PopFilter #\\d+" : "Filter #\\d+" ) );
    for ( QStringList::Iterator it = filterGroups.begin() ;
          it != filterGroups.end() ; ++it )
      config->deleteGroup( *it );

    int i = 0;
    for ( QValueListConstIterator<KMFilter*> it = filters.constBegin() ;
          it != filters.constEnd() ; ++it ) {
      if ( !(*it)->isEmpty() ) {
        QString grpName;
        if ( bPopFilter )
          grpName.sprintf("PopFilter #%d", i);
        else
          grpName.sprintf("Filter #%d", i);
        KConfigGroupSaver saver(config, grpName);
        (*it)->writeConfig(config);
        ++i;
      }
    }
    KConfigGroupSaver saver(config, "General");
    if (bPopFilter)
      config->writeEntry("popfilters", i);
    else
      config->writeEntry("filters", i);
}

FilterImporterExporter::FilterImporterExporter( QWidget* parent, bool popFilter )
:mParent( parent), mPopFilter( popFilter )
{
}

FilterImporterExporter::~FilterImporterExporter()
{
}

QValueList<KMFilter*> FilterImporterExporter::importFilters()
{
    QString fileName = KFileDialog::getOpenFileName( QDir::homeDirPath(), QString::null, mParent, i18n("Import Filters") );
    if ( fileName.isEmpty() )
        return QValueList<KMFilter*>(); // cancel

    { // scoping
        QFile f( fileName );
        if ( !f.open( IO_ReadOnly ) ) {
            KMessageBox::error( mParent, i18n("The selected file is not readable. Your file access permissions might be insufficient.") );
            return QValueList<KMFilter*>();
        }
    }

    KConfig config( fileName );
    QValueList<KMFilter*> imported = readFiltersFromConfig( &config, mPopFilter );
    FilterSelectionDialog dlg( mParent );
    dlg.setFilters( imported );
    dlg.exec();
    return dlg.cancelled() ? QValueList<KMFilter*>() : dlg.selectedFilters();
}

void FilterImporterExporter::exportFilters(const QValueList<KMFilter*> & filters )
{
    KURL saveUrl = KFileDialog::getSaveURL( QDir::homeDirPath(), QString::null, mParent, i18n("Export Filters") );

    if ( saveUrl.isEmpty() || !Util::checkOverwrite( saveUrl, mParent ) )
      return;

    KConfig config( saveUrl.path() );
    FilterSelectionDialog dlg( mParent );
    dlg.setFilters( filters );
    dlg.exec();
    if ( !dlg.cancelled() )
        writeFiltersToConfig( dlg.selectedFilters(), &config, mPopFilter );
}

<|endoftext|>


<commit_before>///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file glm/core/type_vec1.hpp
/// @date 2008-08-25 / 2011-06-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////

#ifndef glm_core_type_gentype1
#define glm_core_type_gentype1

#include "../fwd.hpp"
#include "type_vec.hpp"
#include "_swizzle.hpp"

namespace glm{
namespace detail
{
	template <typename T, precision P>
	struct tvec1
	{
		enum ctor{_null};

		typedef tvec1<T, P> type;
		typedef tvec1<bool, P> bool_type;

		GLM_FUNC_DECL GLM_CONSTEXPR int length() const;

		//////////////////////////////////////
		// Data

#		if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
			T x;
#		else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
			union {T x, r, s;};
#		endif//GLM_COMPONENT

		//////////////////////////////////////
		// Accesses

		GLM_FUNC_DECL T & operator[](int i);
		GLM_FUNC_DECL T const & operator[](int i) const;

		//////////////////////////////////////
		// Implicit basic constructors

		GLM_FUNC_DECL tvec1();
		GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
		template <precision Q>
		GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);

		//////////////////////////////////////
		// Explicit basic constructors

		GLM_FUNC_DECL explicit tvec1(
			ctor);
		GLM_FUNC_DECL explicit tvec1(
			T const & s);

		//////////////////////////////////////
		// Swizzle constructors

		GLM_FUNC_DECL tvec1(tref1<T, P> const & r);

		//////////////////////////////////////
		// Conversion scalar constructors

		//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U>
		GLM_FUNC_DECL explicit tvec1(U const & s);

		//////////////////////////////////////
		// Conversion vector constructors

		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);

		//////////////////////////////////////
		// Unary arithmetic operators

		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<T, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<U, P> const & v);

		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);

		//////////////////////////////////////
		// Increment and decrement operators

		GLM_FUNC_DECL tvec1<T, P> & operator++();
		GLM_FUNC_DECL tvec1<T, P> & operator--();
		GLM_FUNC_DECL tvec1<T, P> operator++(int);
		GLM_FUNC_DECL tvec1<T, P> operator--(int);

		//////////////////////////////////////
		// Unary bit operators

		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);

		//////////////////////////////////////
		// Swizzle operators

		GLM_FUNC_DECL T swizzle(comp X) const;
		GLM_FUNC_DECL tvec2<T, P> swizzle(comp X, comp Y) const;
		GLM_FUNC_DECL tvec3<T, P> swizzle(comp X, comp Y, comp Z) const;
		GLM_FUNC_DECL tvec4<T, P> swizzle(comp X, comp Y, comp Z, comp W) const;
		GLM_FUNC_DECL tref1<T, P> swizzle(comp X);
	};

	template <typename T, precision P>
	struct tref1
	{
		GLM_FUNC_DECL tref1(T & x);
		GLM_FUNC_DECL tref1(tref1<T, P> const & r);
		GLM_FUNC_DECL tref1(tvec1<T, P> const & v);
		GLM_FUNC_DECL tref1<T, P> & operator= (tref1<T, P> const & r);
		GLM_FUNC_DECL tref1<T, P> & operator= (tvec1<T, P> const & v);

		T& x;
	};

	GLM_DETAIL_IS_VECTOR(tvec1);

}//namespace detail
}//namespace glm

#ifndef GLM_EXTERNAL_TEMPLATE
#include "type_vec1.inl"
#endif//GLM_EXTERNAL_TEMPLATE

#endif//glm_core_type_gentype1
<commit_msg>Fixed warnings generated by GLM_COMPONENT* #113<commit_after>///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file glm/core/type_vec1.hpp
/// @date 2008-08-25 / 2011-06-15
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////

#ifndef glm_core_type_gentype1
#define glm_core_type_gentype1

#include "../fwd.hpp"
#include "type_vec.hpp"
#include "_swizzle.hpp"

namespace glm{
namespace detail
{
	template <typename T, precision P>
	struct tvec1
	{
		enum ctor{_null};

		typedef tvec1<T, P> type;
		typedef tvec1<bool, P> bool_type;

		GLM_FUNC_DECL GLM_CONSTEXPR int length() const;

		//////////////////////////////////////
		// Data

		union {T x, r, s;};

		//////////////////////////////////////
		// Accesses

		GLM_FUNC_DECL T & operator[](int i);
		GLM_FUNC_DECL T const & operator[](int i) const;

		//////////////////////////////////////
		// Implicit basic constructors

		GLM_FUNC_DECL tvec1();
		GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
		template <precision Q>
		GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);

		//////////////////////////////////////
		// Explicit basic constructors

		GLM_FUNC_DECL explicit tvec1(
			ctor);
		GLM_FUNC_DECL explicit tvec1(
			T const & s);

		//////////////////////////////////////
		// Swizzle constructors

		GLM_FUNC_DECL tvec1(tref1<T, P> const & r);

		//////////////////////////////////////
		// Conversion scalar constructors

		//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U>
		GLM_FUNC_DECL explicit tvec1(U const & s);

		//////////////////////////////////////
		// Conversion vector constructors

		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U, precision Q>
		GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);

		//////////////////////////////////////
		// Unary arithmetic operators

		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<T, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<U, P> const & v);

		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);

		//////////////////////////////////////
		// Increment and decrement operators

		GLM_FUNC_DECL tvec1<T, P> & operator++();
		GLM_FUNC_DECL tvec1<T, P> & operator--();
		GLM_FUNC_DECL tvec1<T, P> operator++(int);
		GLM_FUNC_DECL tvec1<T, P> operator--(int);

		//////////////////////////////////////
		// Unary bit operators

		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
		template <typename U>
		GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);

		//////////////////////////////////////
		// Swizzle operators

		GLM_FUNC_DECL T swizzle(comp X) const;
		GLM_FUNC_DECL tvec2<T, P> swizzle(comp X, comp Y) const;
		GLM_FUNC_DECL tvec3<T, P> swizzle(comp X, comp Y, comp Z) const;
		GLM_FUNC_DECL tvec4<T, P> swizzle(comp X, comp Y, comp Z, comp W) const;
		GLM_FUNC_DECL tref1<T, P> swizzle(comp X);
	};

	template <typename T, precision P>
	struct tref1
	{
		GLM_FUNC_DECL tref1(T & x);
		GLM_FUNC_DECL tref1(tref1<T, P> const & r);
		GLM_FUNC_DECL tref1(tvec1<T, P> const & v);
		GLM_FUNC_DECL tref1<T, P> & operator= (tref1<T, P> const & r);
		GLM_FUNC_DECL tref1<T, P> & operator= (tvec1<T, P> const & v);

		T& x;
	};

	GLM_DETAIL_IS_VECTOR(tvec1);

}//namespace detail
}//namespace glm

#ifndef GLM_EXTERNAL_TEMPLATE
#include "type_vec1.inl"
#endif//GLM_EXTERNAL_TEMPLATE

#endif//glm_core_type_gentype1
<|endoftext|>